| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package apps::toshiba::storemate::sql::mode::posstatus; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
sub set_counters { |
| 29 |
my ($self, %options) = @_; |
| 30 |
|
| 31 |
$self->{maps_counters_type} = [ |
| 32 |
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, |
| 33 |
{ name => 'state', type => 0, cb_prefix_output => 'prefix_state_output' }, |
| 34 |
{ name => 'merchandise', type => 0, cb_prefix_output => 'prefix_merchandise_output' }, |
| 35 |
{ name => 'transaction', type => 0, cb_prefix_output => 'prefix_transaction_output' }, |
| 36 |
]; |
| 37 |
|
| 38 |
$self->{maps_counters}->{global} = [ |
| 39 |
{ label => 'total', set => { |
| 40 |
key_values => [ { name => 'total' } ], |
| 41 |
output_template => 'total : %s', |
| 42 |
perfdatas => [ |
| 43 |
{ label => 'total', value => 'total', template => '%s', |
| 44 |
min => 0 }, |
| 45 |
], |
| 46 |
} |
| 47 |
}, |
| 48 |
{ label => 'online', set => { |
| 49 |
key_values => [ { name => 'online' } ], |
| 50 |
output_template => 'online : %s', |
| 51 |
perfdatas => [ |
| 52 |
{ label => 'online', value => 'online', template => '%s', |
| 53 |
min => 0 }, |
| 54 |
], |
| 55 |
} |
| 56 |
}, |
| 57 |
{ label => 'offline', set => { |
| 58 |
key_values => [ { name => 'offline' } ], |
| 59 |
output_template => 'offline : %s', |
| 60 |
perfdatas => [ |
| 61 |
{ label => 'offline', value => 'offline', template => '%s', |
| 62 |
min => 0 }, |
| 63 |
], |
| 64 |
} |
| 65 |
}, |
| 66 |
]; |
| 67 |
|
| 68 |
$self->{maps_counters}->{state} = [ |
| 69 |
{ label => 'state-unknown', set => { |
| 70 |
key_values => [ { name => 'unknown' } ], |
| 71 |
output_template => 'unknown : %s', |
| 72 |
perfdatas => [ |
| 73 |
{ label => 'state_unknown', value => 'unknown', template => '%s', |
| 74 |
min => 0 }, |
| 75 |
], |
| 76 |
} |
| 77 |
}, |
| 78 |
{ label => 'state-signoff', set => { |
| 79 |
key_values => [ { name => 'signoff' } ], |
| 80 |
output_template => 'signed off : %s', |
| 81 |
perfdatas => [ |
| 82 |
{ label => 'state_signoff', value => 'signoff', template => '%s', |
| 83 |
min => 0 }, |
| 84 |
], |
| 85 |
} |
| 86 |
}, |
| 87 |
{ label => 'state-signon', set => { |
| 88 |
key_values => [ { name => 'signon' } ], |
| 89 |
output_template => 'signed on : %s', |
| 90 |
perfdatas => [ |
| 91 |
{ label => 'state_signon', value => 'signon', template => '%s', |
| 92 |
min => 0 }, |
| 93 |
], |
| 94 |
} |
| 95 |
}, |
| 96 |
{ label => 'state-closed', set => { |
| 97 |
key_values => [ { name => 'closed' } ], |
| 98 |
output_template => 'closed : %s', |
| 99 |
perfdatas => [ |
| 100 |
{ label => 'state_closed', value => 'closed', template => '%s', |
| 101 |
min => 0 }, |
| 102 |
], |
| 103 |
} |
| 104 |
}, |
| 105 |
{ label => 'state-paused', set => { |
| 106 |
key_values => [ { name => 'paused' } ], |
| 107 |
output_template => 'paused : %s', |
| 108 |
perfdatas => [ |
| 109 |
{ label => 'state_paused', value => 'paused', template => '%s', |
| 110 |
min => 0 }, |
| 111 |
], |
| 112 |
} |
| 113 |
}, |
| 114 |
]; |
| 115 |
|
| 116 |
$self->{maps_counters}->{merchandise} = [ |
| 117 |
{ label => 'merchandise-rep-unknown', set => { |
| 118 |
key_values => [ { name => 'unknown' } ], |
| 119 |
output_template => 'unknown : %s', |
| 120 |
perfdatas => [ |
| 121 |
{ label => 'merchandise_rep_unknown', value => 'unknown', template => '%s', |
| 122 |
min => 0 }, |
| 123 |
], |
| 124 |
} |
| 125 |
}, |
| 126 |
{ label => 'merchandise-rep-ok', set => { |
| 127 |
key_values => [ { name => 'ok' } ], |
| 128 |
output_template => 'ok : %s', |
| 129 |
perfdatas => [ |
| 130 |
{ label => 'merchandise_rep_ok', value => 'ok', template => '%s', |
| 131 |
min => 0 }, |
| 132 |
], |
| 133 |
} |
| 134 |
}, |
| 135 |
{ label => 'merchandise-rep-suspended', set => { |
| 136 |
key_values => [ { name => 'suspended' } ], |
| 137 |
output_template => 'suspended : %s', |
| 138 |
perfdatas => [ |
| 139 |
{ label => 'merchandise_rep_suspended', value => 'suspended', template => '%s', |
| 140 |
min => 0 }, |
| 141 |
], |
| 142 |
} |
| 143 |
}, |
| 144 |
{ label => 'merchandise-rep-error', set => { |
| 145 |
key_values => [ { name => 'error' } ], |
| 146 |
output_template => 'error : %s', |
| 147 |
perfdatas => [ |
| 148 |
{ label => 'merchandise_rep_error', value => 'error', template => '%s', |
| 149 |
min => 0 }, |
| 150 |
], |
| 151 |
} |
| 152 |
}, |
| 153 |
]; |
| 154 |
|
| 155 |
$self->{maps_counters}->{transaction} = [ |
| 156 |
{ label => 'transaction-rep-unknown', set => { |
| 157 |
key_values => [ { name => 'unknown' } ], |
| 158 |
output_template => 'unknown : %s', |
| 159 |
perfdatas => [ |
| 160 |
{ label => 'transaction_rep_unknown', value => 'unknown', template => '%s', |
| 161 |
min => 0 }, |
| 162 |
], |
| 163 |
} |
| 164 |
}, |
| 165 |
{ label => 'transaction-rep-ok', set => { |
| 166 |
key_values => [ { name => 'ok' } ], |
| 167 |
output_template => 'ok : %s', |
| 168 |
perfdatas => [ |
| 169 |
{ label => 'transaction_rep_ok', value => 'ok', template => '%s', |
| 170 |
min => 0 }, |
| 171 |
], |
| 172 |
} |
| 173 |
}, |
| 174 |
{ label => 'transaction-rep-suspended', set => { |
| 175 |
key_values => [ { name => 'suspended' } ], |
| 176 |
output_template => 'suspended : %s', |
| 177 |
perfdatas => [ |
| 178 |
{ label => 'transaction_rep_suspended', value => 'suspended', template => '%s', |
| 179 |
min => 0 }, |
| 180 |
], |
| 181 |
} |
| 182 |
}, |
| 183 |
{ label => 'transaction-rep-error', set => { |
| 184 |
key_values => [ { name => 'error' } ], |
| 185 |
output_template => 'error : %s', |
| 186 |
perfdatas => [ |
| 187 |
{ label => 'transaction_rep_error', value => 'error', template => '%s', |
| 188 |
min => 0 }, |
| 189 |
], |
| 190 |
} |
| 191 |
}, |
| 192 |
]; |
| 193 |
} |
| 194 |
|
| 195 |
sub prefix_global_output { |
| 196 |
my ($self, %options) = @_; |
| 197 |
|
| 198 |
return "Points of sale "; |
| 199 |
} |
| 200 |
|
| 201 |
sub prefix_state_output { |
| 202 |
my ($self, %options) = @_; |
| 203 |
|
| 204 |
return "State "; |
| 205 |
} |
| 206 |
|
| 207 |
sub prefix_merchandise_output { |
| 208 |
my ($self, %options) = @_; |
| 209 |
|
| 210 |
return "Merchandise replication "; |
| 211 |
} |
| 212 |
|
| 213 |
sub prefix_transaction_output { |
| 214 |
my ($self, %options) = @_; |
| 215 |
|
| 216 |
return "Transaction replication "; |
| 217 |
} |
| 218 |
|
| 219 |
sub new { |
| 220 |
my ($class, %options) = @_; |
| 221 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 222 |
bless $self, $class; |
| 223 |
|
| 224 |
$options{options}->add_options(arguments => |
| 225 |
{ |
| 226 |
"database:s" => { name => 'database', default => 'Framework' }, |
| 227 |
}); |
| 228 |
|
| 229 |
return $self; |
| 230 |
} |
| 231 |
|
| 232 |
sub manage_selection { |
| 233 |
my ($self, %options) = @_; |
| 234 |
|
| 235 |
$self->{sql} = $options{sql}; |
| 236 |
$self->{sql}->connect(); |
| 237 |
$self->{sql}->query(query => "SELECT WORKSTATION_ID, ONLINE, FO_STATE, MERCHANDISE_REPLICATION, TRANSACTION_REPLICATION |
| 238 |
FROM " . $self->{option_results}->{database} . ".dbo.WORKSTATION_STATUS"); |
| 239 |
|
| 240 |
$self->{global} = { total => 0, online => 0, offline => 0 }; |
| 241 |
$self->{state} = { unknown => 0, signoff => 0, signon => 0, closed => 0, paused => 0 }; |
| 242 |
$self->{merchandise} = { unknown => 0, ok => 0, suspended => 0, error => 0 }; |
| 243 |
$self->{transaction} = { unknown => 0, ok => 0, suspended => 0, error => 0 }; |
| 244 |
|
| 245 |
my %map_status = (0 => 'offline', 1 => 'online'); |
| 246 |
my %map_state = (0 => 'unknown', 1 => 'signoff', 2 => 'signon', 3 => 'closed', 4 => 'paused'); |
| 247 |
my %map_merch_rep_status = (0 => 'unknown', 1 => 'ok', 2 => 'suspended', 3 => 'error'); |
| 248 |
my %map_trans_rep_status = (0 => 'unknown', 1 => 'ok', 2 => 'suspended', 3 => 'error'); |
| 249 |
|
| 250 |
while (my $row = $self->{sql}->fetchrow_hashref()) { |
| 251 |
$self->{global}->{total}++; |
| 252 |
$self->{global}->{$map_status{$row->{ONLINE}}}++ |
| 253 |
if (defined($map_status{$row->{ONLINE}})); |
| 254 |
$self->{state}->{$map_state{$row->{FO_STATE}}}++ |
| 255 |
if (defined($map_state{$row->{FO_STATE}})); |
| 256 |
$self->{merchandise}->{$map_merch_rep_status{$row->{MERCHANDISE_REPLICATION}}}++ |
| 257 |
if (defined($map_merch_rep_status{$row->{MERCHANDISE_REPLICATION}})); |
| 258 |
$self->{transaction}->{$map_trans_rep_status{$row->{TRANSACTION_REPLICATION}}}++ |
| 259 |
if (defined($map_trans_rep_status{$row->{TRANSACTION_REPLICATION}})); |
| 260 |
} |
| 261 |
} |
| 262 |
|
| 263 |
1; |
| 264 |
|
| 265 |
__END__ |
| 266 |
|
| 267 |
=head1 MODE |
| 268 |
|
| 269 |
Check points of sale status |
| 270 |
|
| 271 |
=over 8 |
| 272 |
|
| 273 |
=item B<--database> |
| 274 |
|
| 275 |
Database name (default: 'Framework'). |
| 276 |
|
| 277 |
=item B<--warning-*> |
| 278 |
|
| 279 |
Warning threshold. |
| 280 |
Can be: 'online, offline, state-unknown, state-signoff, state-signon, state-closed, state-paused, |
| 281 |
merchandise-rep-unknown, merchandise-rep-ok, merchandise-rep-suspended, merchandise-rep-error, |
| 282 |
transaction-rep-unknown, transaction-rep-ok, transaction-rep-suspended, transaction-rep-error'. |
| 283 |
|
| 284 |
=item B<--critical-*> |
| 285 |
|
| 286 |
Critical threshold. |
| 287 |
Can be: 'online, offline, state-unknown, state-signoff, state-signon, state-closed, state-paused, |
| 288 |
merchandise-rep-unknown, merchandise-rep-ok, merchandise-rep-suspended, merchandise-rep-error, |
| 289 |
transaction-rep-unknown, transaction-rep-ok, transaction-rep-suspended, transaction-rep-error'. |
| 290 |
|
| 291 |
=back |
| 292 |
|
| 293 |
=cut |
| 294 |
|