Question

[centreon/centreon-plugins] database::postgres::plugin - Problème avec la mesure "locks"

  • 13 October 2023
  • 7 replies
  • 137 views

Badge +1

Bonjour

J’ai un problème avec “locks”, je ne comprends pas comment fonctionne les seuils. Par exemple :

--warning='waiting=3,exclusive=10' --critical='waiting=5,exclusive=20'

Est-ce que les 2 conditions doivent être réunis pour déclencher un warning ou un critical ? Ou juste une ?

J’ai un exemple où j’ai 13 en exclusive locks sans déclenchement du warning :

 

D’ailleurs je ne comprends pas non plus la différence entre les colonnes <dbname>~<type lock>#database.locks.count et <dbname>_<type lock>, quelle différence ?

Merci d’avance pour votre aide


7 replies

Userlevel 1
Badge +6

Bonjour,

Merci de votre intérêt pour Centreon.

Nous avons lancé une analyse afin de répondre à votre question et, selon le résultat, documenter cette information ou traiter le bug si il y en a un.

Nous vous tiendrons informé.

Userlevel 1
Badge +6

Bonjour,

Pouvez-vous me fournir (sur ce fil ou en MP) l’output du plugin ? 

Il devrait être de la forme 

 

WARNING: Database 'postgres' lock 'exclusive': 2 | 'template1~total#database.locks.count'=0;0:10;;0; 'template1~waiting#database.locks.count'=0;;;0; 'postgres~waiting#database.locks.count'=0;;;0; 'postgres~exclusive#database.locks.count'=2;0:1;;0; 'postgres~total#database.locks.count'=1;0:10;;0; 'postgres~accesssharelock#database.locks.count'=1;;;0;Database 'template1' lock 'total': 0Database 'template1' lock 'waiting': 0Database 'postgres' lock 'waiting': 0Database 'postgres' lock 'exclusive': 2Database 'postgres' lock 'total': 1Database 'postgres' lock 'accesssharelock': 1
Badge +1

Bonjour

Voici l'output actuel :

OK: All databases locks are ok | 'smalarms~waiting#database.locks.count'=0;0:3;0:5;0; 'smalarms~total#database.locks.count'=0;;;0; 'capa~waiting#database.locks.count'=0;0:3;0:5;0; 'capa~total#database.locks.count'=0;;;0; 'sensorjobs~waiting#database.locks.count'=0;0:3;0:5;0; 'sensorjobs~total#database.locks.count'=0;;;0; 'leonardo~waiting#database.locks.count'=0;0:3;0:5;0; 'leonardo~total#database.locks.count'=0;;;0; 'keycloak~waiting#database.locks.count'=0;0:3;0:5;0; 'keycloak~total#database.locks.count'=0;;;0; 'hermod~waiting#database.locks.count'=0;0:3;0:5;0; 'hermod~total#database.locks.count'=0;;;0; 'ikarya~accesssharelock#database.locks.count'=301;;;0; 'ikarya~waiting#database.locks.count'=0;0:3;0:5;0; 'ikarya~total#database.locks.count'=301;;;0; 'l3lanservice~waiting#database.locks.count'=0;0:3;0:5;0; 'l3lanservice~total#database.locks.count'=0;;;0; 'sensorgw~waiting#database.locks.count'=0;0:3;0:5;0; 'sensorgw~total#database.locks.count'=0;;;0; 'mdm~waiting#database.locks.count'=0;0:3;0:5;0; 'mdm~total#database.locks.count'=0;;;0; 'donky~waiting#database.locks.count'=0;0:3;0:5;0; 'donky~total#database.locks.count'=0;;;0; 'sensorgw_old~waiting#database.locks.count'=0;0:3;0:5;0; 'sensorgw_old~total#database.locks.count'=0;;;0;
Database 'smalarms' lock 'waiting': 0
Database 'smalarms' lock 'total': 0
Database 'capa' lock 'waiting': 0
Database 'capa' lock 'total': 0
Database 'sensorjobs' lock 'waiting': 0
Database 'sensorjobs' lock 'total': 0
Database 'leonardo' lock 'waiting': 0
Database 'leonardo' lock 'total': 0
Database 'keycloak' lock 'waiting': 0
Database 'keycloak' lock 'total': 0
Database 'hermod' lock 'waiting': 0
Database 'hermod' lock 'total': 0
Database 'ikarya' lock 'accesssharelock': 301
Database 'ikarya' lock 'waiting': 0
Database 'ikarya' lock 'total': 301
Database 'l3lanservice' lock 'waiting': 0
Database 'l3lanservice' lock 'total': 0
Database 'sensorgw' lock 'waiting': 0
Database 'sensorgw' lock 'total': 0
Database 'mdm' lock 'waiting': 0
Database 'mdm' lock 'total': 0
Database 'donky' lock 'waiting': 0
Database 'donky' lock 'total': 0
Database 'sensorgw_old' lock 'waiting': 0
Database 'sensorgw_old' lock 'total': 0

Le tableau dans mon premier message est un extract de Centreon.

Cordialement

Userlevel 1
Badge +6

Bonjour,

 

Nous avons effectué une batterie de tests sur le plugin.

 

Le comportement est le suivant, et semble conforme : 

  • Récupération du nombre de locks pour chaque base et chaque type de locks (exclusive/waiting/total/accessshare)
  • Comparaison du nombre de ‘total’ et ‘exclusive’ aux seuils définis
  • Si au moins un des counts (il y en a un par base et par type de lock) dépasse le seuil, le statut change.

 

Quelques exemples testés

 

1)

 

Contenu de la base PostgreSQL

 

postgres=*# SELECT granted, mode, datname FROM pg_database d LEFT JOIN pg_locks l ON (d.oid=l.database) where d.datallowconn;
 granted |        mode         |  datname  
---------+---------------------+-----------
 t       | AccessShareLock     | postgres
 t       | AccessExclusiveLock | postgres

 t       | RowExclusiveLock | test_db

 t       | RowExclusiveLock | test_db

 t       | RowExclusiveLock | test_db
         |                                    | template1

 

 

Avec --warning='total=10,exclusive=2'

WARNING: Database 'test_db' lock 'exclusive': 3 | 'template1~waiting#database.locks.count'=0;;;0; 'template1~total#database.locks.count'=0;0:10;;0; 'test_db~exclusive#database.locks.count'=3;0:2;;0; 'postgres~exclusive#database.locks.count'=1;0:2;;0; 'postgres~accesssharelock#database.locks.count'=1;;;0; 'postgres~total#database.locks.count'=2;0:10;;0; 'postgres~waiting#database.locks.count'=0;;;0;Database 'template1' lock 'waiting': 0Database 'template1' lock 'total': 0Database 'test_db' lock 'exclusive': 3Database 'postgres' lock 'exclusive': 1Database 'postgres' lock 'accesssharelock': 1Database 'postgres' lock 'total': 2Database 'postgres' lock 'waiting': 0

 

Le statut est WARNING car au moins une des données de performance (ici test_db~exclusive#database.locks.count) dépasse le seuil “exclusive”.

 

2)

 

Contenu de la base PostgreSQL

 

postgres=*# SELECT granted, mode, datname FROM pg_database d LEFT JOIN pg_locks l ON (d.oid=l.database) where d.datallowconn;
 granted |        mode         |  datname  
---------+---------------------+-----------
 t       | AccessShareLock     | postgres
 t       | AccessExclusiveLock | postgres

 t       | RowExclusiveLock | postgres

 t       | RowExclusiveLock | test_db

 t       | RowExclusiveLock | test_db
         |                                    | template1

 

Avec --warning='total=10,exclusive=5'

OK: All databases locks are ok | 'postgres~total#database.locks.count'=3;0:10;;0; 'postgres~exclusive#database.locks.count'=2;0:5;;0; 'postgres~waiting#database.locks.count'=0;;;0; 'postgres~accesssharelock#database.locks.count'=1;;;0; 'template1~waiting#database.locks.count'=0;;;0; 'template1~total#database.locks.count'=0;0:10;;0; 'test_db~exclusive#database.locks.count'=2;0:5;;0;Database 'postgres' lock 'total': 3Database 'postgres' lock 'exclusive': 2Database 'postgres' lock 'waiting': 0Database 'postgres' lock 'accesssharelock': 1Database 'template1' lock 'waiting': 0Database 'template1' lock 'total': 0Database 'test_db' lock 'exclusive': 2

 

Le statut est OK car aucune des données de performance ne dépasse le seuil “exclusive” ou “total”.

 

Si cela n’est pas conforme à ce que vous observez, pouvez-vous m’envoyer en MP votre email afin que l’on planifie un échange ? 

Merci. 

 

 

Concernant les colonnes en base, nous n’expliquons pas leur présence, sont-elles parfois renseignées avec une valeur <> 0 dans votre base ? récemment ?

cela pourrait provenir d'une ancienne version du plugin. En effet, toutes les données retournées (perfdata) sont de la forme <dbname>~<type>#database.locks.count

 

Restant à votre écoute

Userlevel 5
Badge +11

Bonjour @Mickael.Lechat, est-ce que t’as pu résoudre ton problème avec les solutions proposées ? Fais ton retour à la communauté stp ou choisis le commentaire qui t’a le plus aidé comme “Best Answer”. Ceci aiderait forcément quelqu’un dans les mêmes difficultés. Merci d’avance 

Badge +1

Bonjour

Je suis en cours de test, retour la semaine prochaine.

Bon weekend

Badge +1

Bonjour

Après quelques tests j ai bien un problème.

4 updates bloqués par un 5 cinquième ce qui donne :

postgres=# SELECT granted, mode, datname FROM pg_database d LEFT JOIN pg_locks l ON (d.oid=l.database) where d.datallowconn;
 granted |       mode       |   datname
---------+------------------+--------------
 t       | RowExclusiveLock | postgres
 t       | RowExclusiveLock | postgres
 t       | AccessShareLock  | postgres
 t       | RowExclusiveLock | postgres
 t       | RowExclusiveLock | postgres
 t       | RowExclusiveLock | postgres
 f       | ExclusiveLock    | postgres
 f       | ExclusiveLock    | postgres
 t       | ExclusiveLock    | postgres
 f       | ExclusiveLock    | postgres

 

test avec  --warning='waiting=20,exclusive=3' --critical='waiting=5,exclusive=20'

résultat :

OK: All databases locks are ok | 'postgres~accesssharelock#database.locks.count'=2;;;0; 'postgres~waiting#database.locks.count'=3;0:20;0:5;0; 'postgres~exclusivelock#database.locks.count'=4;;;0; 'postgres~total#database.locks.count'=11;;;0; 'postgres~rowexclusivelock#database.locks.count'=5;;;0;
Database 'postgres' lock 'accesssharelock': 2
Database 'postgres' lock 'waiting': 3
Database 'postgres' lock 'exclusivelock': 4
Database 'postgres' lock 'total': 11
Database 'postgres' lock 'rowexclusivelock': 5

 

exclusive n’a aucun effet, il faut que j’indique le vrai nom du wait (exclusivelock, rowexclusivelock, ...) :

 

--warning='waiting=20,rowexclusivelock=3' --critical='waiting=5,exclusive=20'

WARNING: Database 'postgres' lock 'rowexclusivelock': 5 | 'postgres~accesssharelock#database.locks.count'=2;;;0; 'postgres~waiting#database.locks.count'=3;0:20;0:5;0; 'postgres~exclusivelock#database.locks.count'=4;;;0; 'postgres~total#database.locks.count'=11;;;0; 'postgres~rowexclusivelock#database.locks.count'=5;0:3;;0;
Database 'postgres' lock 'accesssharelock': 2
Database 'postgres' lock 'waiting': 3
Database 'postgres' lock 'exclusivelock': 4
Database 'postgres' lock 'total': 11
Database 'postgres' lock 'rowexclusivelock': 5

 

Cela vient peut être de ma version de plugin ?

Mais du coup sur le votre, exclusive = somme (exclusive%) ? ou max(exclusive%) ? …?

Bonne soirée

Reply