slauger/check_netscaler

Interface perf data

gmounica39 opened this issue · 13 comments

./check_netscaler.pl -H hostname -u username -p passwd -s -C perfdata -o Interface -n rxbytesrate
NetScaler OK - perfdata: Interface.rxbytesrate[0]: 0; Interface.rxbytesrate[1]: 0; Interface.rxbytesrate[2]: 0; Interface.rxbytesrate[3]: 0; Interface.rxbytesrate[4]: 7941; Interface.rxbytesrate[5]: 3714; Interface.rxbytesrate[6]: 874196; Interface.rxbytesrate[7]: 4048; Interface.rxbytesrate[8]: 3677; Interface.rxbytesrate[9]: 2312; Interface.rxbytesrate[10]: 943678; Interface.rxbytesrate[11]: 7889; Interface.rxbytesrate[12]: 6122; Interface.rxbytesrate[13]: 0; Interface.rxbytesrate[14]: 104078; Interface.rxbytesrate[15]: 11635; Interface.rxbytesrate[16]: 6042; Interface.rxbytesrate[17]: 1817614; Interface.rxbytesrate[18]: 12097 | 'Interface.rxbytesrate[0]'=0;; 'Interface.rxbytesrate[1]'=0;; 'Interface.rxbytesrate[2]'=0;; 'Interface.rxbytesrate[3]'=0;; 'Interface.rxbytesrate[4]'=7941;; 'Interface.rxbytesrate[5]'=3714;; 'Interface.rxbytesrate[6]'=874196;; 'Interface.rxbytesrate[7]'=4048;; 'Interface.rxbytesrate[8]'=3677;; 'Interface.rxbytesrate[9]'=2312;; 'Interface.rxbytesrate[10]'=943678;; 'Interface.rxbytesrate[11]'=7889;; 'Interface.rxbytesrate[12]'=6122;; 'Interface.rxbytesrate[13]'=0;; 'Interface.rxbytesrate[14]'=104078;; 'Interface.rxbytesrate[15]'=11635;; 'Interface.rxbytesrate[16]'=6042;; 'Interface.rxbytesrate[17]'=1817614;; 'Interface.rxbytesrate[18]'=12097;;

It is giving rxbytesrate for all the interfaces.
Is there a way to get the metric for particular interface instead of all interfaces
or atleast the "id" value(i.e, the name of the interface) instead of [1],[2]...

Hi @gjarm93,

the command interface does already support the filter switch. See https://github.com/slauger/check_netscaler/blob/master/check_netscaler.pl#L829.

I haven't tested it, but it should be possible to filter the check to a single interface via -f '0/1'. The -f also supports regular expressions, you can expand the check to multiple interfaces (e.g. -f '0.[1-3]').

Please let me know if this fits your needs.

./check_netscaler.pl -H hostname -u user -p pwd -s -C perfdata -o Interface -n rxbytesrate -f '0/1/1'
NetScaler OK - perfdata: Interface.rxbytesrate[0]: 0; Interface.rxbytesrate[1]: 0; Interface.rxbytesrate[2]: 0; Interface.rxbytesrate[3]: 0; Interface.rxbytesrate[4]: 48430; Interface.rxbytesrate[5]: 3060; Interface.rxbytesrate[6]: 958333; Interface.rxbytesrate[7]: 3676; Interface.rxbytesrate[8]: 4449; Interface.rxbytesrate[9]: 1084; Interface.rxbytesrate[10]: 971690; Interface.rxbytesrate[11]: 8099; Interface.rxbytesrate[12]: 5305; Interface.rxbytesrate[13]: 0; Interface.rxbytesrate[14]: 149750; Interface.rxbytesrate[15]: 52753; Interface.rxbytesrate[16]: 4224; Interface.rxbytesrate[17]: 1930708; Interface.rxbytesrate[18]: 11658 | 'Interface.rxbytesrate[0]'=0;; 'Interface.rxbytesrate[1]'=0;; 'Interface.rxbytesrate[2]'=0;; 'Interface.rxbytesrate[3]'=0;; 'Interface.rxbytesrate[4]'=48430;; 'Interface.rxbytesrate[5]'=3060;; 'Interface.rxbytesrate[6]'=958333;; 'Interface.rxbytesrate[7]'=3676;; 'Interface.rxbytesrate[8]'=4449;; 'Interface.rxbytesrate[9]'=1084;; 'Interface.rxbytesrate[10]'=971690;; 'Interface.rxbytesrate[11]'=8099;; 'Interface.rxbytesrate[12]'=5305;; 'Interface.rxbytesrate[13]'=0;; 'Interface.rxbytesrate[14]'=149750;; 'Interface.rxbytesrate[15]'=52753;; 'Interface.rxbytesrate[16]'=4224;; 'Interface.rxbytesrate[17]'=1930708;; 'Interface.rxbytesrate[18]'=11658;;

It still gives all the interfaces even when filter is provided

Ok, this isn't supposed to happen. Let me check this.

Sorry, i was a bit wrong. The filter switch filters out an interface from your result, just as the name suggests. It should be possible to add a inverse filter via perl regular expression (like (?:(?!0\/1).)*), but i couldn't find a working solution right now.

So a quick and very dirty solution would be to filter out all unwanted interfaces:

./check_netscaler.pl -H 10.0.0.240 -p nsroot -C interfaces -f '(LO.1|0.1|0.2|0.3)'

This may or may not solve your initial problem.

Filtering is currently not supported for the perfdata command. This is because the sub check_threshold_and_get_perfdata is very generic. We do not know which field contain the item field.

It seems like that it's also possible to filter the API response to a single interface.

http://<netscaler-ip-address>/nitro/v1/config/Interface/id_value<String>

But this will require some changes in the plugin code - and also this would be only an option for the Interfaces command.

I would need perfdata since I'm looking for rxbytesrate to get current value instead of total(counter). Looks like /nitro/v1/config/Interface doesn't have a rate

Have a look at 5c0ef0a. The commit adds a new --label switch. Does this fix your problem? Currently i do not have a better idea.

Example usage:

# default
-bash$ ./check_netscaler.pl -H 10.0.0.240 -p secure -s -C perfdata -o Interface -n rxbytesrate
NetScaler OK - perfdata: Interface.rxbytesrate[0]: 1711; Interface.rxbytesrate[1]: 13915 | 'Interface.rxbytesrate[0]'=1711;; 'Interface.rxbytesrate[1]'=13915;;

# with the new -f switch set to 'id'
-bash$ ./check_netscaler.pl -H 10.0.0.240 -p secure -s -C perfdata -o Interface -n rxbytesrate -l id
NetScaler OK - perfdata: Interface.rxbytesrate[0/1]: 1575; Interface.rxbytesrate[LO/1]: 12130 | 'Interface.rxbytesrate[0/1]'=1575;; 'Interface.rxbytesrate[LO/1]'=12130;;

Yes, for now this should work.

Thank you!

And are there any plans for future to again filter to get single interface?

Since we now have a label for filtering, adding support for the -f shouldn't be a problem. I'll take care of it.

I renamed the label switch from -l to -L to make room for a new "limit" switch. The limit switch (-l) can be used to limit the current check to specific objects, just like you wanted. It can be combined with the label option (-L) and the existing filter option (-f).

Examples:

# limit to LO/1
./check_netscaler.pl -H 10.0.0.240 -p secure -s -C perfdata -o Interface -n rxbytesrate -L id -l 'LO.1' 

# limit to 0/[0-9] and filter out 0/2
./check_netscaler.pl -H 10.0.0.240 -p secure -s -C perfdata -o Interface -n rxbytesrate -L id -l '0.[0-9]' -f '0.2'

TODOs:

  • Waiting for feedback from @gjarm93
  • Update our existing docs and add some examples
  • Add additional tests for this new switches

It did the job, thank you!!

The new switches are part of Release v1.6.1.