Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I add a new metric? #4996

Open
wp-perc opened this issue Apr 23, 2024 · 3 comments
Open

How can I add a new metric? #4996

wp-perc opened this issue Apr 23, 2024 · 3 comments
Labels

Comments

@wp-perc
Copy link

wp-perc commented Apr 23, 2024

Hello,

I noticed plugin apps::protocols::x509::plugin has no perfdata, while I think having the remaining expiration of a certificate as a metric can be a useful. Therefore, I tried to use --extend-perfdata to add variable expiration as a metric, but I am unable to do so, and I am also unable to find documentation about it. Can you help me in finding a way to add %{expiration} as a perfdata?

For reference, my command line:

/usr/lib/centreon/plugins/centreon_protocol_x509.pl --plugin apps::protocols::x509::plugin --mode certificate --custommode tcp --hostname X.Y.Z.K --port 9200 --warning-status '%{expiration} < 60' --critical-status '%{expiration} < 30 || %{subject} !~ /^EXPECTEDSUBJECT$/'
@lucie-dubrunfaut
Copy link
Contributor

Hello :)

I'm not sure I understand exactly what you mean by converting certificate expiration in a metric? Would you like to apply thresholds etc on it?
About the option --extend-perfdata I only find this help section :

Change or extend perfdata.
Syntax: --extend-perfdata=searchlabel,newlabel,target[,[newuom],[min],[max]]

I'm not sure how this option works or how it is supported, maybe you could show us an example output with this option (and with the --debug option)?

@wp-perc
Copy link
Author

wp-perc commented Jul 19, 2024

Hi, let me rephrase.

I would like to have the remaining certificate's validity days returned as performance data.
It may be silly, but this allows me to make reports and more complex monitoring.

Here the debug output (I removed the check of subjects because it is a test server):

# /usr/lib/centreon/plugins/centreon_protocol_x509.pl --plugin apps::protocols::x509::plugin --mode certificate --custommode tcp --hostname X.Y.Z.K --port 9200 --warning-status '%{expiration} < 60' --critical-status '%{expiration} < 30' --debug
OK: Certificate for 'satellite.test' expires in '3586' days [2034-05-14T08:25:23Z] - Issuer: '/DC=local/DC=*/O=Test/OU=Root CA/CN=*.local'
Alternative subject names: satellite.local, X.Y.Z.K, 127.0.0.1.

I am trying to have the 3586 days in the perfdata. I tried with --extend-perfdata, but since the documentation about perfdata manipulation is lacking I had no luck. Maybe someone that has more insights than me can provide a solution...

@lucie-dubrunfaut
Copy link
Contributor

Hello :)

Okay I understand your need, and based on my understanding I am not sure that the --extend-perfdata option can apply in this case because this mode returns a status and not a metric .
It would be possible to add a second counter which is a metric and which displays the days remaining before the license expires, however this is a request for improvement of the plugin and these are done on TheWatch to be take into account and vote on (you can link this github issue in your idea proposition).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants