#!/bin/bash rm -f tree_ip tree_hostname Rootdir="/usr/share/cacti/cli" i=0 Add_tree(){ awk ‘{print $1}‘ $1 > tree_ip awk ‘{print $2}‘ $1 > tree_hostname php -q $Rootdir/add_tree.php --list-trees echo "Please chose Tree ID:" read id 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<i;k++ )) do host_ids=`php $Rootdir/add_graphs.php --list-hosts | grep ${arr_IP[$k]} | awk -F " " ‘{print $1}‘` php $Rootdir/add_tree.php --host-id="$host_ids" --type=node --node-type=host --tree-id=$id done } if [[ $# -ne 1 ]];then echo -e "Usage:sh $0 list[what you wanna add] list eg:1.1.1.1 [email protected]" exit -1 fi Add_tree $1 #php -q add_tree.php --list-trees
时间: 2024-08-07 17:01:19