Guest User

Untitled

a guest
Oct 4th, 2017
56
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2.  
  3. from optparse import OptionParser
  4. cmdline = OptionParser()
  5. cmdline.add_option( "-s", "--siteid", dest="siteID", default=0, type="int", help="site to examine" )
  6. cmdline.add_option( "-w", "--warning", dest="warning", default=60, type="int", help="warning level" )
  7. cmdline.add_option( "-c", "--critical", dest="critical", default=1440, type="int", help="critical level" )
  8. (options, args) = cmdline.parse_args()
  9.  
  10. if options.siteID:
  11.     siteID = options.siteID
  12.  
  13. if options.warning:
  14.     warn = options.warning
  15.  
  16. if options.critical:
  17.     crit = options.critical
  18.  
  19. if not siteID:
  20.         print "SiteID Needed"
  21.         exit (6)
  22.  
  23. import _mssql
  24. conn = _mssql.connect(server='192.168.55.100', user='user', password='password', database='db')
  25.  
  26. res = conn.execute_scalar('nagios_GetMinutesSinceLastReading @siteid=%d', siteID)
  27.  
  28. if res < warn:
  29.         print "OK: %d" % res
  30.         exit (0)
  31.  
  32. if res > warn < crit:
  33.         print "WARNING: %d" % res
  34.         exit (1)
  35.  
  36. if res > crit:
  37.         print "CRITICAL: %d" % res
  38.         exit (2)
  39.  
  40. conn.close()
RAW Paste Data