This reverts commit efb4d30078
.
This commit is contained in:
parent
efb4d30078
commit
930f4b0c9d
|
@ -29,79 +29,46 @@ sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters_type} = [
|
$self->{maps_counters_type} = [
|
||||||
{ name => 'global', type => 1, cb_prefix_output => 'prefix_instance_output',
|
{ name => 'global', type => 0 },
|
||||||
message_multiple => 'All page life expectancy are ok' },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
{ label => 'page-life-expectancy', nlabel => 'page.life.expectancy.seconds', set => {
|
{ label => 'page-life-expectancy', nlabel => 'page.life.expectancy.seconds', set => {
|
||||||
key_values => [ { name => 'page_life_expectancy' }, { name => 'display' },],
|
key_values => [ { name => 'page_life_expectancy'}],
|
||||||
output_template => 'Page life expectancy : %d second(s)',
|
output_template => 'Page life expectancy : %d second(s)',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ value => 'page_life_expectancy_absolute', template => '%d', unit => 's', min => 0,
|
{ value => 'page_life_expectancy_absolute', template => '%d', unit => 's', min => 0 },
|
||||||
label_extra_instance => 1, instance_use => 'display_absolute' },
|
|
||||||
]
|
]
|
||||||
}}
|
}}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub prefix_instance_output {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
return "Instance '" . $options{instance_value}->{display} . "' ";
|
|
||||||
}
|
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {});
|
||||||
"filter-instance:s" => {name => 'filter_instance'},
|
|
||||||
});
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
$self->SUPER::check_options(%options);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->{sql} = $options{sql};
|
|
||||||
|
|
||||||
$self->{sql}->connect();
|
$options{sql}->connect();
|
||||||
$self->{sql}->query(query => q{
|
$options{sql}->query(query => q{
|
||||||
SELECT object_name,cntr_value
|
SELECT
|
||||||
FROM sys.dm_os_performance_counters
|
cntr_value
|
||||||
WHERE counter_name = 'Page life expectancy'
|
FROM
|
||||||
AND object_name LIKE '%Manager%'
|
sys.dm_os_performance_counters
|
||||||
|
WHERE
|
||||||
|
counter_name = 'Page life expectancy'
|
||||||
|
AND
|
||||||
|
object_name = 'SQLServer:Buffer Manager'
|
||||||
});
|
});
|
||||||
my $result = $self->{sql}->fetchall_arrayref();
|
|
||||||
|
|
||||||
foreach my $row (@$result) {
|
$self->{global}->{page_life_expectancy} = $options{sql}->fetchrow_array();
|
||||||
if (defined($self->{option_results}->{filter_instance}) && $self->{option_results}->{filter_instance} ne '' &&
|
|
||||||
$$row[0] !~ /$self->{option_results}->{filter_instance}/i) {
|
|
||||||
$self->{output}->output_add(debug => 1, long_msg => "Skipping instance " . $$row[0] . ": no matching filter.");
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{global}->{$$row[0]} = {
|
|
||||||
page_life_expectancy => $$row[1],
|
|
||||||
display => get_instances_name($$row[0]),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub get_instances_name {
|
|
||||||
my ($object_name) = @_;
|
|
||||||
|
|
||||||
my ($instance) = $object_name =~ /(?<=\$)(.*?)(?=\:)/;
|
|
||||||
|
|
||||||
return $instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -114,10 +81,6 @@ Check MSSQL page life expectancy.
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
=item B<--filter-instance>
|
|
||||||
|
|
||||||
Filter instance by name (Can be a regex).
|
|
||||||
|
|
||||||
=item B<--warning-page-life-expectancy>
|
=item B<--warning-page-life-expectancy>
|
||||||
|
|
||||||
Threshold warning.
|
Threshold warning.
|
||||||
|
|
Loading…
Reference in New Issue