Python Forum
simplest way to check device status (Up/Down)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
simplest way to check device status (Up/Down)
#1
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')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Copy data from 1 blk device in machine A to another blk device in machine B AbhishekV 2 3,422 Feb-01-2018, 11:40 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020