zoukankan      html  css  js  c++  java
  • cacti批量添加主机脚本

    #!/bin/bash
    
    ##cacti批量脚本位置
    device=/var/www/html/cacti/cli/add_device.php
    graphs=/var/www/html/cacti/cli/add_graphs.php
    tree=/var/www/html/cacti/cli/add_tree.php
    
    ##需要添加的host ip在ip.txt中
    host_ips=`cat ip.txt`
    
    ##开始循环遍历
    for host_ip in $host_ips;
    do
        echo $host_ip
    
    ##这个是添加device 其中--tempate是应用的主机模板,可以通过add_device.php --list-host-templates来查看,后面的是snmp的
        php $device  --description=$host_ip --ip=$host_ip --template=8  --version=2  --community=public
    
    ##添加host后获取Host的ip
        host_id=`php $graphs --list-hosts | grep $host_ip | awk -F " " '{print $1}'`
    
    ##开始绘图,可以通过add_graphs.php --list-templates来查看有哪些图形模板,可以从手动添加监控绘图里面查看绘图的模板,然后来湖区其模板id
        php $graphs --host-id="$host_id" --graph-type=cg --graph-template-id=4
        php $graphs --host-id="$host_id" --graph-type=cg --graph-template-id=11
        php $graphs --host-id="$host_id" --graph-type=cg --graph-template-id=13
        php $graphs --host-id="$host_id" --graph-type=cg --graph-template-id=128
        php $graphs --host-id="$host_id" --graph-type=cg --graph-template-id=129
        php $graphs --host-id="$host_id" --graph-type=cg --graph-template-id=129
        php $graphs --host-id="$host_id" --graph-type=cg --graph-template-id=28
        php $graphs --host-id="$host_id" --graph-type=cg --graph-template-id=29
        php $graphs --host-id="$host_id" --graph-type=cg --graph-template-id=29
    
    ##绘制流量图形,后面是接口,需要注意template id是否正确
        php $graphs --host-id="$host_id" --graph-type=ds --graph-template-id=2 --snmp-query-id=1 --snmp-query-type-id=16 --snmp-field=ifDescr --snmp-value="eth0"
    
    ##绘制磁盘占用图形
        php $graphs --host-id="$host_id" --graph-type=ds --graph-template-id=26 --snmp-query-id=8 --snmp-query-type-id=18 --snmp-field=hrStorageDescr --snmp-value="/"
    
        php $graphs --host-id="$host_id" --graph-type=ds --graph-template-id=26 --snmp-query-id=8 --snmp-query-type-id=18 --snmp-field=hrStorageDescr --snmp-value="Swap space"
    
        php $graphs --host-id="$host_id" --graph-type=ds --graph-template-id=26 --snmp-query-id=8 --snmp-query-type-id=18 --snmp-field=hrStorageDescr --snmp-value="Physical memory"
    
        php $graphs --host-id="$host_id" --graph-type=ds --graph-template-id=26 --snmp-query-id=8 --snmp-query-type-id=18 --snmp-field=hrStorageDescr --snmp-value="Memory buffers"
    
        php $graphs --host-id="$host_id" --graph-type=ds --graph-template-id=26 --snmp-query-id=8 --snmp-query-type-id=18 --snmp-field=hrStorageDescr --snmp-value="Cached memory"
    
        php $graphs --host-id="$host_id" --graph-type=ds --graph-template-id=26 --snmp-query-id=8 --snmp-query-type-id=18 --snmp-field=hrStorageDescr --snmp-value="Virtual memory"
    
    ##加入到tree中,可以用过add_tree.php --list-tree查看已有tree
        php $tree --host-id="$host_id" --type=node --node-type=host --tree-id=1
    done
  • 相关阅读:
    数据访问 之 修改数据 (重要)---2017-04-27
    数据访问 之 删除操作 ------ 2017-04-27
    连接数据库的注册、登录----2017-04-26
    数据访问(创建链接、读取数据、例题)--2017-04-25
    C/S 和B/S 详解 --- 2017-04-25
    二阶段测试改错与反思(数据库+面向对象)----2017-04-24
    qq面板(仿版,未完待续中。。。。)---2017-04-24
    网站设计需要注意的20个常犯错误---2017-04-23
    数据库四大特性;
    数据库部分---查询-简单查询;
  • 原文地址:https://www.cnblogs.com/cmsd/p/3593497.html
Copyright © 2011-2022 走看看