Zabbix template

curly882

New Member
Sep 15, 2020
4
0
1
33
Hi all.
Which templates or custom scripts best for monitoring proxmox cluster whith zabbix agent?
Who what used?
 
hi,

you can use the regular linux templates which come with zabbix - that will cover your most needs.

if you need to monitor anything specific you can easily create items or scripts according to your needs
 
You can have a look at my scripts, made to monitor a whole cluster (just point zabbix at one node, which will monitor everything else) : https://git.fws.fr/fws/zabbix-agent-addons

in zabbix_scripts, you'll find disco_pve_sudo and check_pve_sudo which will do the hardwork (it's calling pvesh to get data from the API). in zabbix_conf you'll find pve.conf, which must be added to the agent's config on the node you monitor, and in zabbix_templates you'll find the associated template named Template_App_PVE_Cluster.xml

All this together will :
  • Discover all nodes and collect stats (resources usage) and triggers (not all nodes online, non quorate cluster, high load etc.)
  • Discover all guests and collect stats (resources usages, uptime
  • Disover VM pools to also collect pool wide stats
  • Discover storage with triggers when one is nearly full
Hope it helps.
Cheers,
Daniel
 
You can have a look at my scripts, made to monitor a whole cluster (just point zabbix at one node, which will monitor everything else) : https://git.fws.fr/fws/zabbix-agent-addons

in zabbix_scripts, you'll find disco_pve_sudo and check_pve_sudo which will do the hardwork (it's calling pvesh to get data from the API). in zabbix_conf you'll find pve.conf, which must be added to the agent's config on the node you monitor, and in zabbix_templates you'll find the associated template named Template_App_PVE_Cluster.xml

All this together will :
  • Discover all nodes and collect stats (resources usage) and triggers (not all nodes online, non quorate cluster, high load etc.)
  • Discover all guests and collect stats (resources usages, uptime
  • Disover VM pools to also collect pool wide stats
  • Discover storage with triggers when one is nearly full
Hope it helps.
Cheers,
Daniel
is there any installation instructions step by step?
 
No step by step doc written, but here are the main steps :
  • Put disco_pve_sudo and check_pve_sudo on the PVE host you want to monitor. For example in /var/lib/zabbix/bin. Makes sure the scripts are executable. You might need to install some perl libs if they are not already installed (libconfig-simple-perl, libjson-perl and libfile-which-perl)
  • Add the content of zabbix_conf/pve.conf to the Zabbix agent conf. Either in the main zabbix_agentd.conf file or included. You might need to adapt the path of the scripts if it's not /var/lib/zabbix/bin
  • Makes sure zabbix user can run scripts with sudo permissions without password. See an example in conf/sudo.conf file
  • Import the file zabbix_templates/Template_App_PVE_Cluster.xml file on your Zabbix server.
  • Create a new host pointing at your PVE node, and add the Template_App_PVE_Cluster template on it
Discovery rules should detect all your VM, nodes, pools, storage and monitor them automaticaly
 
No step by step doc written, but here are the main steps :
  • Put disco_pve_sudo and check_pve_sudo on the PVE host you want to monitor. For example in /var/lib/zabbix/bin. Makes sure the scripts are executable. You might need to install some perl libs if they are not already installed (libconfig-simple-perl, libjson-perl and libfile-which-perl)
  • Add the content of zabbix_conf/pve.conf to the Zabbix agent conf. Either in the main zabbix_agentd.conf file or included. You might need to adapt the path of the scripts if it's not /var/lib/zabbix/bin
  • Makes sure zabbix user can run scripts with sudo permissions without password. See an example in conf/sudo.conf file
  • Import the file zabbix_templates/Template_App_PVE_Cluster.xml file on your Zabbix server.
  • Create a new host pointing at your PVE node, and add the Template_App_PVE_Cluster template on it
Discovery rules should detect all your VM, nodes, pools, storage and monitor them automaticaly
I think I did all the step so far except this one:
  • Makes sure zabbix user can run scripts with sudo permissions without password. See an example in conf/sudo.conf file
I am not sure I understand it correctly. Zabbix agent will connect to the PVE and will execute the 2 scripts in /var/lib/zabbix/bin without password? Is that right? If so then how should I do it?
 
You need a zabbix agent running on the pve node
The Agent is installed, but I still have no idea on how to quote "zabbix user can run scripts with sudo permissions without password"
The conf/sudo.conf example don`t ring any bell for me... I don`t understand it
 
Last edited:
OK. So, the zabbix user account running Zabbix agent on your PVE must be able to run the scripts with sudo, without password. You should be able to just drop conf/sudo.conf in /etc/sudoers.d/zabbix_agent.conf and it should work. (just adapt the path if you use something else than /var/lib/zabbix/bin)
 
OK. So, the zabbix user account running Zabbix agent on your PVE must be able to run the scripts with sudo, without password. You should be able to just drop conf/sudo.conf in /etc/sudoers.d/zabbix_agent.conf and it should work. (just adapt the path if you use something else than /var/lib/zabbix/bin)
Thank you very much for your help.

Unfortunately and for some reason I`ve got an error:


Zabbix agent item "pve.check.all[cluster]" on host "PVE" failed: first network error, wait for 15 seconds

And this is really strange as I have no problem with my network for sure.
 
This is really more a Zabbix issue than a PVE one. On the PVE node, you have to check you have allowed your server (or proxy, depending on your setup) in /etc/zabbix/zabbix_agentd.conf with the Server directive. You also need to have the port 10050 reachable
 
This is really more a Zabbix issue than a PVE one. On the PVE node, you have to check you have allowed your server (or proxy, depending on your setup) in /etc/zabbix/zabbix_agentd.conf with the Server directive. You also need to have the port 10050 reachable
Yes I`ve configured zabbix_agentd.conf and set the IP of the Zabbix Server, also there is no firewall restricting port 10050 on the PVE
 
I have a small problem with your description, I using Proxmox 6.2. My Zabbix is 5.2.1 on a different server. The agent on the pve is 5.2.

If i run the disco_pve_sudo then it shows me following:
Code:
{"data":[{"{#PVE_NODE_IP}":"192.168.2.253","{#PVE_NODE_LOCAL}":1,"{#PVE_NODE_NAME}":"pve002253","{#PVE_NODE_ID}":0}]}

if i run the check_pve_sudo it shows:
Code:
ZBX_NOTSUPPORTED

The libconfig-simple-perl, libjson-perl, libfile-which-perl and sudo is installed via apt-get

In agents-config the ip for the adress is set

in /etc/zabbix/zabbix_agentd.d the pve.conf file is downloaded

But no data is send to my zabbix-server
 
Last edited:
check_pve_sudo needs some parameters. The script can be run manually with eg

Code:
/var/lib/zabbix/bin/check_pve_sudo --cluster
/var/lib/zabbix/bin/check_pve_sudo --node=pve1
/var/lib/zabbix/bin/check_pve_sudo --guest=110
/var/lib/zabbix/bin/check_pve_sudo --storage=local-zfs

(you can add --pretty to have a more readable output)

But all this is called by the zabbix agent. To test it, you can use eg :

Code:
zabbix_agentd -t pve.check.all[cluster]
zabbix_agentd -t pve.check.all[node,pve1]
zabbix_agentd -t pve.check.all[guest,110]
zabbix_agentd -t pve.check.all[storage,local-zfs]

If this is working then the agent config is fine
 
If this is working then the agent config is fine
Ok - that was my fault. Now the start on command line give me results.

But in zabbix i have following value (the only one):
Code:
PVE Cluster: info
    2020-11-27 21:06:05    We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. sudo: no tty present and no askpass program specified

I think some is missing. the sudo.conf is copied to /etc/sudoers.d/ and renamed to zabbix_agent.conf - is that the right place or was could be wrong with that?

Solution found:
https://superuser.com/questions/869144/why-does-the-system-have-etc-sudoers-d-how-should-i-edit-it

When does sudo ignore a file in /etc/sudoers?​


If your /etc/sudoers file contains the line:

#includedir /etc/sudoers.d


then sudo will read files in the directory /etc/sudoers.d.


Exceptions are:


  1. Files whose names end in ~
  2. Files whose names contain a . character

This is done (a) for the convenience of package managers and also (b) so that backup files from editors are ignored.
 
Last edited:
I too am having errors. Guess that is what happens when someone is new and has no instructions on how to use something.
 
I too am having errors. Guess that is what happens when someone is new and has no instructions on how to use something.
Not sure if you figured it out by now but I got it working using some of this info and put together a few notes to help out.

the .conf files will be added to the /etc/zabbix/zabbix_agentd.conf

when the conf is updated it the agent needs restarting systemctl restart zabbix-agent.service

the Scripts are to be loaded in /var/lib/zabbix/bin as default location for the conf file. I created the directory since
it didnt exist.
Make the scripts executable.
sudo chmod +x check_pve_sudo check_zfs disco_pve_sudo disco_zfs

for the scripts to work libconfig-simple-perl libjson-perl libfile-which-perl need to be installed I did this from root

zabbix user has to run sudo without password for this to work.

sudo will need to be installed on proxmox if not already there

I had to delete and recreate the zabbix as a real user with a long password, then add to sudo group
using visudo editor to apend the text from sudo.conf to then end.

I couldn't get the service to run on a second install for another Proxmox setup. Turned out I needed to remove zabbix-agent from
host then install again. Then the service would start.

Hopefully this helps out some, been a while since I got it working for my nodes.
 
Hello everyone! Stumbled upon this thread and decided to share a template that I recently started creating for work, based on Zabbix HTTP Agent checks and PVE API.

Requirements: Zabbix 5.4.7, PVE 7.0 (tested on this versions), direct access from zabbix server to PVE via 8006/tcp

At the moment, I have implemented auto-discovery of virtual machines, containers, storages, cluster nodes and quite a few triggers based on the data found.

Do you think you need to add something to this template or change it in general?

The template itself and instructions can be found on my git, as well as in the attached files

Git: https://git.isaev.tech/IsaevTech/zbx-tmplt-pve
 

Attachments

  • zbx-tmplt-pve-master.zip
    10.4 KB · Views: 50
I alway got the problem that I'm only using the latest LTS release and zabbix isn't backwards compatible. So your template can't be used with a zabbix 5.0 LTS and I would need to wait for the 6.0 LTS to run it but then you are probably already releasing that template for 6.1+.

So would be really great if you could release a LTS version too...especially if you don't need any new features.

Monitoring missing updates would be useful too if thats possible using the api. Once I tried a apt template for that but didn't get that working.

And a PBS template would be very useful too.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!