@@ -25,6 +25,7 @@ use warnings;
2525use base qw( centreon::plugins::templates::counter) ;
2626use centreon::plugins::constants qw( :counters) ;
2727use centreon::plugins::misc qw( is_excluded) ;
28+ use Digest::SHA qw( sha256_hex) ;
2829
2930sub prefix_by_instance_output {
3031 my ($self , %options ) = @_ ;
@@ -41,9 +42,9 @@ sub set_counters {
4142 ];
4243
4344 $self -> {maps_counters }-> {total } = [
44- { label => ' deadlocks' , type => COUNTER_KIND_METRIC, nlabel => ' total#mssql.deadlocks.count ' , set => {
45- key_values => [ { name => ' total' } ],
46- output_template => ' %.2f total dead locks/s ' ,
45+ { label => ' deadlocks' , type => COUNTER_KIND_METRIC, nlabel => ' total#mssql.deadlocks.perminute ' , set => {
46+ key_values => [ { name => ' total' , per_minute => 1 } ],
47+ output_template => ' %.2f total dead locks/min ' ,
4748 perfdatas => [
4849 { template => ' %.2f' , min => 0 },
4950 ],
@@ -52,9 +53,9 @@ sub set_counters {
5253 ];
5354
5455 $self -> {maps_counters }-> {by_instance } = [
55- { label => ' deadlocks-by-instance' , nlabel => ' mssql.deadlocks.count ' , set => {
56- key_values => [ { name => ' value' }, { name => ' display' } ],
57- output_template => ' %.2f dead locks/s ' ,
56+ { label => ' deadlocks-by-instance' , nlabel => ' mssql.deadlocks.perminute ' , set => {
57+ key_values => [ { name => ' value' , per_minute => 1 }, { name => ' display' } ],
58+ output_template => ' %.2f dead locks/min ' ,
5859 perfdatas => [
5960 { template => ' %.2f' , min => 0, label_extra_instance => 1, instance_use => ' display' },
6061 ],
@@ -63,10 +64,9 @@ sub set_counters {
6364 ];
6465}
6566
66-
6767sub new {
6868 my ($class , %options ) = @_ ;
69- my $self = $class -> SUPER::new(package => __PACKAGE__ , %options , force_new_perfdata => 1);
69+ my $self = $class -> SUPER::new(package => __PACKAGE__ , %options , statefile => 1, force_new_perfdata => 1);
7070 bless $self , $class ;
7171
7272 $options {options }-> add_options(arguments => {
@@ -96,7 +96,6 @@ sub manage_selection {
9696 my $query_result = $options {sql }-> fetchall_arrayref();
9797 $self -> {total }-> {total } = 0;
9898
99-
10099 foreach my $row (@{$query_result }) {
101100 my ($instance , $value ) = @$row ;
102101 next if $instance eq ' _Total' ;
@@ -109,6 +108,10 @@ sub manage_selection {
109108 }
110109 $self -> {output }-> option_exit(short_msg => " No locks counter found with given filters" )
111110 unless $self -> {by_instance } && keys %{$self -> {by_instance }};
111+
112+ $self -> {cache_name } = ' mssql_' . $self -> {mode } . ' _' . $options {sql }-> get_unique_id4save() . ' _' .
113+ sha256_hex($self -> {option_results }-> {include_instance }) . ' _' .
114+ sha256_hex($self -> {option_results }-> {exclude_instance });
112115}
113116
1141171;
@@ -117,7 +120,7 @@ __END__
117120
118121=head1 MODE
119122
120- Check MSSQL dead locks per second
123+ Check MSSQL dead locks per minute
121124
122125=over 8
123126
0 commit comments