码迷,mamicode.com
首页 > 移动开发 > 详细

批量生成nagios监控主机

时间:2015-03-18 10:44:34      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:监控主机

#!/bin/bash
exec <22.txt
while read line
do
#############################
 
echo ‘define host {‘ >>ping.host
 echo ‘        use                     linux-server‘ >>ping.host
 echo "        host_name               `echo $line|awk ‘{print $1}‘`" >>ping.host
 echo "        alias                   `echo $line|awk ‘{print $1}‘` " >>ping.host
 echo "        address                 `echo $line|awk ‘{print $2}‘` " >>ping.host
 echo ‘        register                1‘ >>ping.host
 echo ‘        contact_groups          MISAdmin‘ >>ping.host
 echo "}" >>ping.host
 
##########################################
           #P I N G
echo ‘define service {‘ >>ping.host
 echo ‘        use                     generic-service‘ >>ping.host
 echo "        host_name               `echo $line|awk ‘{print $1}‘`" >>ping.host
 echo "        service_description     linux_PING " >>ping.host
 echo "        check_command           check_ping!100.0,20%!500.0,60% " >>ping.host
 echo ‘register1‘ >>ping.host
 echo ‘contact_groupsMISAdmin‘ >>ping.host
 echo "}" >>ping.host
###########################
           #C P U
######################################
#########################################
            
            #Memory      
#$ echo ‘define service {‘ >>ping.host
# echo ‘        use                     generic-service‘ >>ping.host
# echo "        host_name               `echo $line|awk ‘{print $1}‘`" >>ping.host
# echo "        service_description     ESXi Memory Usage" >>ping.host
# echo ‘        check_command           check_nrpe_memory‘   >>ping.host
# echo ‘register1‘ >>ping.host
# echo ‘contact_groupsMISAdmin‘ >>ping.host
# echo "}" >>ping.host
##########################################
                   
                 #Network
 echo ‘define service {‘ >>ping.host
 echo ‘        use                     generic-service‘ >>ping.host
 echo "        host_name               `echo $line|awk ‘{print $1}‘`" >>ping.host
 echo "        service_description     linux_http" >>ping.host
 echo ‘        check_command           check_http‘   >>ping.host
 echo ‘register1‘ >>ping.host
 echo ‘contact_groupsMISAdmin‘ >>ping.host
 echo "}" >>ping.host
#########################################
              
 echo ‘define service {‘ >>ping.host
 echo ‘        use                     generic-service‘ >>ping.host
 echo "        host_name               `echo $line|awk ‘{print $1}‘`" >>ping.host
 echo "        service_description     linux_ssh" >>ping.host
 echo ‘        check_command           check_ssh‘   >>ping.host
 echo ‘register1‘ >>ping.host
 echo ‘contact_groupsMISAdmin‘ >>ping.host
 echo "}" >>ping.host
###########################################
                   #io_read
 echo ‘define service {‘ >>ping.host
 echo ‘        use                     generic-service‘ >>ping.host
 echo "        host_name               `echo $line|awk ‘{print $1}‘`" >>ping.host
 echo "        service_description     linux_swap" >>ping.host
 echo ‘        check_command           check_local_swap!20!10‘   >>ping.host
 echo ‘register1‘ >>ping.host
 echo ‘contact_groupsMISAdmin‘ >>ping.host
 echo "}" >>ping.host
###########################################
 echo ‘define service {‘ >>ping.host
 echo ‘        use                     generic-service‘ >>ping.host
 echo "        host_name               `echo $line|awk ‘{print $1}‘`" >>ping.host
 echo "        service_description     linux-disk" >>ping.host
 echo ‘        check_command           check_local_disk!20%!10%!/‘   >>ping.host
 echo ‘register1‘ >>ping.host
 echo ‘contact_groupsMISAdmin‘ >>ping.host
 echo "}" >>ping.host
###########################################
 echo ‘define service {‘ >>ping.host
 echo ‘        use                     generic-service‘ >>ping.host
 echo "        host_name               `echo $line|awk ‘{print $1}‘`" >>ping.host
 echo "        service_description     linux_users" >>ping.host
 echo ‘        check_command           check_local_users!20!50‘   >>ping.host
 echo ‘register1‘ >>ping.host
 echo ‘contact_groupsMISAdmin‘ >>ping.host
 echo "}" >>ping.host
###############################################
done


本文出自 “星空” 博客,请务必保留此出处http://liuxiaolan.blog.51cto.com/7789055/1621689

批量生成nagios监控主机

标签:监控主机

原文地址:http://liuxiaolan.blog.51cto.com/7789055/1621689

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!