Nagios监控自动化

  










# !/bin/bash   # yuchunyun   #时间:2014/03/14   #用途:此脚本用于监控主机nagios添加被监控端的主机定义   #用法:使用此脚本之前,请确保被监控端已安装nrpe服务,且本机具备连接其nrpe的权限   cfg_path=/usr/地方/nagios//etc/对象   nagios_cfg=/usr/地方/nagios/etc/nagios.cfg   读- p”请输入主机名(如10.8.8.141):“主机名   阅读- p“请输入alise (141):“alise   读- p”请输入ipaddress(如10.8.8.141):“ip   主机=' sed - n/主机名/p nagios_cfg美元”   如果(" $主机"=" ");   回声“cfg_file=cfg_path/主机名美元。在祝辞cfg”;nagios_cfg美元   回声“定义主机{   美元host_name主机名   别名alise美元   地址$ ip   check_command check-host-alive   notification_options d u r   check_interval 1   max_check_attempts 2   contact_groups管理员   notification_interval 10   notification_period 24 x7   }”在cfg_path/hostname.cfg美元   回声“# # # # # # # # # # # # # # # # # # # # # # # # # # # # #”   回声”主持人:美元主机名添加好了”   回声“# # # # # # # # # # # # # # # # # # # # # # # # # # # # #”   其他的   回声”主持人:$主机名已经存在! ! !”   fi


# !/bin/bash   # yuchunyun   #时间:2014/03/14   #用途:此脚本用于监控主机nagios配置被监控端上的服务监控   #用法:使用此脚本之前请确保已用host.sh脚本定义了该被监控主机。由于监控插件有限,所以只能提供下面列出的监控模板!   cfg_path=/usr/地方/nagios/etc/对象   nagios_cfg=/usr/地方/nagios/etc/nagios.cfg   nagios_bin=/usr/地方/nagios/bin/nagios   读- p”请输入主机名已经补充道:“主机名   主机=' sed - n/主机名/p nagios_cfg美元”   如果(" $主机"=" ");   回声”主持人:主机名是undefind美元! ! !”   其他的   ((i=0; i<10;我+ +));   做   回声“请选择一些服务监控”   回声“# # # # # #   ID服务命令   1总用户- - - - - -在check_user; #监控系统登录人数   2系统负载——→check_load; #监控系统负载   3总过程——祝辞check_total_procs; #监控系统进程数   4盘- - - - - - - - - - - -在check_disk; #监控磁盘使用情况   5记忆- - - - - - - - - - -在check_free_memory; #监控内存使用情况   6传热性能- - - - - - - - - -→check_contect_est; #监控活动的网络连接数   7 Httpd进程——→check_httpd_proces; #监监控apache进程数   8 Nginx过程——→check_nginx_proces; #监控Nginx进程数   9 Php过程——祝辞check_php_proces; #监控Php进程数   10 Mysql过程——→check_mysql_proces; #监控Mysql进程数   11 Java进程——祝辞check_java_proces; #监控Java进程数   12辞职”   echo - n“请inpout ID你想检查(1 - 10):“   读id   如果($ id eq 1);   回声”定义服务{   美元host_name主机名   service_description总用户   check_period 24 x7   normal_check_interval 2   retry_check_interval 1   max_check_attempts 5   notification_period 24 x7   notification_options w, u c r   check_command check_nrpe ! check_user   }”,祝辞的在cfg_path/hostname.cfg美元   回声“用户监控总好!”   elif ($ id eq 2);   回声”定义服务{   美元host_name主机名   service_description系统负载   check_period 24 x7   normal_check_interval 2   retry_check_interval 1   max_check_attempts 5   notification_period 24 x7   notification_options w, u c r   check_command check_nrpe ! check_load   }”,祝辞的在cfg_path/hostname.cfg美元   回声”系统负载监控好!”   elif ($ id eq 3);   回声”定义服务{   美元host_name主机名   service_description总过程   check_period 24 x7   normal_check_interval 2   retry_check_interval 1   max_check_attempts 5   notification_period 24 x7   notification_options w, u c r   check_command check_nrpe ! check_total_procs   }”,祝辞的在cfg_path/hostname.cfg美元   回声”总过程监控好!”   elif eq 4] [$ id,然后   回声”定义服务{   美元host_name主机名   service_description磁盘   check_period 24 x7   normal_check_interval 2   retry_check_interval 1   max_check_attempts 5   notification_period 24 x7   notification_options w, u c r   check_command check_nrpe ! check_disk   }”,祝辞的在cfg_path/hostname.cfg美元   回声“磁盘监控好!”   elif ($ id情商5);   回声”定义服务{   美元host_name主机名   service_description记忆   check_period 24 x7   normal_check_interval 2   retry_check_interval 1   max_check_attempts 5   notification_period 24 x7   notification_options w, u c r   check_command check_nrpe ! check_free_memory   }”,祝辞的在cfg_path/hostname.cfg美元   回声“记忆监控好!”   elif eq 6] [$ id,然后   回声”定义服务{   美元host_name主机名   service_description传热性能   check_period 24 x7   normal_check_interval 2   retry_check_interval 1   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

Nagios监控自动化