bucardo / check_postgres

Nagios check_postgres plugin for checking status of PostgreSQL databases
http://bucardo.org/wiki/Check_postgres
Other
562 stars 175 forks source link

Add performance data for dbstats action #201

Open Napsty opened 1 year ago

Napsty commented 1 year ago

This PR adds performance data for the dbstats action (something I personally was missing for years).

The performance data was tested with all databases:

$ ./check_postgres.pl --action dbstats --dbpass secret -H 127.0.0.1 -u monitoring 
Stats for DB postgres: backends:1 commits:1194355 rollbacks:17 read:5292 hit:97661742 idxscan:0 idxtupread:0 idxtupfetch:0 idxblksread:0 idxblkshit:0 seqscan:0 seqtupread:0 ret:336331475 fetch:49270807 ins:7 upd:91 del:0  --- Stats for DB template1: backends:0 commits:771428 rollbacks:0 read:5283 hit:28421374 idxscan:0 idxtupread:0 idxtupfetch:0 idxblksread:0 idxblkshit:0 seqscan:0 seqtupread:0 ret:337132649 fetch:5520600 ins:17501 upd:855 del:34  --- Stats for DB template0: backends:0 commits:0 rollbacks:0 read:0 hit:0 idxscan:0 idxtupread:0 idxtupfetch:0 idxblksread:0 idxblkshit:0 seqscan:0 seqtupread:0 ret:0 fetch:0 ins:0 upd:0 del:0  --- Stats for DB puppetdb: backends:50 commits:393537778 rollbacks:5075910 read:24493024 hit:186684485479 idxscan:0 idxtupread:0 idxtupfetch:0 idxblksread:0 idxblkshit:0 seqscan:0 seqtupread:0 ret:580282485959 fetch:110262795010 ins:38275879 upd:9855953 del:10146181  --- |postgres_backends=1;;;; postgres_commits=1194355;;;; postgres_rollbacks=17;;;; postgres_read=5292;;;; postgres_hit=97661742;;;; postgres_idxscan=0;;;; postgres_idxtupread=0;;;; postgres_idxtupfetch=0;;;; postgres_idxblksread=0;;;; postgres_idxblkshit=0;;;; postgres_seqscan=0;;;; postgres_seqtupread=0;;;; postgres_ret=336331475;;;; postgres_fetch=49270807;;;; postgres_ins=7;;;; postgres_upd=91;;;; postgres_del=0;;;; template1_backends=0;;;; template1_commits=771428;;;; template1_rollbacks=0;;;; template1_read=5283;;;; template1_hit=28421374;;;; template1_idxscan=0;;;; template1_idxtupread=0;;;; template1_idxtupfetch=0;;;; template1_idxblksread=0;;;; template1_idxblkshit=0;;;; template1_seqscan=0;;;; template1_seqtupread=0;;;; template1_ret=337132649;;;; template1_fetch=5520600;;;; template1_ins=17501;;;; template1_upd=855;;;; template1_del=34;;;; template0_backends=0;;;; template0_commits=0;;;; template0_rollbacks=0;;;; template0_read=0;;;; template0_hit=0;;;; template0_idxscan=0;;;; template0_idxtupread=0;;;; template0_idxtupfetch=0;;;; template0_idxblksread=0;;;; template0_idxblkshit=0;;;; template0_seqscan=0;;;; template0_seqtupread=0;;;; template0_ret=0;;;; template0_fetch=0;;;; template0_ins=0;;;; template0_upd=0;;;; template0_del=0;;;; puppetdb_backends=50;;;; puppetdb_commits=393537778;;;; puppetdb_rollbacks=5075910;;;; puppetdb_read=24493024;;;; puppetdb_hit=186684485479;;;; puppetdb_idxscan=0;;;; puppetdb_idxtupread=0;;;; puppetdb_idxtupfetch=0;;;; puppetdb_idxblksread=0;;;; puppetdb_idxblkshit=0;;;; puppetdb_seqscan=0;;;; puppetdb_seqtupread=0;;;; puppetdb_ret=580282485959;;;; puppetdb_fetch=110262795010;;;; puppetdb_ins=38275879;;;; puppetdb_upd=9855953;;;; puppetdb_del=10146181;;;; 

And also with a single database (here using --include):

$ ./check_postgres.pl --action dbstats --dbpass secret -H 127.0.0.1 -u monitoring  --include puppetdb
Stats for DB puppetdb: backends:50 commits:393538013 rollbacks:5075910 read:24493024 hit:186684738036 idxscan:0 idxtupread:0 idxtupfetch:0 idxblksread:0 idxblkshit:0 seqscan:0 seqtupread:0 ret:580282723797 fetch:110262996641 ins:38275898 upd:9855968 del:10146199  --- |puppetdb_backends=50;;;; puppetdb_commits=393538013;;;; puppetdb_rollbacks=5075910;;;; puppetdb_read=24493024;;;; puppetdb_hit=186684738036;;;; puppetdb_idxscan=0;;;; puppetdb_idxtupread=0;;;; puppetdb_idxtupfetch=0;;;; puppetdb_idxblksread=0;;;; puppetdb_idxblkshit=0;;;; puppetdb_seqscan=0;;;; puppetdb_seqtupread=0;;;; puppetdb_ret=580282723797;;;; puppetdb_fetch=110262996641;;;; puppetdb_ins=38275898;;;; puppetdb_upd=9855968;;;; puppetdb_del=10146199;;;; 

As you can see, the performance data entries contain the database name as well as the statistic key. The performance data is quite simplified, there are no min/max or threshold values.