Skip to main content

Hello,

I’m trying to monitor PosgreSQL autovacuums per 1 or 5 minutes to get a graph, without alerting (without thresholds).

I already have the request to get a number (from DB start I guess) with “--mode=sql” :

```

/usr/lib/centreon/plugins/centreon_postgresql.pl --plugin=database::postgres::plugin --mode=sql --host=HOSTNAME --username='monitoring' --password='secret' --port='5432' --database='dbname' --sql-statement="SELECT SUM(autovacuum_count) AS total_autovacuum FROM pg_stat_all_tables"

OK: SQL statement result : 113703. | 'value'=113703;;;; 'sqlrequest.execution.time.seconds'=0.008s;;;0;

```

Or with “--mode=collection” too with a custom JSON file. I know this mode have a retention mode in statefile but I don’t know how to use it to get previous value to subtract it to current value to have a ratio from last check.

 

How can I do that? Maybe I don’t use the right check and a better way exists?

Hi,

Personally, I check two things :

1°) the activation of the autovacuum:


2°) the last execution of a vacuum:

 

 

With this way I don't get the number of autovacuums but their frequencies :

 

To answer your question, a simple way to subtract the last check value from the current value could be to write a Postgresql function. Each time the plugin calls it, it would store the last value in the database.

 

Regards


Reply