How to monitoring Linux KVM with snmp
on ubuntu
Frist you must install git and other package with
# apt-get install git –y
# apt-get install libvirt-dev -y
# apt-get install snmp snmpd libsnmp-dev libsnmp-perl –y
# apt-get install automake –y
# apt-get install make -y
After install this you must get libvirt-snmp with git
# git clone git://libvirt.org/libvirt-snmp.git
After clone libvirt-snmp git to your computer you must change directory to libvirt-snmp
# cd libvirt-snmp
And run a shell script file in this directory
# ./autobuild.sh
If every thing is ok you must have a tbz package into bellow address
# ~/libvirt-snmp/build
Change directory ti this and copy it to home directory for compile and build
# cp build/libvirt-snmp-0.0.3.tar.gz /root/
And unzip your package
# cd
# tar xzvf libvirt-snmp-0.0.3.tar.gz
Now you can compile your libvirt-snmp
# cd libvirt-snmp-0.0.3/
# ./configure
# make
# make install
Check your installation with bellow command
# which libvirtMib_subagent
You see a similar out put
/usr/local/bin/libvirtMib_subagent
Configure SNMP
First check snmpd is install in your machine
# /etc/init.d/snmpd status
If your daemon is install and you have a snmpd.conf file in /etc/snmp. Give a backup from this and copy
bellow information and restart your snmp daemon
# cd /etc/snmp
# mv snmpd.conf snmpd.conf_bk
# nano snmpd.conf
com2sec notConfigUser default public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1
access notConfigGroup "" any noauth exact systemview systemview none
access MyRWGroup "" any noauth 0 all all all
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
dontLogTCPWrappersConnects yes
master agentx
agentX Socket /var/agentx/master
trap2sink localhost public
save your change and restart daemon
# /etc/init.d/snmpd restart
Now you must start libvirtMib_subagent
# LIBVIRT_DEFAULT_URI="qemu:///system" libvirtMib_subagent -f –L > /dev/null &
NET-SNMP version 5.4.3 AgentX subagent connected
After it you can check your snmp information with
# snmpbulkwalk -c public -v2c localhost . -m ALL | head -5
If command cann’t find MIB files first chack mib path
# net-snmp-config --default-mibdirs
/root/.snmp/mibs:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr
/share/mibs/ietf:/usr/share/mibs/netsnmp
Then run bellow command
# apt-get install -y snmp-mibs-downloader
After install it you must run bellow command and find your snmp OID and use it
# snmpbulkwalk -v 2c -c public localhost -OX libvirtMIB -m all
LIBVIRT-MIB::libvirtGuestName[STRING: 38480573-71c0-3a16-a05e-8c476d32a806] = STRING:
"i-2-16-VM"
LIBVIRT-MIB::libvirtGuestName[STRING: 4981090b-d2b9-3584-9b22-5bc8bf94ef5e] = STRING:
"r-14-VM"
LIBVIRT-MIB::libvirtGuestName[STRING: 7efbdbe0-3d01-3b22-a8a0-1d41c6f2502f] = STRING: "i-
2-7-VM"
LIBVIRT-MIB::libvirtGuestName[STRING: dbccf7a6-cbb6-37d1-8763-83cf9ff8dcc6] = STRING: "i-2-
17-VM"
LIBVIRT-MIB::libvirtGuestName[STRING: f257919b-e2e-3d85-823e-c36d79e10727] = STRING: "r-
4-VM"
LIBVIRT-MIB::libvirtGuestName[STRING: fd78b75f-37c8-3679-80a1-60b82ef2c055] = STRING: "i-
2-8-VM"
LIBVIRT-MIB::libvirtGuestState[STRING: 38480573-71c0-3a16-a05e-8c476d32a806] = INTEGER:
running(1)
LIBVIRT-MIB::libvirtGuestState[STRING: 4981090b-d2b9-3584-9b22-5bc8bf94ef5e] = INTEGER:
running(1)
LIBVIRT-MIB::libvirtGuestState[STRING: 7efbdbe0-3d01-3b22-a8a0-1d41c6f2502f] = INTEGER:
running(1)
LIBVIRT-MIB::libvirtGuestState[STRING: dbccf7a6-cbb6-37d1-8763-83cf9ff8dcc6] = INTEGER:
running(1)
LIBVIRT-MIB::libvirtGuestState[STRING: f257919b-e2e-3d85-823e-c36d79e10727] = INTEGER:
running(1)
LIBVIRT-MIB::libvirtGuestState[STRING: fd78b75f-37c8-3679-80a1-60b82ef2c055] = INTEGER:
running(1)
LIBVIRT-MIB::libvirtGuestCpuCount[STRING: 38480573-71c0-3a16-a05e-8c476d32a806] =
Gauge32: 2
LIBVIRT-MIB::libvirtGuestCpuCount[STRING: 4981090b-d2b9-3584-9b22-5bc8bf94ef5e] =
Gauge32: 1
LIBVIRT-MIB::libvirtGuestCpuCount[STRING: 7efbdbe0-3d01-3b22-a8a0-1d41c6f2502f] =
Gauge32: 1
LIBVIRT-MIB::libvirtGuestCpuCount[STRING: dbccf7a6-cbb6-37d1-8763-83cf9ff8dcc6] =
Gauge32: 2
LIBVIRT-MIB::libvirtGuestCpuCount[STRING: f257919b-e2e-3d85-823e-c36d79e10727] =
Gauge32: 1
LIBVIRT-MIB::libvirtGuestCpuCount[STRING: fd78b75f-37c8-3679-80a1-60b82ef2c055] =
Gauge32: 1
LIBVIRT-MIB::libvirtGuestMemoryCurrent[STRING: 38480573-71c0-3a16-a05e-8c476d32a806] =
Gauge32: 512
LIBVIRT-MIB::libvirtGuestMemoryCurrent[STRING: 4981090b-d2b9-3584-9b22-5bc8bf94ef5e] =
Gauge32: 128
LIBVIRT-MIB::libvirtGuestMemoryCurrent[STRING: 7efbdbe0-3d01-3b22-a8a0-1d41c6f2502f] =
Gauge32: 1024
LIBVIRT-MIB::libvirtGuestMemoryCurrent[STRING: dbccf7a6-cbb6-37d1-8763-83cf9ff8dcc6] =
Gauge32: 512
LIBVIRT-MIB::libvirtGuestMemoryCurrent[STRING: f257919b-e2e-3d85-823e-c36d79e10727] =
Gauge32: 128
LIBVIRT-MIB::libvirtGuestMemoryCurrent[STRING: fd78b75f-37c8-3679-80a1-60b82ef2c055] =
Gauge32: 512
LIBVIRT-MIB::libvirtGuestMemoryLimit[STRING: 38480573-71c0-3a16-a05e-8c476d32a806] =
Gauge32: 512
LIBVIRT-MIB::libvirtGuestMemoryLimit[STRING: 4981090b-d2b9-3584-9b22-5bc8bf94ef5e] =
Gauge32: 128
LIBVIRT-MIB::libvirtGuestMemoryLimit[STRING: 7efbdbe0-3d01-3b22-a8a0-1d41c6f2502f] =
Gauge32: 1024
LIBVIRT-MIB::libvirtGuestMemoryLimit[STRING: dbccf7a6-cbb6-37d1-8763-83cf9ff8dcc6] =
Gauge32: 512
LIBVIRT-MIB::libvirtGuestMemoryLimit[STRING: f257919b-e2e-3d85-823e-c36d79e10727] =
Gauge32: 128
LIBVIRT-MIB::libvirtGuestMemoryLimit[STRING: fd78b75f-37c8-3679-80a1-60b82ef2c055] =
Gauge32: 512
LIBVIRT-MIB::libvirtGuestCpuTime[STRING: 38480573-71c0-3a16-a05e-8c476d32a806] =
Counter64: 737580000000
LIBVIRT-MIB::libvirtGuestCpuTime[STRING: 4981090b-d2b9-3584-9b22-5bc8bf94ef5e] =
Counter64: 1451830000000
LIBVIRT-MIB::libvirtGuestCpuTime[STRING: 7efbdbe0-3d01-3b22-a8a0-1d41c6f2502f] =
Counter64: 5264560000000
LIBVIRT-MIB::libvirtGuestCpuTime[STRING: dbccf7a6-cbb6-37d1-8763-83cf9ff8dcc6] =
Counter64: 84100000000
LIBVIRT-MIB::libvirtGuestCpuTime[STRING: f257919b-e2e-3d85-823e-c36d79e10727] =
Counter64: 4827100000000
LIBVIRT-MIB::libvirtGuestCpuTime[STRING: fd78b75f-37c8-3679-80a1-60b82ef2c055] =
Counter64: 4703990000000
LIBVIRT-MIB::libvirtGuestRowStatus[STRING: 38480573-71c0-3a16-a05e-8c476d32a806] =
INTEGER: active(1)
LIBVIRT-MIB::libvirtGuestRowStatus[STRING: 4981090b-d2b9-3584-9b22-5bc8bf94ef5e] =
INTEGER: active(1)
LIBVIRT-MIB::libvirtGuestRowStatus[STRING: 7efbdbe0-3d01-3b22-a8a0-1d41c6f2502f] =
INTEGER: active(1)
LIBVIRT-MIB::libvirtGuestRowStatus[STRING: dbccf7a6-cbb6-37d1-8763-83cf9ff8dcc6] =
INTEGER: active(1)
LIBVIRT-MIB::libvirtGuestRowStatus[STRING: f257919b-e2e-3d85-823e-c36d79e10727] =
INTEGER: active(1)
LIBVIRT-MIB::libvirtGuestRowStatus[STRING: fd78b75f-37c8-3679-80a1-60b82ef2c055] =
INTEGER: active(1)
Or you can see a table of running machine with
# snmptable -m ALL -v 2c -c public -Cb localhost libvirtGuestTable
f7f92f9b-14e7-4621-849c-ac51977751c3