Cacti - Template For VMSTAT

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.sh
hostname=$1
result=`/usr/local/nagios/libexec/check_nrpe -H $hostname -c cacti_vmstat | tail -n 1`

# proc
running=`echo $result | awk '{print $1}'`
busy=`echo $result | awk '{print $2}'`
#echo -n "running:$running busy:$busy "

# memory
swapd=`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 "

# swap
si=`echo $result | awk '{print $7}'` && ((si=$si*1024))
so=`echo $result | awk '{print $8}'` && ((so=$so*1024))
#echo -n "si:$si so:$so "

# io
bi=`echo $result | awk '{print $9}'`
bo=`echo $result | awk '{print $10}'`
#echo -n "bi:$bi bo:$bo "

# system
in=`echo $result | awk '{print $11}'`
cs=`echo $result | awk '{print $12}'`
#echo -n "in:$in cs:$cs "

# cpu
us=`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/bash

ip=$1

# 判断是否存在,如果存在就退出
hostfind=`php add_graphs.php --list-hosts | grep $ip$ | wc -l`
[ $hostfind -eq 1 ] && ( echo "host $ip 已经存在 ";exit 0 )

# 添加hosts
php add_device.php --description=$ip --ip=$ip --template=9
hostid=`php add_graphs.php --list-hosts | grep $ip$ | awk '{print $1}'`

echo $hostid
#exit 0

#[[ $hostid -gt 70 ]] || exit 0

# 开始画vmstat
php 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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值