adjust/move prometheus perfdata + cleaning
This commit is contained in:
parent
f35d452a35
commit
9e76630bd6
|
@ -99,7 +99,6 @@ sub new {
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /running/ || %{state} !~ /ready/' },
|
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /running/ || %{state} !~ /ready/' },
|
||||||
"extra-filter:s@" => { name => 'extra_filter' },
|
"extra-filter:s@" => { name => 'extra_filter' },
|
||||||
"metric-overload:s@" => { name => 'metric_overload' },
|
"metric-overload:s@" => { name => 'metric_overload' },
|
||||||
"filter-counters:s" => { name => 'filter_counters' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
|
|
@ -106,7 +106,6 @@ sub new {
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"filter-counters:s" => { name => 'filter_counters' },
|
|
||||||
"extra-filter:s@" => { name => 'extra_filter' },
|
"extra-filter:s@" => { name => 'extra_filter' },
|
||||||
"metric-overload:s@" => { name => 'metric_overload' },
|
"metric-overload:s@" => { name => 'metric_overload' },
|
||||||
});
|
});
|
||||||
|
|
|
@ -104,7 +104,6 @@ sub new {
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"filter-counters:s" => { name => 'filter_counters' },
|
|
||||||
"extra-filter:s@" => { name => 'extra_filter' },
|
"extra-filter:s@" => { name => 'extra_filter' },
|
||||||
"metric-overload:s@" => { name => 'metric_overload' },
|
"metric-overload:s@" => { name => 'metric_overload' },
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,7 +40,7 @@ sub set_counters {
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{global_cpu} = [
|
$self->{maps_counters}->{global_cpu} = [
|
||||||
{ label => 'node-usage', set => {
|
{ label => 'node-usage', nlabel => 'node.cpu.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'node_average' } ],
|
key_values => [ { name => 'node_average' } ],
|
||||||
output_template => '%.2f %%',
|
output_template => '%.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -51,7 +51,7 @@ sub set_counters {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
$self->{maps_counters}->{cpu} = [
|
$self->{maps_counters}->{cpu} = [
|
||||||
{ label => 'cpu-usage', set => {
|
{ label => 'cpu-usage', nlabel => 'core.cpu.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'cpu_usage' }, { name => 'display' } ],
|
key_values => [ { name => 'cpu_usage' }, { name => 'display' } ],
|
||||||
output_template => 'Usage: %.2f %%',
|
output_template => 'Usage: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -93,14 +93,12 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
"instance:s" => { name => 'instance', default => 'instance=~".*"' },
|
||||||
"instance:s" => { name => 'instance', default => 'instance=~".*"' },
|
"cpu:s" => { name => 'cpu', default => 'cpu=~".*"' },
|
||||||
"cpu:s" => { name => 'cpu', default => 'cpu=~".*"' },
|
"extra-filter:s@" => { name => 'extra_filter' },
|
||||||
"extra-filter:s@" => { name => 'extra_filter' },
|
"metric-overload:s@" => { name => 'metric_overload' },
|
||||||
"metric-overload:s@" => { name => 'metric_overload' },
|
});
|
||||||
"filter-counters:s" => { name => 'filter_counters' },
|
|
||||||
});
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
@ -140,12 +138,16 @@ sub manage_selection {
|
||||||
|
|
||||||
$self->{nodes} = {};
|
$self->{nodes} = {};
|
||||||
|
|
||||||
my $results = $options{custom}->query_range(queries => [ '(1 - irate({__name__=~"' . $self->{metrics}->{cpu} . '",' .
|
my $results = $options{custom}->query_range(
|
||||||
'mode="idle",' .
|
queries => [
|
||||||
$self->{option_results}->{instance} . ',' .
|
'(1 - irate({__name__=~"' . $self->{metrics}->{cpu} . '",' .
|
||||||
$self->{option_results}->{cpu} .
|
'mode="idle",' .
|
||||||
$self->{extra_filter} . '}[' . $self->{prom_step} . '])) * 100' ],
|
$self->{option_results}->{instance} . ',' .
|
||||||
timeframe => $self->{prom_timeframe}, step => $self->{prom_step});
|
$self->{option_results}->{cpu} .
|
||||||
|
$self->{extra_filter} . '}[' . $self->{prom_step} . '])) * 100'
|
||||||
|
],
|
||||||
|
timeframe => $self->{prom_timeframe}, step => $self->{prom_step}
|
||||||
|
);
|
||||||
|
|
||||||
foreach my $result (@{$results}) {
|
foreach my $result (@{$results}) {
|
||||||
my $average = $options{custom}->compute(aggregation => 'average', values => $result->{values});
|
my $average = $options{custom}->compute(aggregation => 'average', values => $result->{values});
|
||||||
|
|
|
@ -40,7 +40,7 @@ sub set_counters {
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{global_cpu} = [
|
$self->{maps_counters}->{global_cpu} = [
|
||||||
{ label => 'node-wait', set => {
|
{ label => 'node-wait', nlabel => 'node.cpu.wait.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'iowait' } ],
|
key_values => [ { name => 'iowait' } ],
|
||||||
output_template => 'Wait: %.2f %%',
|
output_template => 'Wait: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -49,7 +49,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'node-user', set => {
|
{ label => 'node-user', nlabel => 'node.cpu.user.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'user' } ],
|
key_values => [ { name => 'user' } ],
|
||||||
output_template => 'User: %.2f %%',
|
output_template => 'User: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -58,7 +58,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'node-softirq', set => {
|
{ label => 'node-softirq', nlabel => 'node.cpu.softirq.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'softirq' } ],
|
key_values => [ { name => 'softirq' } ],
|
||||||
output_template => 'Soft Irq: %.2f %%',
|
output_template => 'Soft Irq: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -67,7 +67,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'node-interrupt', set => {
|
{ label => 'node-interrupt', nlabel => 'node.cpu.interrupt.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'irq' } ],
|
key_values => [ { name => 'irq' } ],
|
||||||
output_template => 'Interrupt: %.2f %%',
|
output_template => 'Interrupt: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -76,7 +76,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'node-idle', set => {
|
{ label => 'node-idle', nlabel => 'node.cpu.idle.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'idle' } ],
|
key_values => [ { name => 'idle' } ],
|
||||||
output_template => 'Idle: %.2f %%',
|
output_template => 'Idle: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -85,7 +85,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'node-steal', set => {
|
{ label => 'node-steal', nlabel => 'node.cpu.steal.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'steal' } ],
|
key_values => [ { name => 'steal' } ],
|
||||||
output_template => 'Steal: %.2f %%',
|
output_template => 'Steal: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -94,7 +94,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'node-system', set => {
|
{ label => 'node-system', nlabel => 'node.cpu.system.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'system' } ],
|
key_values => [ { name => 'system' } ],
|
||||||
output_template => 'System: %.2f %%',
|
output_template => 'System: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -103,7 +103,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'node-nice', set => {
|
{ label => 'node-nice', nlabel => 'node.cpu.nice.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'nice' } ],
|
key_values => [ { name => 'nice' } ],
|
||||||
output_template => 'Nice: %.2f %%',
|
output_template => 'Nice: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -114,7 +114,7 @@ sub set_counters {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
$self->{maps_counters}->{cpu} = [
|
$self->{maps_counters}->{cpu} = [
|
||||||
{ label => 'cpu-wait', set => {
|
{ label => 'cpu-wait', nlabel => 'core.cpu.wait.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'iowait' }, { name => 'display' } ],
|
key_values => [ { name => 'iowait' }, { name => 'display' } ],
|
||||||
output_template => 'Wait: %.2f %%',
|
output_template => 'Wait: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -123,7 +123,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'cpu-user', set => {
|
{ label => 'cpu-user', nlabel => 'core.cpu.user.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'user' }, { name => 'display' } ],
|
key_values => [ { name => 'user' }, { name => 'display' } ],
|
||||||
output_template => 'User: %.2f %%',
|
output_template => 'User: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -132,7 +132,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'cpu-softirq', set => {
|
{ label => 'cpu-softirq', nlabel => 'core.cpu.softirq.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'softirq' }, { name => 'display' } ],
|
key_values => [ { name => 'softirq' }, { name => 'display' } ],
|
||||||
output_template => 'Soft Irq: %.2f %%',
|
output_template => 'Soft Irq: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -141,7 +141,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'cpu-interrupt', set => {
|
{ label => 'cpu-interrupt', nlabel => 'core.cpu.interrupt.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'irq' }, { name => 'display' } ],
|
key_values => [ { name => 'irq' }, { name => 'display' } ],
|
||||||
output_template => 'Interrupt: %.2f %%',
|
output_template => 'Interrupt: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -150,7 +150,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'cpu-idle', set => {
|
{ label => 'cpu-idle', nlabel => 'core.cpu.idle.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'idle' }, { name => 'display' } ],
|
key_values => [ { name => 'idle' }, { name => 'display' } ],
|
||||||
output_template => 'Idle: %.2f %%',
|
output_template => 'Idle: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -159,7 +159,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'cpu-steal', set => {
|
{ label => 'cpu-steal', nlabel => 'core.cpu.steal.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'steal' }, { name => 'display' } ],
|
key_values => [ { name => 'steal' }, { name => 'display' } ],
|
||||||
output_template => 'Steal: %.2f %%',
|
output_template => 'Steal: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -168,7 +168,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'cpu-system', set => {
|
{ label => 'cpu-system', nlabel => 'core.cpu.system.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'system' }, { name => 'display' } ],
|
key_values => [ { name => 'system' }, { name => 'display' } ],
|
||||||
output_template => 'System: %.2f %%',
|
output_template => 'System: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -177,7 +177,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'cpu-nice', set => {
|
{ label => 'cpu-nice', nlabel => 'core.cpu.nice.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'nice' }, { name => 'display' } ],
|
key_values => [ { name => 'nice' }, { name => 'display' } ],
|
||||||
output_template => 'Nice: %.2f %%',
|
output_template => 'Nice: %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -219,15 +219,13 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
"instance:s" => { name => 'instance', default => 'instance=~".*"' },
|
||||||
"instance:s" => { name => 'instance', default => 'instance=~".*"' },
|
"cpu:s" => { name => 'cpu', default => 'cpu=~".*"' },
|
||||||
"cpu:s" => { name => 'cpu', default => 'cpu=~".*"' },
|
"type:s" => { name => 'type', default => 'mode=~".*"' },
|
||||||
"type:s" => { name => 'type', default => 'mode=~".*"' },
|
"extra-filter:s@" => { name => 'extra_filter' },
|
||||||
"extra-filter:s@" => { name => 'extra_filter' },
|
"metric-overload:s@" => { name => 'metric_overload' },
|
||||||
"metric-overload:s@" => { name => 'metric_overload' },
|
});
|
||||||
"filter-counters:s" => { name => 'filter_counters' },
|
|
||||||
});
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
@ -267,12 +265,16 @@ sub manage_selection {
|
||||||
|
|
||||||
$self->{nodes} = {};
|
$self->{nodes} = {};
|
||||||
|
|
||||||
my $results = $options{custom}->query_range(queries => [ '(irate({__name__=~"' . $self->{metrics}->{cpu} . '",' .
|
my $results = $options{custom}->query_range(
|
||||||
$self->{option_results}->{instance} . ',' .
|
queries => [
|
||||||
$self->{option_results}->{cpu} . ',' .
|
'(irate({__name__=~"' . $self->{metrics}->{cpu} . '",' .
|
||||||
$self->{option_results}->{type} .
|
$self->{option_results}->{instance} . ',' .
|
||||||
$self->{extra_filter} . '}[' . $self->{prom_step} . '])) * 100' ],
|
$self->{option_results}->{cpu} . ',' .
|
||||||
timeframe => $self->{prom_timeframe}, step => $self->{prom_step});
|
$self->{option_results}->{type} .
|
||||||
|
$self->{extra_filter} . '}[' . $self->{prom_step} . '])) * 100'
|
||||||
|
],
|
||||||
|
timeframe => $self->{prom_timeframe}, step => $self->{prom_step}
|
||||||
|
);
|
||||||
|
|
||||||
foreach my $result (@{$results}) {
|
foreach my $result (@{$results}) {
|
||||||
my $average = $options{custom}->compute(aggregation => 'average', values => $result->{values});
|
my $average = $options{custom}->compute(aggregation => 'average', values => $result->{values});
|
||||||
|
|
|
@ -33,7 +33,7 @@ sub set_counters {
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{nodes} = [
|
$self->{maps_counters}->{nodes} = [
|
||||||
{ label => 'load1', set => {
|
{ label => 'load1', nlabel => 'load.1minute.count', set => {
|
||||||
key_values => [ { name => 'load1' }, { name => 'display' } ],
|
key_values => [ { name => 'load1' }, { name => 'display' } ],
|
||||||
output_template => 'Load 1 minute: %.2f',
|
output_template => 'Load 1 minute: %.2f',
|
||||||
output_change_bytes => 1,
|
output_change_bytes => 1,
|
||||||
|
@ -43,7 +43,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'load5', set => {
|
{ label => 'load5', nlabel => 'load.5minutes.count', set => {
|
||||||
key_values => [ { name => 'load5' }, { name => 'display' } ],
|
key_values => [ { name => 'load5' }, { name => 'display' } ],
|
||||||
output_template => 'Load 5 minutes: %.2f',
|
output_template => 'Load 5 minutes: %.2f',
|
||||||
output_change_bytes => 1,
|
output_change_bytes => 1,
|
||||||
|
@ -53,7 +53,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'load15', set => {
|
{ label => 'load15', nlabel => 'load.15minutes.count', set => {
|
||||||
key_values => [ { name => 'load15' }, { name => 'display' } ],
|
key_values => [ { name => 'load15' }, { name => 'display' } ],
|
||||||
output_template => 'Load 15 minutes: %.2f',
|
output_template => 'Load 15 minutes: %.2f',
|
||||||
output_change_bytes => 1,
|
output_change_bytes => 1,
|
||||||
|
@ -78,13 +78,11 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
"instance:s" => { name => 'instance', default => 'instance=~".*"' },
|
||||||
"instance:s" => { name => 'instance', default => 'instance=~".*"' },
|
"extra-filter:s@" => { name => 'extra_filter' },
|
||||||
"extra-filter:s@" => { name => 'extra_filter' },
|
"metric-overload:s@" => { name => 'metric_overload' },
|
||||||
"metric-overload:s@" => { name => 'metric_overload' },
|
});
|
||||||
"filter-counters:s" => { name => 'filter_counters' },
|
|
||||||
});
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
@ -123,15 +121,19 @@ sub manage_selection {
|
||||||
|
|
||||||
$self->{nodes} = {};
|
$self->{nodes} = {};
|
||||||
|
|
||||||
my $results = $options{custom}->query(queries => [ 'label_replace({__name__=~"' . $self->{metrics}->{load1} . '",' .
|
my $results = $options{custom}->query(
|
||||||
$self->{option_results}->{instance} .
|
queries => [
|
||||||
$self->{extra_filter} . '}, "__name__", "load1", "", "")',
|
'label_replace({__name__=~"' . $self->{metrics}->{load1} . '",' .
|
||||||
'label_replace({__name__=~"' . $self->{metrics}->{load5} . '",' .
|
$self->{option_results}->{instance} .
|
||||||
$self->{option_results}->{instance} .
|
$self->{extra_filter} . '}, "__name__", "load1", "", "")',
|
||||||
$self->{extra_filter} . '}, "__name__", "load5", "", "")',
|
'label_replace({__name__=~"' . $self->{metrics}->{load5} . '",' .
|
||||||
'label_replace({__name__=~"' . $self->{metrics}->{load15} . '",' .
|
$self->{option_results}->{instance} .
|
||||||
$self->{option_results}->{instance} .
|
$self->{extra_filter} . '}, "__name__", "load5", "", "")',
|
||||||
$self->{extra_filter} . '}, "__name__", "load15", "", "")' ]);
|
'label_replace({__name__=~"' . $self->{metrics}->{load15} . '",' .
|
||||||
|
$self->{option_results}->{instance} .
|
||||||
|
$self->{extra_filter} . '}, "__name__", "load15", "", "")'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
foreach my $result (@{$results}) {
|
foreach my $result (@{$results}) {
|
||||||
$self->{nodes}->{$result->{metric}->{$self->{labels}->{instance}}}->{display} = $result->{metric}->{$self->{labels}->{instance}};
|
$self->{nodes}->{$result->{metric}->{$self->{labels}->{instance}}}->{display} = $result->{metric}->{$self->{labels}->{instance}};
|
||||||
|
|
|
@ -30,19 +30,22 @@ sub custom_usage_perfdata {
|
||||||
|
|
||||||
my $label = 'used';
|
my $label = 'used';
|
||||||
my $value_perf = $self->{result_values}->{used};
|
my $value_perf = $self->{result_values}->{used};
|
||||||
my $extra_label = '';
|
|
||||||
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
|
||||||
my %total_options = ();
|
my %total_options = ();
|
||||||
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
|
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
|
||||||
$total_options{total} = $self->{result_values}->{total};
|
$total_options{total} = $self->{result_values}->{total};
|
||||||
$total_options{cast_int} = 1;
|
$total_options{cast_int} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B',
|
$self->{output}->perfdata_add(
|
||||||
value => $value_perf,
|
label => $label, unit => 'B',
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options),
|
nlabel => 'memory.usage.bytes',
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
|
value => $value_perf,
|
||||||
min => 0, max => $self->{result_values}->{total});
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
|
||||||
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options),
|
||||||
|
min => 0, max => $self->{result_values}->{total},
|
||||||
|
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_usage_threshold {
|
sub custom_usage_threshold {
|
||||||
|
@ -53,8 +56,9 @@ sub custom_usage_threshold {
|
||||||
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
|
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
|
||||||
$threshold_value = $self->{result_values}->{prct_used};
|
$threshold_value = $self->{result_values}->{prct_used};
|
||||||
}
|
}
|
||||||
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
|
$exit = $self->{perfdata}->threshold_check(value => $threshold_value,
|
||||||
{ label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
|
threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
|
||||||
|
{ label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||||
return $exit;
|
return $exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +104,7 @@ sub set_counters {
|
||||||
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'buffer', set => {
|
{ label => 'buffer', nlabel => 'buffer.usage.bytes', set => {
|
||||||
key_values => [ { name => 'buffer' }, { name => 'display' } ],
|
key_values => [ { name => 'buffer' }, { name => 'display' } ],
|
||||||
output_template => 'Buffer: %.2f %s',
|
output_template => 'Buffer: %.2f %s',
|
||||||
output_change_bytes => 1,
|
output_change_bytes => 1,
|
||||||
|
@ -110,7 +114,7 @@ sub set_counters {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'cached', set => {
|
{ label => 'cached', nlabel => 'cache.usage.bytes', set => {
|
||||||
key_values => [ { name => 'cached' }, { name => 'display' } ],
|
key_values => [ { name => 'cached' }, { name => 'display' } ],
|
||||||
output_template => 'Cached: %.2f %s',
|
output_template => 'Cached: %.2f %s',
|
||||||
output_change_bytes => 1,
|
output_change_bytes => 1,
|
||||||
|
@ -180,18 +184,22 @@ sub manage_selection {
|
||||||
|
|
||||||
$self->{nodes} = {};
|
$self->{nodes} = {};
|
||||||
|
|
||||||
my $results = $options{custom}->query(queries => [ 'label_replace({__name__=~"' . $self->{metrics}->{total} . '",' .
|
my $results = $options{custom}->query(
|
||||||
$self->{option_results}->{instance} .
|
queries => [
|
||||||
$self->{extra_filter} . '}, "__name__", "total", "", "")',
|
'label_replace({__name__=~"' . $self->{metrics}->{total} . '",' .
|
||||||
'label_replace({__name__=~"' . $self->{metrics}->{available} . '",' .
|
$self->{option_results}->{instance} .
|
||||||
$self->{option_results}->{instance} .
|
$self->{extra_filter} . '}, "__name__", "total", "", "")',
|
||||||
$self->{extra_filter} . '}, "__name__", "available", "", "")',
|
'label_replace({__name__=~"' . $self->{metrics}->{available} . '",' .
|
||||||
'label_replace({__name__=~"' . $self->{metrics}->{cached} . '",' .
|
$self->{option_results}->{instance} .
|
||||||
$self->{option_results}->{instance} .
|
$self->{extra_filter} . '}, "__name__", "available", "", "")',
|
||||||
$self->{extra_filter} . '}, "__name__", "cached", "", "")',
|
'label_replace({__name__=~"' . $self->{metrics}->{cached} . '",' .
|
||||||
'label_replace({__name__=~"' . $self->{metrics}->{buffer} . '",' .
|
$self->{option_results}->{instance} .
|
||||||
$self->{option_results}->{instance} .
|
$self->{extra_filter} . '}, "__name__", "cached", "", "")',
|
||||||
$self->{extra_filter} . '}, "__name__", "buffer", "", "")' ]);
|
'label_replace({__name__=~"' . $self->{metrics}->{buffer} . '",' .
|
||||||
|
$self->{option_results}->{instance} .
|
||||||
|
$self->{extra_filter} . '}, "__name__", "buffer", "", "")'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
foreach my $result (@{$results}) {
|
foreach my $result (@{$results}) {
|
||||||
$self->{nodes}->{$result->{metric}->{$self->{labels}->{instance}}}->{display} = $result->{metric}->{$self->{labels}->{instance}};
|
$self->{nodes}->{$result->{metric}->{$self->{labels}->{instance}}}->{display} = $result->{metric}->{$self->{labels}->{instance}};
|
||||||
|
|
|
@ -28,10 +28,9 @@ use warnings;
|
||||||
sub custom_usage_perfdata {
|
sub custom_usage_perfdata {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $extra_label = '';
|
|
||||||
$extra_label = '_' . $self->{result_values}->{label} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
|
||||||
my $label = 'used';
|
my $label = 'used';
|
||||||
my $value_perf = $self->{result_values}->{used};
|
my $value_perf = $self->{result_values}->{used};
|
||||||
|
|
||||||
if (defined($self->{instance_mode}->{option_results}->{free})) {
|
if (defined($self->{instance_mode}->{option_results}->{free})) {
|
||||||
$label = 'free';
|
$label = 'free';
|
||||||
$value_perf = $self->{result_values}->{free};
|
$value_perf = $self->{result_values}->{free};
|
||||||
|
@ -42,11 +41,15 @@ sub custom_usage_perfdata {
|
||||||
$total_options{cast_int} = 1;
|
$total_options{cast_int} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B',
|
$self->{output}->perfdata_add(
|
||||||
value => $value_perf,
|
label => $label . $extra_label, unit => 'B',
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options),
|
nlabel => 'memory.usage.bytes',
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
|
value => $value_perf,
|
||||||
min => 0, max => $self->{result_values}->{total});
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
|
||||||
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options),
|
||||||
|
min => 0, max => $self->{result_values}->{total}
|
||||||
|
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_usage_threshold {
|
sub custom_usage_threshold {
|
||||||
|
@ -59,7 +62,9 @@ sub custom_usage_threshold {
|
||||||
$threshold_value = $self->{result_values}->{prct_used};
|
$threshold_value = $self->{result_values}->{prct_used};
|
||||||
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
|
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
|
||||||
}
|
}
|
||||||
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
|
$exit = $self->{perfdata}->threshold_check(value => $threshold_value,
|
||||||
|
threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
|
||||||
|
{ label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||||
return $exit;
|
return $exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,16 +198,20 @@ sub manage_selection {
|
||||||
|
|
||||||
$self->{nodes} = {};
|
$self->{nodes} = {};
|
||||||
|
|
||||||
my $results = $options{custom}->query(queries => [ 'label_replace({__name__=~"' . $self->{metrics}->{free} . '",' .
|
my $results = $options{custom}->query(
|
||||||
$self->{option_results}->{instance} . ',' .
|
queries => [
|
||||||
$self->{option_results}->{mountpoint} . ',' .
|
'label_replace({__name__=~"' . $self->{metrics}->{free} . '",' .
|
||||||
$self->{option_results}->{fstype} .
|
$self->{option_results}->{instance} . ',' .
|
||||||
$self->{extra_filter} . '}, "__name__", "free", "", "")',
|
$self->{option_results}->{mountpoint} . ',' .
|
||||||
'label_replace({__name__=~"' . $self->{metrics}->{size} . '",' .
|
$self->{option_results}->{fstype} .
|
||||||
$self->{option_results}->{instance} . ',' .
|
$self->{extra_filter} . '}, "__name__", "free", "", "")',
|
||||||
$self->{option_results}->{mountpoint} . ',' .
|
'label_replace({__name__=~"' . $self->{metrics}->{size} . '",' .
|
||||||
$self->{option_results}->{fstype} .
|
$self->{option_results}->{instance} . ',' .
|
||||||
$self->{extra_filter} . '}, "__name__", "size", "", "")' ]);
|
$self->{option_results}->{mountpoint} . ',' .
|
||||||
|
$self->{option_results}->{fstype} .
|
||||||
|
$self->{extra_filter} . '}, "__name__", "size", "", "")'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
foreach my $result (@{$results}) {
|
foreach my $result (@{$results}) {
|
||||||
$self->{nodes}->{$result->{metric}->{$self->{labels}->{instance}}}->{display} = $result->{metric}->{$self->{labels}->{instance}};
|
$self->{nodes}->{$result->{metric}->{$self->{labels}->{instance}}}->{display} = $result->{metric}->{$self->{labels}->{instance}};
|
||||||
|
|
Loading…
Reference in New Issue