My needs check windows process number.
import sys
import os
import commands
ip = sys.argv[5]
val = sys.argv[1]
oid = "HOST-RESOURCES-MIB::hrSWRunName"
cmd = "snmpwalk -v 2c -c public %s %s" % (ip,oid)
(r_c,r_e) = commands.getstatusoutput(cmd)
if r_c != 0:
print "C - snmpwalk is Error."
else:
for i in r_e.split('\n'):
a = i.split(':')[-1].strip(' "')
print a
Result:</p>
conhost.exe
conhost.exe
conhost.exe
conhost.exe
fdhost.exe
cmd.exe
fdhost.exe
I hope the result is. I do not know how to achieve it.
if sys.argv[1] <5:#count(conhost.exe)
print "critical -"
else:
print "OK - "
How the statistics of my results? conhost.exe 4 conhost.exe 1 conhost.exe 1