Skip to content

Commit

Permalink
fix: add the ability to set a custom perfdata label for sub check_key…
Browse files Browse the repository at this point in the history
…word and check_threshold_and_get_perfdata (#56)
  • Loading branch information
slauger committed Sep 8, 2020
1 parent 6494a57 commit 5c0ef0a
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions check_netscaler.pl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@
usage => '-f, --filter=STRING',
desc => 'filter out objects from the API response (regular expression syntax)',
required => 0,
},
{
spec => 'label|l=s',
usage => '-l, --label=STRING',
desc => 'optional name of the field, which will be used as identifier when the response contians multiple items (default is to use the array index instead)',
required => 0,
}
);

Expand Down Expand Up @@ -519,8 +525,17 @@ sub check_keyword {

$description = $params{'objecttype'} . '.' . $response->{$objectname_id} . '.' . $objectname;
} else {
$objectname = $origin_objectname;
$description = $params{'objecttype'} . '.' . $origin_objectname . '[' . $response_id . ']';
$objectname = $origin_objectname;

# use a custom label from a field in the response as perfdata label (see #56)
my $label;

if ( $plugin->opts->label ) {
$label = $response->{'id'};
} else {
$label = $response_id;
}
$description = $params{'objecttype'} . '.' . $origin_objectname . '[' . $label . ']';
}

if ( not defined( $response->{$objectname} ) ) {
Expand Down Expand Up @@ -744,8 +759,17 @@ sub check_threshold_and_get_perfdata {

$description = $params{'objecttype'} . '.' . $response->{$objectname_id} . '.' . $objectname;
} else {
$objectname = $origin_objectname;
$description = $params{'objecttype'} . '.' . $origin_objectname . '[' . $response_id . ']';
$objectname = $origin_objectname;

# use a custom label from a field in the response as perfdata label (see #56)
my $label;

if ( $plugin->opts->label ) {
$label = $response->{'id'};
} else {
$label = $response_id;
}
$description = $params{'objecttype'} . '.' . $origin_objectname . '[' . $label . ']';
}

if ( not defined( $response->{$objectname} ) ) {
Expand Down

0 comments on commit 5c0ef0a

Please sign in to comment.