Python Forum

Full Version: simplest way to check device status (Up/Down)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

small code to check device status through SNMP, if snmp response is not blank means device is up or else device is down... any suggestions please.


#!/usr/bin/python
from easysnmp import snmp_get, snmp_set, snmp_walk
ip = sys.argv[1]
oid  = 'sysDescr.0'

status = snmp_get(oid, hostname=ip, community='public', version=2)
if status !='':
   print (str(ip)+' ' +'Up\n')
else:
   print (str(ip)+' '+'Down\n')