diff --git a/database/mssql/mode/pagelifeexpectancy.pm b/database/mssql/mode/pagelifeexpectancy.pm index e9ca17e80..300fed534 100644 --- a/database/mssql/mode/pagelifeexpectancy.pm +++ b/database/mssql/mode/pagelifeexpectancy.pm @@ -29,79 +29,46 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', type => 1, cb_prefix_output => 'prefix_instance_output', - message_multiple => 'All page life expectancy are ok' }, + { name => 'global', type => 0 }, ]; $self->{maps_counters}->{global} = [ { 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)', perfdatas => [ - { value => 'page_life_expectancy_absolute', template => '%d', unit => 's', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'page_life_expectancy_absolute', template => '%d', unit => 's', min => 0 }, ] }} ]; } -sub prefix_instance_output { - my ($self, %options) = @_; - - return "Instance '" . $options{instance_value}->{display} . "' "; -} - sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - $options{options}->add_options(arguments => { - "filter-instance:s" => {name => 'filter_instance'}, - }); + $options{options}->add_options(arguments => {}); return $self; } -sub check_options { - my ($self, %options) = @_; - - $self->SUPER::check_options(%options); -} - sub manage_selection { my ($self, %options) = @_; - $self->{sql} = $options{sql}; - $self->{sql}->connect(); - $self->{sql}->query(query => q{ - SELECT object_name,cntr_value - FROM sys.dm_os_performance_counters - WHERE counter_name = 'Page life expectancy' - AND object_name LIKE '%Manager%' + $options{sql}->connect(); + $options{sql}->query(query => q{ + SELECT + cntr_value + FROM + 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) { - 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; + $self->{global}->{page_life_expectancy} = $options{sql}->fetchrow_array(); } 1; @@ -114,10 +81,6 @@ Check MSSQL page life expectancy. =over 8 -=item B<--filter-instance> - -Filter instance by name (Can be a regex). - =item B<--warning-page-life-expectancy> Threshold warning.