#!/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
分享名称:批量生成nagios监控主机
文章链接:
http://cdxtjz.cn/article/pesgih.html