cacti 脚本批量添加 graphs tree

#!/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

cacti 脚本批量添加 graphs tree的相关文章

Cacti 系统批量添加Device脚本

[功能]: 自动添加设备,自动生成模板图像; 自动生成远程抓取的数据图像; 自动添加到相应的组. [准备工作]: 1.启动客户端snmpd服务,并设置snmpd.conf文件: /etc/init.d/snmpdstart ;chkconfig snmpd on [[email protected] .ssh]# cat /etc/snmp/snmpd.conf com2sec notConfigUser  default      public group  notConfigGroup v1

SHELL脚本批量添加用户

在Linux服务中添加相应的用户账号,初始密码均为"123456".可以先指定所有用户的列表文件,然后编写一个名为uadduser.sh的脚本 [[email protected] ~]# vim /root/users.txt                       //新建一个指定所有用户的列表文件xiaomingxiaoqingxiaofangxiaodong [[email protected] ~]# vim uadduser.sh         //创建批量添加用户的

&lt;linux小脚本&gt;批量添加/删除用户

批量添加/删除用户,当输入add时,判断用户是否存在,存在则显示存在,不存在则添加:当输入del时,判断用户是否存在,存在则删除用户,不存在则显示不存在. #!/bin/bash if [ $1 == "add" ];then for i in {1..10}; do if id user$i &> /dev/null;then echo "the user$i exists!" else useradd user$i &> /dev/n

脚本批量添加和批量删除用户

批量添加用户 #!/bin/bash i=1while [ $i -le 20 ]do useradd stu$i echo "123456" | passwd --stdin stu$i &> /dev/null i=$(($i+1))done # 删除用户 #!/bin/bash# 批量删除用户user=$(cat /etc/passwd | grep "/bin/bash" | grep -v "root"|grep -v &

powershell小脚本--批量添加用户属性----导出登录时间

需求1:某公司所有员工少了MAIL属性,需要批量添加.例如,用户chenyy  添加邮件属性[email protected] 先导出(只导出名字)备用: Get-ADUser -Filter * -Properties * | select name | Export-Csv c:\test.csv 用where条件可以过滤系统账号 Get-ADUser -Filter * -Properties * |where {$_.UserPrincipalName -ne $null} | sele

KVM脚本批量添加删除虚拟机版本2

在原有的基础上,做些功能上的添加. 修改虚拟机的主机名 修改虚拟机的MAC 修改虚拟机的IP 虚拟机采用qcow2格式,使用qemu-img的backing_file技术,快速生成虚拟机 这样,虚拟机创建好后,便可以远程管理了. 第1版,请参考: http://5ydycm.blog.51cto.com/115934/1211630 第2版,create_delete_vm.py代码: #!/usr/bin/env python #coding:utf-8 ###################

SHELL 脚本批量添加删除用户

#!/bin/bash # # read -p "keyin add or del:  " keyin for i in `seq -w 10`;do password=user$i`echo $RANDOM | md5sum | cut -c 1-5` case $keyin in add) if ! id user$i &> /dev/null ;then useradd user$i &> /dev/null echo $password | pass

Linux系统编写shell脚本批量创建和删除用户

一.编写shell脚本批量添加用户 实现方法:判断用户是否存在,存在则返回错误提示,同时判断用户文件是否存在,不存在则退出 1.创建添加用户脚本 [[email protected] ~]# vim useradd.sh #!/bin/bashif [ $# -eq 0 ];then        echo "你没有输入任何文件!"        exit 1fi if [ ! -f $1 ];then        echo "输入有误!"        exit

PowerShell批量添加VM端点

我们可以通过PowerShell脚本批量添加VM端点.请您参考以下方案. 准备工作 – PowerShell连接China Azure 1. 从官网下载页面,下载并安装Windows Azure PowerShell: http://www.windowsazure.cn/zh-cn/downloads/#cmd-line-tools 2. 安装完毕后以管理员身份运行,右键点击PowerShell图标然后选择以管理员身份运行: 3. 执行命令Get-AzurePublishSettingsFil