cacti 使用

一个向GraphTree中添加节点图片的脚本

ip="10.100.100.$1" 
cli_path="/var/www/cacti/cli"
host_id=`php /var/www/cacti/cli/add_tree.php --name=CrawlProxy --list-hosts|grep "$ip"|awk '{print $1}'`  #该条命令显示tree下面的所有host,也就是设备,根据grep设备名字提取设备的host_id
echo "ip:$ip,host_id:$host_id"
parent_id=`php ${cli_path}/add_tree.php --name=CrawlProx --list-nodes --tree-id=2|grep "$ip"|awk '{print $2}'` #该条命令从节点中提出节点的id,该id需要作为添加图偏的父节点id
echo "parent_id:$parent_id"
for graph_id in `php ${cli_path}/add_tree.php --name=CrawlProxy --list-graphs --host-id=${host_id}|grep "PerFercherOcStatus"|awk '{print $1}'` #取出hostid下的图片的id
do
echo graph_id:$graph_id
php ${cli_path}/add_tree.php --name=CrawlProxy --node-type=graph --tree-id=2 --parent-node=$parent_id --graph-id=$graph_id --type=node #执行添加图片到tree的命令,设置父id,和图片id
done

其他一些refer:

http://lihuipeng.blog.51cto.com/3064864/777363

http://hi.baidu.com/effdsuvnxiilqte/item/94a457ed990ef8bbc10d751f

原文地址:https://www.cnblogs.com/lovemdx/p/2762499.html