autocheck_hour.py 917 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Mon Dec 3 17:40:17 2018
  5. @author: dufs
  6. """
  7. import sys
  8. import logging.config
  9. import hostinfo as hf
  10. import snmpclient as scl
  11. if __name__ == '__main__':
  12. logging.config.fileConfig("conf/logging.conf")
  13. #create logger
  14. logger = logging.getLogger("autocheck")
  15. hostList=hf.get_hostinfo(False)
  16. if hostList[0]!=0:
  17. logger.error('get hostinfo error')
  18. raise
  19. hostSet=set()
  20. for host in hostList[1]:
  21. hostSet.add((host[1], 'SNMP_COMMUNITY', host[0]))
  22. logger.info('get host number %d', len(hostSet))
  23. if len(hostSet)>0:
  24. oidSet=set()
  25. oidSet.add(('disk', 'snmpdf'))
  26. oidSet.add(('mem', 'memTotalReal'))
  27. oidSet.add(('mem', 'memAvailReal'))
  28. oidSet.add(('cpu', 'ssCpuIdle'))
  29. scl.snmp_batch_cmd(hostSet, oidSet)
  30. logger.info('exec autocheck_hour finished')