cacti 批量添加监控主机 —简单的
2015-03-19 update#!/bin/bash
rm -f ip hostname
Rootdir="/var/www/html/cacti/cli/"
i=0
Add_host(){
awk '{print $1}' $1 > ip
awk '{print $2}' $1 > hostname
while read line
do
arr_IP[$i]="$line"
i=`expr $i + 1`
done < ip
i=0
while read line
do
arr_HOSTNAME[$i]="$line"
i=`expr $i + 1`
done < hostname
for (( k=0;k /tmp/list
sleep 3
while read line
do
php $Rootdir/add_graphs.php --host-id="$host_ids" --graph-type=ds--graph-template-id=26 --snmp-query-id=8 --snmp-query-type-id=18 --snmp-field=hrStorageDescr --snmp-value="$line"
sleep 1
done< /tmp/list
# php $Rootdir/add_graphs.php --host-id="$host_ids" --graph-type=ds--graph-template-id=26 --snmp-query-id=8 --snmp-query-type-id=18 --snmp-field=hrStorageDescr --list-snmp-values="Memory Buffers"
# php $Rootdir/add_graphs.php --host-id="$host_ids" --graph-type=ds--graph-template-id=26 --snmp-query-id=8 --snmp-query-type-id=18 --snmp-field=hrStorageDescr --list-snmp-values="Cached memory"
# php $Rootdir/add_graphs.php --host-id="$host_ids" --graph-type=ds--graph-template-id=26 --snmp-query-id=8 --snmp-query-type-id=18 --snmp-field=hrStorageDescr --list-snmp-values="Physical memory"
# php $Rootdir/add_graphs.php --host-id="$host_ids" --graph-type=ds--graph-template-id=26 --snmp-query-id=8 --snmp-query-type-id=18 --snmp-field=hrStorageDescr --list-snmp-values="Swap Space"
# php $Rootdir/add_tree.php --host-id="$host_ids" --type=node --node-type=host --tree-id=2
done
}
if [[ $# -ne 1 ]];then
echo -e "\e
list eg:1.1.1.1test@example.com\e[0m"
exit -1
fi
Add_host $1
2015-3-13更新版本
注意版本不同,可能php 运行时候加的参数也有不同,具体可以先运行php 查看
#!/bin/bash
rm -f ip hostname
Rootdir="/usr/share/cacti/cli"
i=0
Add_host(){
awk '{print $1}' $1 > ip
awk '{print $2}' $1 > hostname
while read line
do
arr_IP[$i]="$line"
i=`expr $i + 1`
done < ip
i=0
while read line
do
arr_HOSTNAME[$i]="$line"
i=`expr $i + 1`
done < hostname
for (( k=0;k ip
awk '{print $2}' iplist > hostname
i=0
while read line
do
arr_IP[$i]="$line"
i=`expr $i + 1`
done < ip
i=0
while read line
do
arr_HOSTNAME[$i]="$line"
i=`expr $i + 1`
done < hostname
for (( k=0;k
页:
[1]