Zabbix template

curly882

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

oguz

Proxmox Staff Member
Staff member
Nov 19, 2018
2,833
316
88
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
 

danielb

Active Member
Jun 1, 2018
167
40
33
34
Bordeaux (france)
www.firewall-services.com
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
 

josifbg

New Member
Nov 21, 2020
5
0
1
45
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?
 

danielb

Active Member
Jun 1, 2018
167
40
33
34
Bordeaux (france)
www.firewall-services.com
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
 

josifbg

New Member
Nov 21, 2020
5
0
1
45
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?
 

josifbg

New Member
Nov 21, 2020
5
0
1
45
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:

danielb

Active Member
Jun 1, 2018
167
40
33
34
Bordeaux (france)
www.firewall-services.com
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)
 

josifbg

New Member
Nov 21, 2020
5
0
1
45
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.
 

danielb

Active Member
Jun 1, 2018
167
40
33
34
Bordeaux (france)
www.firewall-services.com
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
 

josifbg

New Member
Nov 21, 2020
5
0
1
45
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
 

Mykey0815

New Member
Nov 27, 2020
2
0
1
51
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:

danielb

Active Member
Jun 1, 2018
167
40
33
34
Bordeaux (france)
www.firewall-services.com
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
 

Mykey0815

New Member
Nov 27, 2020
2
0
1
51
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:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE 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 your own in 60 seconds.

Buy now!