enh(citrix) Get licenses by name/PLD
This commit is contained in:
parent
71f21194f7
commit
214cd95b97
|
@ -49,11 +49,43 @@ sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters_type} = [
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
|
||||||
{ name => 'license', type => 1, cb_prefix_output => 'prefix_license_output', message_multiple => 'All licenses are ok', skipped_code => { -10 => 1 } },
|
{ name => 'license', type => 1, cb_prefix_output => 'prefix_license_output', message_multiple => 'All licenses are ok', skipped_code => { -10 => 1 } },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'total-count', nlabel => 'licenses.count', set => {
|
||||||
|
key_values => [ { name => 'count' } ],
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'count', template => '%d' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'total-usage', nlabel => 'licenses.usage.count', set => {
|
||||||
|
key_values => [ { name => 'used' }, { name => 'total' } ],
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'used', template => '%d', min => 0, max => 'total' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'total-usage-free', display_ok => 0, nlabel => 'licenses.free.count', set => {
|
||||||
|
key_values => [ { name => 'free' }, { name => 'total' } ],
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'free', template => '%d', min => 0, max => 'total' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'total-usage-prct', display_ok => 0, nlabel => 'licenses.usage.percentage', set => {
|
||||||
|
key_values => [ { name => 'prct_used' } ],
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{license} = [
|
$self->{maps_counters}->{license} = [
|
||||||
{ label => 'usage', nlabel => 'licenses.usage.count', set => {
|
{ label => 'usage', nlabel => 'license.usage.count', set => {
|
||||||
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ],
|
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ],
|
||||||
closure_custom_output => $self->can('custom_license_output'),
|
closure_custom_output => $self->can('custom_license_output'),
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -61,7 +93,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'usage-free', display_ok => 0, nlabel => 'licenses.free.count', set => {
|
{ label => 'usage-free', display_ok => 0, nlabel => 'license.free.count', set => {
|
||||||
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ],
|
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ],
|
||||||
closure_custom_output => $self->can('custom_license_output'),
|
closure_custom_output => $self->can('custom_license_output'),
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -69,7 +101,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'usage-prct', display_ok => 0, nlabel => 'licenses.usage.percentage', set => {
|
{ label => 'usage-prct', display_ok => 0, nlabel => 'license.usage.percentage', set => {
|
||||||
key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ],
|
key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ],
|
||||||
closure_custom_output => $self->can('custom_license_output'),
|
closure_custom_output => $self->can('custom_license_output'),
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -101,10 +133,14 @@ sub manage_selection {
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{global} = { count => 0, total => 0, used => 0 };
|
||||||
my $query = "Select PLD,InUseCount,Count from Citrix_GT_License_Pool";
|
my $query = "Select PLD,InUseCount,Count from Citrix_GT_License_Pool";
|
||||||
my $resultset = $wmi->ExecQuery($query);
|
my $resultset = $wmi->ExecQuery($query);
|
||||||
foreach my $obj (in $resultset) {
|
foreach my $obj (in $resultset) {
|
||||||
if (!defined($self->{option_results}->{filter}) || ($obj->{PLD} =~ /$self->{option_results}->{filter}/i)) {
|
if (!defined($self->{option_results}->{filter}) || ($obj->{PLD} =~ /$self->{option_results}->{filter}/i)) {
|
||||||
|
$self->{global}->{count}++;
|
||||||
|
$self->{global}->{used} += $obj->{InUseCount};
|
||||||
|
$self->{global}->{total} += $obj->{Count};
|
||||||
$self->{license}->{$obj->{PLD}}->{display} = $obj->{PLD};
|
$self->{license}->{$obj->{PLD}}->{display} = $obj->{PLD};
|
||||||
$self->{license}->{$obj->{PLD}}->{used} = $obj->{InUseCount};
|
$self->{license}->{$obj->{PLD}}->{used} = $obj->{InUseCount};
|
||||||
$self->{license}->{$obj->{PLD}}->{total} = $obj->{Count};
|
$self->{license}->{$obj->{PLD}}->{total} = $obj->{Count};
|
||||||
|
@ -118,6 +154,10 @@ sub manage_selection {
|
||||||
$self->{output}->add_option_msg(short_msg => 'Cant get licenses count');
|
$self->{output}->add_option_msg(short_msg => 'Cant get licenses count');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{global}->{prct_used} = $self->{global}->{used} * 100 / $self->{global}->{total};
|
||||||
|
$self->{global}->{prct_free} = 100 - $self->{global}->{prct_used};
|
||||||
|
$self->{global}->{free} = $self->{global}->{total} - $self->{global}->{used};
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -137,7 +177,8 @@ Filter license name.
|
||||||
=item B<--warning-*> B<--critical-*>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Thresholds.
|
Thresholds.
|
||||||
Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%).
|
Can be: 'usage', 'usage-free, 'usage-prct' (%),
|
||||||
|
'total-usage', 'total-count', 'total-usage-free, 'total-usage-prct' (%).
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue