Question

centreon_linux_snmp disk-usage message changes while in warning/critical alarm

  • 22 June 2023
  • 2 replies
  • 411 views

Badge +1

Hi,

I’m trying to use the Centreon Linux SNMP script “centreon_linux_snmp.pl” to monitor disk usage.

I was able to configure all the parameters I needed but I’m seeing a strange behavior after I configure a “warning-usage-prct” or “critical-usage-prct”.

For some reason, the output message changes depending if the disk utilization has triggered the warning/critical.

Normal output:
/usr/lib/centreon/plugins/centreon_linux_snmp.pl --plugin=os::linux::snmp::plugin --mode=disk-usage --hostname=192.168.100.42 --snmp-version='3' --snmp-username='snmpuser' --authprotocol='MD5' --authpassphrase='cent1610!' --filter-disk-path='/$' --warning-usage-prct=80
OK: Partition '/' usage total: 23.63 GB used: 17.95 GB (75.94%) free: 5.69 GB (24.06%), Inodes used: 4 % | 'count'=2;;;0; 'used'=19271544832B;;;0;25377501184 'free'=6105956352B;;;0;25377501184 'used_prct'=75.94%;0:80;;0;100 'inodes'=4%;;;0;100
 

Output when warning/critical is triggered:
/usr/lib/centreon/plugins/centreon_linux_snmp.pl --plugin=os::linux::snmp::plugin --mode=disk-usage --hostname=192.168.100.42 --snmp-version='3' --snmp-username='snmpuser' --authprotocol='MD5' --authpassphrase='cent1610!' --filter-disk-path='/$' --warning-usage-prct=70
WARNING: Partition '/' used: 75.94 % | 'count'=2;;;0; 'used'=19271544832B;;;0;25377501184 'free'=6105956352B;;;0;25377501184 'used_prct'=75.94%;0:70;;0;100 'inodes'=4%;;;0;100
 

Checking the XML output I noticed that when it’s in warning/critical, there are 2 messages for some reason.

/usr/lib/centreon/plugins/centreon_linux_snmp.pl --plugin=os::linux::snmp::plugin --mode=disk-usage --hostname=192.168.100.42 --snmp-version='3' --snmp-username='snmpuser' --authprotocol='MD5' --authpassphrase='cent1610!' --filter-disk-path='/$' --warning-usage-prct=70 --output-xml
<?xml version="1.0" encoding="utf-8"?>
<plugin>
  <name>os::linux::snmp::plugin</name>
  <mode>disk-usage</mode>
  <exit>WARNING</exit>
  <outputs>
    <output>
      <type>1</type>
      <exit>WARNING</exit>
      <msg>WARNING: Partition '/' used: 75.93 %</msg>
    </output>
    <output>
      <type>1</type>
      <exit>OK</exit>
      <msg>OK: Partition '/' usage total: 23.63 GB used: 17.95 GB (75.93%) free: 5.69 GB (24.07%), Inodes used: 4 %</msg>
    </output>
  </outputs>
  <perfdatas>
    <perfdata>
      <critical/>
      <max/>
      <value>2</value>
      <warning/>
      <min>0</min>
      <mode>disk-usage</mode>
      <unit/>
      <label>count</label>
      <nlabel>storage.partitions.count</nlabel>
    </perfdata>
    <perfdata>
      <nlabel>storage.space.usage.bytes</nlabel>
      <label>used</label>
      <unit>B</unit>
      <mode>disk-usage</mode>
      <min>0</min>
      <warning/>
      <value>19270103040</value>
      <max>25377501184</max>
      <critical/>
    </perfdata>
    <perfdata>
      <label>free</label>
      <unit>B</unit>
      <nlabel>storage.space.free.bytes</nlabel>
      <min>0</min>
      <mode>disk-usage</mode>
      <critical/>
      <warning/>
      <value>6107398144</value>
      <max>25377501184</max>
    </perfdata>
    <perfdata>
      <mode>disk-usage</mode>
      <min>0</min>
      <max>100</max>
      <warning>0:70</warning>
      <value>75.93</value>
      <critical/>
      <nlabel>storage.space.usage.percentage</nlabel>
      <unit>%</unit>
      <label>used_prct</label>
    </perfdata>
    <perfdata>
      <nlabel>storage.inodes.usage.percentage</nlabel>
      <unit>%</unit>
      <label>inodes</label>
      <mode>disk-usage</mode>
      <min>0</min>
      <max>100</max>
      <warning/>
      <value>4</value>
      <critical/>
    </perfdata>
  </perfdatas>
</plugin>
 

 

Is this normal / expected behavior ?

I would really prefer if the message information didn’t change and remain like the first one

Partition '/' usage total: 23.63 GB used: 17.95 GB (75.93%) free: 5.69 GB (24.07%), Inodes used: 4 %

 

From what I can see this behavior only happens when using the “warning-usage-prct” or “critical-usage-prct”, the other variants of the warning/critical don’t have this behavior.


2 replies

Userlevel 5
Badge +14

hello

this is “by design”, apparently (i’m currently trying to understand this thing exactly to make my own plugin)

what is happening is you got a status with the “default it’s ok output” then you get a threshold trigger with whatever metric has been setup in the check (--warning-* and --critical-* can be bytes, percent, usage, free, anything can go here)

then you get a specific output in the short message only with the triggered alarms

 

as far as I understand the mechanic, except rewriting the check itself you will be stuck with this behaviour, I may be wrong and there is a magic --option bypass that, 

 

have you also try to add --verbose on your command, i think it may give you the output you want

 

(I’d rather have the warning/crit value in the text on screen when a threshold is triggered than the old way when you didn’t know which threshold was in error and you had multiple threshold, and don’t know what is warning or critical, it doesn’t change the perfdata in database, and the eventlog is correctly filled in)

Badge +1

Hi @christophe.niel-ACT,

I tried verbose, and in the CLI it does show both messages, however in Centreon in “Monitoring → Resources Status” I only see the one I don’t want 😅

Normal / no alarm:

 

Warning alarm:

 

In my opinion the first message is a lot more helpful, I can see everything I want.
Only having the percentage of used space doesn’t help much, it’s good information but it lacks context.
Having 80% of a 1GB drive a a lot more concerning than 80% on a 1TB drive.

 

I am trying to move away from custom plugins and scripts and trying to use the official ones provided by Centreon, but maybe that’s not possible

Reply