ITPub博客

首页 > Linux操作系统 > Linux操作系统 > cacti批量添加监控

cacti批量添加监控

原创 Linux操作系统 作者:wang_0720 时间:2014-03-11 15:19:06 0 删除 编辑
#!/bin/bash           
#read ip list
PHP=/usr/local/php/bin/php
CLI=/usr/local/apache/htdocs/cacti/cli
host_ips=`cat /usr/local/scripts/ips.txt`    
for host_ip in $host_ips
do
        #add devices   
        ${PHP} ${CLI}/add_device.php --description="$host_ip" --ip="$host_ip" --template=3 --version=2 --community="public"
         
        #obtain device's id    
        host_ids=`${PHP} ${CLI}/add_graphs.php --list-hosts | grep -w "$host_ip" | awk -F " " '{print $1}'`    
         
        #create template's graph 
       for graph_id in `4 11 13`
       do 
               ${PHP} ${CLI}/add_graphs.php --host-id="$host_ids" --graph-type=cg --graph-template-id="$graph_id"
         done
        #create NIC graph
        ${PHP} ${CLI}/add_graphs.php --host-id="$host_ids" --graph-type=ds  --graph-template-id=2 \
                   --snmp-query-id=1 --snmp-query-type-id=16 --snmp-field=ifDescr --snmp-value="eth0"    
        ${PHP} ${CLI}/add_graphs.php --host-id="$host_ids" --graph-type=ds  --graph-template-id=2 \
               --snmp-query-id=1 --snmp-query-type-id=16 --snmp-field=ifDescr --snmp-value="eth1"    
       
        #add devices to groups
        ${PHP} ${CLI}/add_tree.php --host-id="$host_ids" --type=node --node-type=host --tree-id=1
done

cat ips.txt
192.168.151.40
192.168.151.23
192.168.151.2
192.168.151.141

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27181165/viewspace-1107560/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-11-05

  • 博文量
    111
  • 访问量
    953137