Skip to content
Snippets Groups Projects
Commit 2cf0a57b authored by Ricardo Rocha's avatar Ricardo Rocha
Browse files

make sure it's integers we're dealing with

parent 55e3dfc1
No related branches found
No related tags found
No related merge requests found
......@@ -52,14 +52,14 @@ class process:
"""
String representation for performance
"""
procname = str.replace(self.comm, '.', '-')
procname = str.replace(self.comm, '.', '-')
return "'%s instances'=%d '%s cpu'=%.2f%% '%s mem'=%.2f%% '%s thr'=%d '%s conn'=%d '%s fd'=%d" % \
(procname, len(self.pid),
procname, self.cpu,
procname, self.mem,
procname, self.thr,
procname, self.conn,
procname, self.fd)
(procname, len(self.pid),
procname, self.cpu,
procname, self.mem,
procname, self.thr,
procname, self.conn,
procname, self.fd)
class check_process:
"Checks a process activity"
......@@ -174,18 +174,18 @@ Description of work executed by the probe:
proc.thr += int(threads)
# Network connections
(status, lsof_out) = commands.getstatusoutput("sudo -n /usr/sbin/lsof -a -i4 -i6 -p %d" % pid)
(status, lsof_out) = commands.getstatusoutput("sudo -n /usr/sbin/lsof -a -i4 -i6 -p %d" % int(pid))
if status == 0:
proc.conn += len(lsof_out.split('\n')) - 1
else:
debug("Could not retrieve sockets for %s (%d): Maybe died or sudo not configured properly" % (proc.comm, pid))
debug("Could not retrieve sockets for %s (%d): Maybe died or sudo not configured properly" % (proc.comm, int(pid)))
# File descriptors
(status, lsof_out) = commands.getstatusoutput("sudo -n /usr/sbin/lsof -a -d 0-99999 -p %d" % pid)
(status, lsof_out) = commands.getstatusoutput("sudo -n /usr/sbin/lsof -a -d 0-99999 -p %d" % int(pid))
if status == 0:
proc.fd = len(lsof_out.split('\n')) - 1
else:
debug("Could not retrieve file descriptors for %s (%d): Maybe died or sudo not configured properly" % (proc.comm, pid))
debug("Could not retrieve file descriptors for %s (%d): Maybe died or sudo not configured properly" % (proc.comm, int(pid)))
# Performance
performance = " ".join([ str(proc) for proc in self.proc_info.values() ])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment