diff --git a/README b/README index 747df4a..102be6e 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ NAME - check_pgbackrest - pgBackRest backup check plugin for Nagios + check_pgbackrest - pgBackRest backup check plugin for Nagios and Zabbix (for zabbix integration, see zabbix subfolder) SYNOPSIS check_pgbackrest [-s|--service SERVICE] [-S|--stanza NAME] @@ -8,7 +8,7 @@ SYNOPSIS DESCRIPTION check_pgbackrest is designed to monitor pgBackRest (2.33 and above) - backups from Nagios. + backups from Nagios and Zabbix. -s, --service SERVICE The Nagios service to run. See section SERVICES for a description of diff --git a/README.pod b/README.pod index f7d916d..8a4628a 100644 --- a/README.pod +++ b/README.pod @@ -1,6 +1,6 @@ =head1 NAME -check_pgbackrest - pgBackRest backup check plugin for Nagios +check_pgbackrest - pgBackRest backup check plugin for Nagios and zabbix =head1 SYNOPSIS diff --git a/zabbix/check_pgbackrest_discovery.sh b/zabbix/check_pgbackrest_discovery.sh new file mode 100644 index 0000000..f685a9a --- /dev/null +++ b/zabbix/check_pgbackrest_discovery.sh @@ -0,0 +1,4 @@ +A=`echo '- pgbackrest_stanza { "data" : ['` +B=`pgbackrest info | grep -i stanza: | awk '{print "{ \"{#STANZA}\":\"" $2 "\"},"}'` +C=`echo "}]}"` +echo $A$B$C diff --git a/zabbix/pgbackrest_template.xml b/zabbix/pgbackrest_template.xml new file mode 100644 index 0000000..aa89bfc --- /dev/null +++ b/zabbix/pgbackrest_template.xml @@ -0,0 +1,150 @@ + + + 5.4 + 2021-12-18T16:40:41Z + + + 748ad4d098d447d492bb935c907f652f + Templates/Databases + + + + + + diff --git a/zabbix/zabbix.md b/zabbix/zabbix.md new file mode 100644 index 0000000..3edf7d4 --- /dev/null +++ b/zabbix/zabbix.md @@ -0,0 +1,35 @@ +## Zabbix + +Template is tested with Zabbix 5.4 and Zabbix Agent 5.4 or Zabbix Agent2 + +## Installation +### check_pgbackrest + +Place it in /opt/zabbix/ +change owner of directory and script to zabbix user/group as per your system settings + +### crontab +Place below line into root crontab. It will execute stanza discovery once a day. + +``` +0 0 * * * /bin/bash /opt/zabbix/check_pgbackrest_discovery.sh | zabbix_sender -c /etc/zabbix/zabbix_agent2.conf -i - +``` + +### userparameter +Put to either separate userparameter file or zabbix agent config file. +``` +UserParameter=pgbackrest_check[*],sudo perl /opt/zabbix/check_pgbackrest -s archives -S $1 -O json +``` + +### sudo +Script is executed by zabbix user and it works with pgbackrest which requires root, we need to allow sudo for zabbix agent. + +SECURITY! Below line will work but allow zabbix user to execute any command without password, use on your own risk. ! + +``` +zabbix ALL = (root) NOPASSWD:ALL +``` + +### template +Just import template into Zabbix server and assign to host, for faster results, run discovery manually. +Template name is t_pgbackrest. \ No newline at end of file