After installing the COLLECTD tool on the host, you can such as cpu,memery,if-traffic of the virtual machine on the host by using the COLLECTD tool. Monitoring of these data can be achieved through Nagios monitoring scripts.
The following is a simple monitoring virtual machine memory script:
#!/bin/bash#desc:to check memory about vm instancestate_ok=0state_warning=1state_ Critical=2state_unknown=3collectd_home=/usr/local/collectdcollectd_ctl= $COLLECTD _home/bin/collectdctlvmname=$ 1function usage () { msg= "$0 : use to Check vm memery usage for nagios " echo "****************************************************" echo -e "\033[1;94m${msg}\033[0m" echo -e " Usage: " echo -e " $0 [-w warning_value -c critical_value] vm_name " echo -e " $0 vmname " echo "****************************************************"}if [ $# -eq 0 ];then usage exit 1fimem_used= ' $COLLECTD _ctl getval $vmname/virt-$vmname/memory-rss | awk -f "=" ' {print $2} ' | awk ' {printf ("%.1f\n", $0/1024/1024)} ' Data= ' mem=$ mem_used "if [ -z $mem _used ];thenecho " unkown: fail to find vm_ instance! " exit $STATE _unknownelseecho "OK - USED : ${MEM_USED}MB | ${DATA}MB" exit $STATE _OKFI
This article from "Month Child" blog, declined reprint!
A simple example of nagios monitoring scripts for virtual machines via the COLLECTD tool