Read time: 5 minutes
Repository Link: GitHub
Proxmox Nagios Helper
This repository contains a helper Python script for Nagios. The script can be used independently of Nagios, but it’s primary purpose is to run a series of basic checks against a Proxmox host.
Usage
It’s required to setup an API token using the instructions listed below.
The script can be used independently but Nagios config files have been provided in the Nagios folder. There is a dedicated README explaining how this script can be used effectively with a Nagios deployment.
Check CPU threshold of all Proxmox nodes:
python3 base.py --ip=<HOSTADDRESS> --auth_file=<auth_file> --threshold=80 --check_type=cpu_threshold
Check CPU threshold of VM’s within Proxmox
python3 base.py --ip=<HOSTADDRESS> --auth_file=<auth_file> --threshold=80 --check_type=vm_cpu
Check RAM threshold of all Proxmox nodes:
python3 base.py --ip=<HOSTADDRESS> --auth_file=<auth_file> --threshold=80 --check_type=mem_threshold
Check disk usage for the root file system of all Proxmox nodes
python3 base.py --ip=<HOSTADDRESS> --auth_file=<auth_file> --threshold=85 --check_type=rootfs_threshold
Check VM’s are in a running state
Note: multiple VM names can be ignored by comma separating a value in the --ignore_names argument
python3 base.py --ip=<HOSTADDRESS> --auth_file=<auth_file> --check_type=vm_running --ignore_names=vm01,vm02
Setup
Create an API token
Create a dedicated user
Within the DataCenter view of the Proxmox UI, select ‘Users’
Select ‘Add’
Enter api as the username using Linux PAM standard authentication
Create an API token
Within the DataCenter view of the Proxmox UI, select ‘Api Tokens’ under ‘Permissions’
Select the ‘Add’ option
In the user dropdown, select the created user
Create a token ID of your choice. A value like pythonAccess suffices.
Make note of the secret because it will only be shown once
Create a token file for the script
Create a json file using the token information. It should look like:
{
"TokenId": "api@pam!pythonAccess",
"Secret": "<insert_secret_value>"
}
Assign permissions
Within the DataCenter view of the Proxmox UI, select ‘Permissions’
Select ‘Add’
For the path, select the root (/)
Select the API token previously created
For the role, select PVEAuditor
Ensure the Propagate option is selected and then select ‘Add’