Cacti - Template For VMSTAT

来源:互联网 发布:2017苹果mac桌面壁纸 编辑:程序博客网 时间:2024/06/05 02:16

Client

# vmstat 1 2, 一秒间隔,取两次,因为发现第一次不准确command[cacti_vmstat]=/usr/bin/vmstat 1 2

Server Data Input Method

/bin/bash <path_cacti>/scripts/bigbig_vmstat_cpu.sh <server_addr>
#!/bin/bash# bigbig_vmstat_cpu.shhostname=$1result=`/usr/local/nagios/libexec/check_nrpe -H $hostname -c cacti_vmstat | tail -n 1`# procrunning=`echo $result | awk '{print $1}'`busy=`echo $result | awk '{print $2}'`#echo -n "running:$running busy:$busy "# memoryswapd=`echo $result | awk '{print $3}'` && ((swapd=$swapd*1024))free=`echo $result | awk '{print $4}'` && ((free=$free*1024))buff=`echo $result | awk '{print $5}'` && ((buff=$buff*1024))cache=`echo $result | awk '{print $6}'` && ((cache=$cache*1024))#echo -n "swapd:$swapd free:$free buff:$buff cache:$cache "# swapsi=`echo $result | awk '{print $7}'` && ((si=$si*1024))so=`echo $result | awk '{print $8}'` && ((so=$so*1024))#echo -n "si:$si so:$so "# iobi=`echo $result | awk '{print $9}'`bo=`echo $result | awk '{print $10}'`#echo -n "bi:$bi bo:$bo "# systemin=`echo $result | awk '{print $11}'`cs=`echo $result | awk '{print $12}'`#echo -n "in:$in cs:$cs "# cpuus=`echo $result | awk '{print $13}'`sy=`echo $result | awk '{print $14}'`id=`echo $result | awk '{print $15}'`wa=`echo $result | awk '{print $16}'`st=`echo $result | awk '{print $17}'`echo -n "sdfsdf:123 user:$us system:$sy idle:$id wait:$wa stealt:$st sdf sdf sdf sdf "

Server - Template Import

http://pan.baidu.com/s/1dD34F1B

Use Script Add The Graph

#!/bin/baship=$1# 判断是否存在,如果存在就退出hostfind=`php add_graphs.php --list-hosts | grep $ip$ | wc -l`[ $hostfind -eq 1 ] && ( echo "host $ip 已经存在 ";exit 0 )# 添加hostsphp add_device.php --description=$ip --ip=$ip --template=9hostid=`php add_graphs.php --list-hosts | grep $ip$ | awk '{print $1}'`echo $hostid#exit 0#[[ $hostid -gt 70 ]] || exit 0# 开始画vmstatphp add_graphs.php --graph-type=cg --graph-template-id=64 --host-id=$hostid --input-fields="server_addr=$ip"php add_graphs.php --graph-type=cg --graph-template-id=73 --host-id=$hostid --input-fields="server_addr=$ip"php add_graphs.php --graph-type=cg --graph-template-id=74 --host-id=$hostid --input-fields="server_addr=$ip"php add_graphs.php --graph-type=cg --graph-template-id=75 --host-id=$hostid --input-fields="server_addr=$ip"
0 0