help with developping a plugin : how to use threshold with custom perddata

  • 21 November 2022
  • 2 replies

Userlevel 5
Badge +14


I launched myself in the full rebuild of an snmp plugin for huawei dorado (san storage) by using Rest API.

I did this because I added a “lun” mode to the existing snmp plugin, but as it happens, if you have too many luns the snmp is getting lots timeout, the table is huge and when go over 50 lun/snapshot the plugin never give the information back… 

after a bit of digging, I found there is a Restful api, and lot more digging I managed to create my own custom api


I have an issue with the thing I coded, I cannot get critical or warning alerts when I use for example “--critical-usage-prct=50” on the perfdata

here is the plugin, work in progress : centreon-plugins/ at master · christophe-activiumid/centreon-plugins ( (btw, anyone feel free to test it in command line if you have a dorado, it needs a read only account, and work for dorado v6 and v5)

everything work fine, except threshold...

I do need to implement a cache/statefile on this specific lun mode because with the api and more than 50 lun I need to throttle a bit the api call, so I’ll use a statefile with a few minutes of lifetime (because I have 1 check per lun, I don’t like a global check. it works, but graphs and alert are unmanageable imo)


but as I said, all the --critical-* and --warning-* thresholds are not working and I’m having trouble understanding why when I compare to other plugin using these kind of thresholds

when I say they don’t work : I always get “OK”, if I try a --critical-zorglub it says the argument is unkwown, so that’s fine, but when I put the right argument name, it’s not using the value to make an alert, for example

“--critical-usage-prct=50” on a lun capcity used at 60%

(I tried >50 or 50% or >50% in the value, didn’t work better)


if a centreon dev can help me for what I could have missed when creating the mode, that would be great.


best regards,



Best answer by sdepassio 24 November 2022, 12:32

View original

2 replies

Badge +1


You need to remove your "check_options" method from, so it will use the one from the counter template, where the warning and critical thresholds are defined.

Let me know if it fix your issue.


Userlevel 5
Badge +14


yes it works with that. I have done a lot of frankenstein-ism to make this plugin, and a lot is still confusing to understand what calls what. but I know I added this sub here to prepare for the use of the cache file (and didn’t check the threshold before at all… I was focusing on perfdata and status)


I have a problem for removing the sub check_options… for example if you look at the “” file I needed to use :

(line 148)$self->{statefile}->check_options(option_results => $self->{option_results}); 

otherwise the check is not creating the statefile correctly, and it tries to write the cache in “/” so this sub is pretty important



but you gave me an important tip, class inheritance, and overrides which I didn’t thought of (i’m not really used to class in perl), I added a call to the parent class function SUPER::check_options(%options)

sub check_options {
my ($self, %options) = @_;



it also work, on my interface traffic if I add that at the end of my check_options sub.


i’ll finish this plugin in the next few days, a bit swamped with work but thanks for the help