aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-07-31 10:57:13 +0100
committerBryn M. Reeves <bmr@redhat.com>2014-07-31 10:57:13 +0100
commitc41584a5da76ae6e3e99e5fc76ebcd4ee41e9979 (patch)
treeb531d49050bbb7249194c70d655d0db801d145c8
parent9a4a594b950478c8ab375967206bd08a7baf2739 (diff)
downloadsos-c41584a5da76ae6e3e99e5fc76ebcd4ee41e9979.tar.gz
[pcp] use socket.gethostname() instead of shelling out
There's no need to take a fork to retrieve the system host name. Use the socket.gethostname() function instead (plugins also have no businness importing things from sos.utilities directly - all the useful functions in there have wrapper methods in the Plugin class, e.g. call_ext_prog(), check_ext_prog() etc.). Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/pcp.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/sos/plugins/pcp.py b/sos/plugins/pcp.py
index 7f67358d..f3d18c2c 100644
--- a/sos/plugins/pcp.py
+++ b/sos/plugins/pcp.py
@@ -15,9 +15,9 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
from sos.plugins import Plugin, RedHatPlugin, DebianPlugin
-from sos.utilities import sos_get_command_output
import os
import os.path
+from socket import gethostname
class Pcp(Plugin, RedHatPlugin, DebianPlugin):
@@ -115,13 +115,7 @@ class Pcp(Plugin, RedHatPlugin, DebianPlugin):
# won't work for directory trees. I.e. we can't say fetch /foo/bar/
# only if it is < 100MB. To be killed once the Plugin base class will
# add a method for this use case via issue #281
- ret = sos_get_command_output('hostname')
- if ret['status'] == 0:
- # Make sure that if output is not a string we do not barf
- try:
- self.pcp_hostname = ret['output'].strip()
- except:
- pass
+ self.pcp_hostname = gethostname()
# Make sure we only add PCP_LOG_DIR/pmlogger/`hostname` if hostname
# is set, otherwise we'd collect everything