×

扫描二维码登录本站

QQ登录

只需一步,快速开始

来自:网络



[ ttp://my.oschina.net/jk409/blog/389008#]?[/url]
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





上一篇:如何在纯净ubuntu系统上安装nagios
下一篇:学习Nagios——Nagios配置
monicazhang

写了 2297 篇文章,拥有财富 12859,被 21 人关注

您需要登录后才可以回帖 登录 | 立即注册
B Color Link Quote Code Smilies

成为第一个吐槽的人

手机版|小黑屋|最新100贴|论坛版块|ITIL先锋论坛 |粤ICP备11099876号|网站地图
Powered by Discuz! X3.4 Licensed  © 2001-2017 Comsenz Inc.
返回顶部