Python Ops script Python monitors system load

Source: Internet
Author: User
Tags snmp

#!/usr/bin/Envpython#-*-coding=utf-8-*-#Using GPL v2.7#Author: [email protected]126. Com#python Monitoring System Load"""1, the realization principle: obtains the system information through the SNMP protocol, then carries on the corresponding computation and the format, the final output result2, special note: SNMP is required on the monitored machine.Yum Install-Y net-snmp*installation"""#!/usr/bin/pythonimport osdef getallitems (Host, OID): SN1= Os.popen ('snmpwalk-v 2c-c Public'+ Host +' '+ OID). Read ().Split('\ n') return SN1 def getload (host,loid): Load_oids='1.3.6.1.4.1.2021.10.1.3.'+Str (loid) return Getallitems (host,load_oids) [0].Split(':')[3]                                                                     if__name__ = ='__main__': Hosts= ['192.168.10.1','192.168.10.2'] #check_system_load Print'==============system load=============='         forHostinchHosts:load1= Getload (Host,1) Load10= Getload (Host,2) Load15= Getload (Host,3) Print'%s Load (1min):%s, Load (10min):%s, Load (15min):%s'% (HOST,LOAD1,LOAD10,LOAD15)

Python Ops script Python monitors system load

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.