Monday, June 10, 2013

Nagios to Check Postgresql Least Vacuum Time

0 comments
Nagios is one of the finest tools to monitor system. We use it in our environment to monitor all our systems like databases, application servers, services etc. check_postgres is one of the tools to monitor different aspect of Postgresql database service. It has a function named check_postrges_last_vacuum which works well to get notified if there is any critical distance between last vacuum date of a table of a database.
But our requirement was a bit different. We configured manual vacuum each night during backup and need a method which would notify us the least vacuum date for a table in any database in a server where we were not able to give any specific database name. The reason was such that if for some reason vacuum failed for one database we should be notified.
So we created a nagios plugin named check_postgres_least_vacuum and now its working fine.
The script is available at:
https://www.dropbox.com/sh/gw44f3c1tjm4k96/40gU8bgZsh/check_postgres_least_vacuum.sh


Then we defined  command in command.cfg:
define command{
       command_name  check-postgres-least-vacuum
       command_line  $USER1$/check_postgres_least_vacuum -H $HOSTADDRESS$ -P $ARG1$ -U $ARG2$ -D $ARG3$ -x $ARG4$ -w $ARG5$ -c $ARG6$
       }

Then we defined service in dbserver.cfg:

define service{
        use                             generic-service
        host_name                       DBSERVER1
        service_description             Check Postgresql DB Server Least Vacuum time
        check_command                   check-postgres-least-vacuum!5432!postgres!postgres!D!2!3
        contact_groups                  admins,dev-admins
        check_period                    non-workhours
        }






Leave a Reply

Labels