IT运维流程库历史主题 · 只读
← 返回目录

简单的nagios主机配置文件---python

来自:网络

[ /jk409/blog/389008#]?
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
__author__ = 'Administrator' import sys,os
dir_cfg="./" #file=sys.argv[1] #hostname=sys.argv[2] #app=sys.argv[3] #ip=sys.argv[4] #port=sys.argv[5] def test(file,hostname,app,ip,port): nagios培训 filepath=dir_cfg+file
if os.path.exists(filepath): try: wf=open(filepath,'a') wf.write(data_02%(hostname,app,port)) nagios实施 wf.close()
except: print('Write file fail2!') wf.close() else: try: wf=open(filepath,'w') wf.write(data_01%(hostname,hostname,ip,hostname,app,port)) wf.close() except: print('Write file fail!') 监控软件 wf.close()
data_01=''' define host{ use generic-host host_name %s alias %s address %s } define service { use generic-service nagios配置 host_name %s
service_description %s check_command check_tcp!%s } ''' data_02=''' define service { use generic-service host_name %s service_description %s check_command check_tcp!%s 开源监控软件 }
''' #print("%-40s %-10s"%('7899999999999999999999','hhh')) if __name__ == "__main__": test('kkk.cfg','kkk','SSH','127.0.0.1','80') nagios安装

想做Nagios, Zabbix,Cacti,iTop各种交流的,可以进入开源监控工具Nagios交流 QQ群号 :476809427