Skip to content

Conversation

@cedr-x
Copy link

@cedr-x cedr-x commented Dec 1, 2025

offset with a negative "-1 second" output cause a critical status of the plugin. Offsets should be positive integers

Community contributors

Description

Sometimes, centreon_linux_snmp.pl --plugin=os::linux::snmp::plugin --mode=time trigger critical status when the checked host is just a second behind the ref_time

sudo -u centreon-engine /usr/lib/centreon/plugins//centreon_linux_snmp.pl --plugin=os::linux::snmp::plugin --mode=time --hostname=192.168.1.118 --snmp-version=2c --snmp-community=****** --warning-offset=120 --critical-offset=300 
CRITICAL: Time offset -1 second(s): Local Time : 2025-12-01T09:42:30 (Europe/Paris) | 'offset'=-1s;0:120;0:300;;

Type of change

  • Patch fixing an issue (non-breaking change)

How this pull request can be tested ?

Check against an host which have it clock set near 1s behing ntp ref time
The unpatched check is tossed be criticals when it retrives exactly "-1" (second) as offset
This patched check, returning in that case "1" stay with status OK

tested with:

sudo -u centreon-engine /usr/lib/centreon/plugins//centreon_linux_snmp.pl --plugin=os::linux::snmp::plugin --mode=time --hostname=192.168.1.118 --snmp-version=2c --snmp-community=****** --warning-offset=120 --critical-offset=300 
OK: Time offset 1 second(s): Local Time : 2025-12-01T09:51:12 (+0100) | 'offset'=1s;0:120;0:300;;

Checklist

  • I have followed the coding style guidelines provided by Centreon
  • I have commented my code, especially hard-to-understand areas of the PR.
  • I have rebased my development branch on the base branch (develop).
  • I have provide data or shown output displaying the result of this code in the plugin area concerned.

offset with a negative "-1 second" offset causes a critical status

Offsets should be positive integers
@cedr-x cedr-x requested a review from a team as a code owner December 1, 2025 09:30
@cedr-x cedr-x requested a review from sdepassio December 1, 2025 09:30
@omercier
Copy link
Contributor

omercier commented Dec 1, 2025

Hi @cedr-x,
Thanks for your contribution, but I think losing the minus signs would mean that you don't know if your host is ahead or late compared to the reference time.

Here's what I suggest:

  • Use Nagios ranges: setting the thresholds this way --warning-offset=-120:120 will return a warning status only when the value is outside the interval [-120:120]. More information here. You can use this option without changing the code.
  • Smart guessing the user's intentions: instead of transforming the threshold into its absolute value, suppose that if the threshold value is a positive integer, then the user probably meant "I want the offset's absolute value to be less than x", and silently change the threshold from n to -n:n.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants