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

Interface perf data #56

Closed
gmounica39 opened this issue Sep 7, 2020 · 13 comments
Closed

Interface perf data #56

gmounica39 opened this issue Sep 7, 2020 · 13 comments
Assignees

Comments

@gmounica39
Copy link

gmounica39 commented Sep 7, 2020

./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]...

@slauger
Copy link
Owner

slauger commented Sep 7, 2020

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.

@gmounica39
Copy link
Author

./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

@slauger
Copy link
Owner

slauger commented Sep 7, 2020

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

@slauger
Copy link
Owner

slauger commented Sep 7, 2020

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.

@slauger
Copy link
Owner

slauger commented Sep 7, 2020

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.

@gmounica39
Copy link
Author

gmounica39 commented Sep 7, 2020

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

slauger added a commit that referenced this issue Sep 8, 2020
@slauger
Copy link
Owner

slauger commented Sep 8, 2020

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;;

@gmounica39
Copy link
Author

Yes, for now this should work.

Thank you!

@gmounica39
Copy link
Author

gmounica39 commented Sep 9, 2020

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

@slauger
Copy link
Owner

slauger commented Sep 10, 2020

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

@slauger
Copy link
Owner

slauger commented Sep 11, 2020

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

@slauger slauger self-assigned this Sep 11, 2020
@gmounica39
Copy link
Author

It did the job, thank you!!

github-actions bot pushed a commit that referenced this issue Sep 18, 2020
## [1.6.1](v1.6.0...v1.6.1) (2020-09-18)

### Bug Fixes

* add --seperator to allow to configure a custom perfdata seperator ([#47](#47)) ([9a9a1b1](9a9a1b1))
* add limit switch ('--limit', '-l') and change spec for label switch from '-l' to '-L' ([f396fbe](f396fbe))
* add release automation via semantic-release-bot ([19bb5d1](19bb5d1))
* add support for limit in more subs ([90b7995](90b7995))
* add the ability to set a custom perfdata label for sub check_keyword and check_threshold_and_get_perfdata ([#56](#56)) ([5c0ef0a](5c0ef0a))
* get host, user and password from environment variables (NETSCALER_HOST, NETSCALER_USERNAME, NETSCALER_PASSWORD) ([4cec658](4cec658))
* replace hardcoded id with $plugin->opts->label ([2c623d3](2c623d3))
@slauger
Copy link
Owner

slauger commented Sep 18, 2020

The new switches are part of Release v1.6.1.

@slauger slauger closed this as completed Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants