slauger/check_netscaler

Partition support

henriknoerr opened this issue · 10 comments

Hey,

Do you plan on implementing partition support? We use this heavily in our company.
That would make this excellent tool even better :)

Best regards,
Henrik

There seems to be a difference in the output when polling partitions:

eg:
/home/hno0/check_netscaler.pl -t 1 -C perfdata -u nsroot -p password -s -H -v -o nspartition/PartitionName -n memoryusagepcnt
debug: target url is https://IPAddress/nitro/v1/stat/nspartition/PartitionName
$VAR1 = '{ "errorcode": 0, "message": "Done", "severity": "NONE", "nspartition": [ { "partitionname": "PartitionName", "minbandwidth": "2048000", "maxbandwidth": "2048000", "maxconnection": "200000", "maxmemory": "512", "currentbandwidth": "201752", "currentconnections": "68761", "memoryusagepcnt": "3", "totaldrops": "0", "dropsrate": 0, "totaltokendrops": "0", "tokendropsrate": 0, "totalconnectiondrops": "0", "connectiondropsrate": 0 } ] }';
NetScaler UNKNOWN - perfdata: unable to parse data. Returned data is not a HASH or ARRAY!

notice the brackets [ ] that are not present when polling default partition

Hi Henrik,

to be honest, i never used the partition feature before, but indeed support for it is a good idea. Currently i have a bit spare time, so i will look what changes in the code are to support partitions and get back to you.

Cheers, Simon

I see the same is relevant for nsmemory eg. https:///nitro/v1/stat/nsmemory
so in general array support in the json output

/Later

The subs check_threshold_and_get_perfdata and check_keyword should now support your partition setup. Could you test this please and give us some feedback?

Do you know how it's possible to access other stuff in partitions (like server objects and vservers) in the API? I couldn't find any information about this in the docs.

Seems like the only way is using http://<netscaler-ip-address>/nitro/v1/config/nspartition?action=Switch, but this requires an auth session via NITRO_AUTH_TOKEN. I removed the authentication token method some time ago to reduce the amount of API requests.

See also https://developer-docs.citrix.com/projects/netscaler-nitro-api/en/12.0/configuration/ns/nspartition/nspartition/#switch

Hey,

Fast work... It does work now when querying a partition directly, like:
root@hostname:/home/user# /home/user/check_netscaler.pl -t 1 -C perfdata -u nsroot -p nsroot -s -H ipofvpx -v -o nspartition/specificpartitionname -n memoryusagepcnt
debug: target url is https://ipofvpx/nitro/v1/stat/nspartition/specificpartitionname
debug: response of request is:
$VAR1 = '{ "errorcode": 0, "message": "Done", "severity": "NONE", "nspartition": [ { "partitionname": "specificpartitionname", "minbandwidth": "1024000", "maxbandwidth": "1024000", "maxconnection": "100000", "maxmemory": "256", "currentbandwidth": "8312", "currentconnections": "3646", "memoryusagepcnt": "11", "totaldrops": "0", "dropsrate": 0, "totaltokendrops": "0", "tokendropsrate": 0, "totalconnectiondrops": "0", "connectiondropsrate": 0 } ] }';
debug: decoded response of request is:
$VAR1 = {
'errorcode' => 0,
'nspartition' => [
{
'totaldrops' => '0',
'connectiondropsrate' => 0,
'totalconnectiondrops' => '0',
'dropsrate' => 0,
'currentconnections' => '3646',
'tokendropsrate' => 0,
'partitionname' => 'specificpartitionname',
'maxconnection' => '100000',
'currentbandwidth' => '8312',
'minbandwidth' => '1024000',
'totaltokendrops' => '0',
'maxmemory' => '256',
'memoryusagepcnt' => '11',
'maxbandwidth' => '1024000'
}
],
'severity' => 'NONE',
'message' => 'Done'
};
NetScaler OK - perfdata: nspartition/specificpartitionname .memoryusagepcnt: 11 | 'nspartition/specificpartitionname .memoryusagepcnt'=11;;

This is great, but I would also like to just query nspartition without /
Useful, when partitions are created without your knowledge :)

This gives a list of nspartitions and some usefull data like memory usage %

In the development version I still get:
NetScaler UNKNOWN - perfdata: return data is an array and contains multiple objects. You need te seperate id and name with a ".".

I do not see a great solution when polling for partition vserver health. As you mention the API wants a switch post which complicated everything. I know of no solution to circumvent it.

This is great, but I would also like to just query nspartition without /
This gives a list of nspartitions and some usefull data like memory usage %

In the development version I still get:
NetScaler UNKNOWN - perfdata: return data is an array and contains multiple objects. You need te seperate id and name with a ".".

Seems like we also need a special treatment for those arrays with a single element/hash. Fix incoming. 😜

# check_threshold_and_get_perfdata with nspartition
-bash$ ./check_netscaler.pl -H 10.0.0.240 -s -C above -o nspartition -n memoryusagepcnt -w 30 -c 40
NetScaler WARNING - above: nspartition.memoryusagepcnt[0] is above threshold (current: 37, warning: 30); nspartition.memoryusagepcnt[1] is above threshold (current: 37, warning: 30) | 'nspartition.memoryusagepcnt[0]'=37;30;40 'nspartition.memoryusagepcnt[1]'=37;30;40

# check_threshold_and_get_perfdata with nspartition and specific partition
-bash$ ./check_netscaler.pl -H 10.0.0.240 -s -C above -o nspartition/test-partition -n memoryusagepcnt -w 20 -c 30
NetScaler CRITICAL - above: nspartition/test-partition.memoryusagepcnt is above threshold (current: 37, critical: 30) | 'nspartition/test-partition.memoryusagepcnt'=37;20;30

# check_keyword with nspartition
-bash$ ./check_netscaler.pl -H 10.0.0.240 -s -C matches -o nspartition -n partitionname -w test2 -c test-partition
NetScaler CRITICAL - keyword matches: nspartition.partitionname[0]: "test-partition" matches keyword "test-partition"; nspartition.partitionname[1]: "test2" matches keyword "test2"

# check_keyword with nspartition and specific partition
-bash$ ./check_netscaler.pl -H 10.0.0.240 -s -C matches -o nspartition/test-partition -n partitionname -w test2 -c test-partition
NetScaler CRITICAL - keyword matches: nspartition/test-partition.partitionname: "test-partition" matches keyword "test-partition";

Error handling is not yet implemented (e.g. if a field in the response hash is missing) and tests still have to be added to the CI pipeline.

Tests added, changes merged into master.