Difference between revisions of "Zabbix Discovery of guest"
From Linux-VServer
(using zabbix discovery features in prototype for vserver guest) |
|||
| (One intermediate revision by one user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | =Zabbix and Vserver guest discovery= | |
| − | + | Zabbix 2.4+ has an discovery system for ressources like disks and cpu. You can use it to detect running guest and monitor some 'stuff' like this: | |
| − | 1/ on the agentd configuration add | + | *1/ on the agentd configuration add |
UserParameter=vserver.discovery,/pathto/my/script/guestdetect.sh | UserParameter=vserver.discovery,/pathto/my/script/guestdetect.sh | ||
And restart the agent | And restart the agent | ||
| − | 2/ create the script /pathto/my/script/guestdetect.sh | + | *2/ create the script /pathto/my/script/guestdetect.sh |
#!/bin/bash | #!/bin/bash | ||
echo -n '{'; | echo -n '{'; | ||
| Line 17: | Line 17: | ||
guest=$(vserver-info "$xid" ID); | guest=$(vserver-info "$xid" ID); | ||
name=$(vserver-info "$guest" NAME); | name=$(vserver-info "$guest" NAME); | ||
| + | if [ "$I" != "0" ]; then echo -n ','; fi | ||
echo -n "{\"{#GUESTNAME}\":\"$name\",\"{#GUESTCTX}\":\"$xid\"}"; | echo -n "{\"{#GUESTNAME}\":\"$name\",\"{#GUESTCTX}\":\"$xid\"}"; | ||
I+=1; | I+=1; | ||
| Line 22: | Line 23: | ||
echo -n "]}"; | echo -n "]}"; | ||
| − | + | make it executable : chmod 755 /pathto/my/script/guestdetect.sh; | |
| − | 3/ add a discovery rule on a zabbix template using vserver.discovery as the key, then {#GUESTNAME} and {#GUESTCTX} as you see fit in your prototype. | + | *3/ add a discovery rule on a zabbix template using vserver.discovery as the key, then {#GUESTNAME} and {#GUESTCTX} as you see fit in your prototype. |
| − | + | Enjoy ! | |
Ghislain. | Ghislain. | ||
AQUEOS. | AQUEOS. | ||
Latest revision as of 11:16, 7 January 2015
[edit] Zabbix and Vserver guest discovery
Zabbix 2.4+ has an discovery system for ressources like disks and cpu. You can use it to detect running guest and monitor some 'stuff' like this:
- 1/ on the agentd configuration add
UserParameter=vserver.discovery,/pathto/my/script/guestdetect.sh
And restart the agent
- 2/ create the script /pathto/my/script/guestdetect.sh
#!/bin/bash
echo -n '{';
echo -n '"data":['
I=0;
for n in $(ls -d /proc/virtual/[0-9]*); do
xid=${n##*/};
guest=$(vserver-info "$xid" ID);
name=$(vserver-info "$guest" NAME);
if [ "$I" != "0" ]; then echo -n ','; fi
echo -n "{\"{#GUESTNAME}\":\"$name\",\"{#GUESTCTX}\":\"$xid\"}";
I+=1;
done
echo -n "]}";
make it executable : chmod 755 /pathto/my/script/guestdetect.sh;
- 3/ add a discovery rule on a zabbix template using vserver.discovery as the key, then {#GUESTNAME} and {#GUESTCTX} as you see fit in your prototype.
Enjoy !
Ghislain. AQUEOS.