-
Notifications
You must be signed in to change notification settings - Fork 0
/
hosts.cfg_pl.sh
41 lines (30 loc) · 875 Bytes
/
hosts.cfg_pl.sh
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
#!/bin/bash
## nagios批量生成配置文件 2016-08-04
## http://www.aqzt.com
##email: [email protected]
##robert yu
##centos 6
mkdir /root/test
#生成IP列表
for((i=1;i<=254;i++));do echo 192.168.10.$i;done > hosts.txt
for host in $(cat hosts.txt):
do
echo "$host in progress";
###snmpwalk -r 1 -t 1 -v 2c -c public $host:161 sysDescr | awk -F ' ' '{print $1}'
commande=`snmpwalk -r 1 -t 1 -v 2c -c public $host:161 sysDescr | awk -F ' ' '{print $1}'`
echo $commande
if [ -z "$commande" ] ; then
echo "No response"
else
cat >/root/test/$host.cfg<<EOF
define host{
use meiyou-linux,host-pnp
host_name $host
alias $host
address $host
}
EOF
echo -ne "$host,\c">>/root/test/hostgroup.conf
echo "Ok"
fi
done;