diff --git a/storage/synology/mode/hardware.pm b/storage/synology/mode/hardware.pm new file mode 100644 index 000000000..164ec443c --- /dev/null +++ b/storage/synology/mode/hardware.pm @@ -0,0 +1,347 @@ +################################################################################ +# Copyright 2005-2014 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package storage::synology::mode::hardware; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my $oid_synoSystempowerStatus = '.1.3.6.1.4.1.6574.1.3.0'; +my $oid_synoSystemsystemFanStatus = '.1.3.6.1.4.1.6574.1.4.1.0'; +my $oid_synoSystemcpuFanStatus = '.1.3.6.1.4.1.6574.1.4.2.0'; +my $oid_synoDisk = '.1.3.6.1.4.1.6574.2.1'; +my $oid_synoDiskdiskStatus = '.1.3.6.1.4.1.6574.2.1.1.5'; + +my $thresholds = { + psu => [ + ['Normal', 'OK'], + ['Failed', 'CRITICAL'], + ], + fan => [ + ['Normal', 'OK'], + ['Failed', 'CRITICAL'], + ], + disk => [ + ['Normal', 'OK'], + ['Initialized', 'OK'], + ['NotInitialized', 'OK'], + ['SystemPartitionFailed', 'CRITICAL'], + ['Crashed', 'CRITICAL'], + ], +}; + +my %map_states_fan = ( + 1 => 'Normal', + 2 => 'Failed', +); + +my %map_states_psu = ( + 1 => 'Normal', + 2 => 'Failed', +); + +my %map_states_disk = ( + 1 => 'Normal', + 2 => 'Initialized', + 3 => 'NotInitialized', + 4 => 'SystemPartitionFailed', + 5 => 'Crashed', +); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "exclude:s" => { name => 'exclude' }, + "component:s" => { name => 'component', default => 'all' }, + "no-component:s" => { name => 'no_component' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); + + $self->{components} = {}; + $self->{no_components} = undef; + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (defined($self->{option_results}->{no_component})) { + if ($self->{option_results}->{no_component} ne '') { + $self->{no_components} = $self->{option_results}->{no_component}; + } else { + $self->{no_components} = 'critical'; + } + } + + $self->{overload_th} = {}; + foreach my $val (@{$self->{option_results}->{threshold_overload}}) { + if ($val !~ /^(.*?),(.*?),(.*)$/) { + $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->option_exit(); + } + my ($section, $status, $filter) = ($1, $2, $3); + if ($self->{output}->is_litteral_status(status => $status) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $self->{output}->option_exit(); + } + $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); + push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; + } + +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + + $self->{results} = $self->{snmp}->get_leef(oids => [$oid_synoSystempowerStatus, $oid_synoSystemcpuFanStatus, $oid_synoSystemsystemFanStatus], + nothing_quit => 1); + + if ($self->{option_results}->{component} eq 'all') { + $self->check_fan_cpu(); + $self->check_fan_psu(); + $self->check_psu(); + $self->check_disk(); + } elsif ($self->{option_results}->{component} eq 'fan_cpu') { + $self->check_fan_cpu(); + } elsif ($self->{option_results}->{component} eq 'fan_psu') { + $self->check_fan_psu(); + } elsif ($self->{option_results}->{component} eq 'psu') { + $self->check_psu(); + } elsif ($self->{option_results}->{component} eq 'disk') { + $self->check_disk(); + } else { + $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); + $self->{output}->option_exit(); + } + + my $total_components = 0; + my $display_by_component = ''; + my $display_by_component_append = ''; + foreach my $comp (sort(keys %{$self->{components}})) { + # Skipping short msg when no components + next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); + $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; + my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; + $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name}; + $display_by_component_append = ', '; + } + + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("All %s components are ok [%s].", + $total_components, + $display_by_component) + ); + + if (defined($self->{option_results}->{no_component}) && $total_components == 0) { + $self->{output}->output_add(severity => $self->{no_components}, + short_msg => 'No components are checked.'); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +sub check_exclude { + my ($self, %options) = @_; + + if (defined($options{instance})) { + if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { + $self->{components}->{$options{section}}->{skip}++; + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); + return 1; + } + } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); + return 1; + } + return 0; +} + +sub get_severity { + my ($self, %options) = @_; + my $status = 'UNKNOWN'; # default + + if (defined($self->{overload_th}->{$options{section}})) { + foreach (@{$self->{overload_th}->{$options{section}}}) { + if ($options{value} =~ /$_->{filter}/i) { + $status = $_->{status}; + return $status; + } + } + } + foreach (@{$thresholds->{$options{section}}}) { + if ($options{value} =~ /$$_[0]/i) { + $status = $$_[1]; + return $status; + } + } + + return $status; +} + +sub check_fan_cpu { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking cpu fan"); + $self->{components}->{cpu_fan} = {name => 'cpu_fan', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'cpu_fan')); + $self->{components}->{cpu_fan}->{total}++; + + my $cpu_fan_state = $self->{results}->{$oid_synoSystemcpuFanStatus}; + $self->{output}->output_add(long_msg => sprintf("CPU Fan state is %s.", + $map_states_fan{$cpu_fan_state})); + my $exit = $self->get_severity(section => 'fan', value => $map_states_fan{$cpu_fan_state}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("CPU Fan state is %s.", $map_states_fan{$cpu_fan_state})); + } +} + +sub check_fan_psu { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking psu fan"); + $self->{components}->{psu_fan} = {name => 'psu_fan', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'psu_fan')); + $self->{components}->{psu_fan}->{total}++; + + my $psu_fan_state = $self->{results}->{$oid_synoSystempowerStatus}; + $self->{output}->output_add(long_msg => sprintf("PSU Fan state is %s.", + $map_states_fan{$psu_fan_state})); + my $exit = $self->get_severity(section => 'fan', value => $map_states_fan{$psu_fan_state}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("PSU Fan state is %s.", $map_states_fan{$psu_fan_state})); + } +} + + +sub check_psu { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power supply"); + $self->{components}->{psu} = {name => 'psu', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'psu')); + $self->{components}->{psu}->{total}++; + + my $psu_state = $self->{results}->{$oid_synoSystempowerStatus}; + $self->{output}->output_add(long_msg => sprintf("Power Supply state is %s.", + $map_states_psu{$psu_state})); + my $exit = $self->get_severity(section => 'psu', value => $map_states_psu{$psu_state}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power Supply state is %s.", $map_states_psu{$psu_state})); + } +} + +sub check_disk { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking disk"); + $self->{components}->{disk} = {name => 'disk', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'disk')); + + + my $results = $self->{snmp}->get_table(oid => $oid_synoDisk, return_type => 1); + + my $instance = 0; + + foreach my $key ($self->{snmp}->oid_lex_sort(keys %$results)) { + next if ($key !~ /^$oid_synoDiskdiskStatus\.(\d+)/); + my $index = $1; + $instance = $1; + my $disk_state = $results->{$oid_synoDiskdiskStatus . '.' . $index}; + + next if ($self->check_exclude(section => 'disk', instance => $instance)); + + $self->{components}->{disk}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Disk '%s' state is %s.", + $index, $map_states_disk{$disk_state})); + my $exit = $self->get_severity(section => 'disk', value => $map_states_disk{$disk_state}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Disk '%s' state is %s.", $index, $map_states_disk{$disk_state})); + } + } +} + + +1; + +__END__ + +=head1 MODE + +Check hardware (SYNOLOGY-SYSTEM-MIB) (Fans, Power Supplies, Disk status). + +=over 8 + +=item B<--component> + +Which component to check (Default: 'all'). +Can be: 'psu', 'fan_cpu', 'fan_psu', 'disk'. + +=item B<--exclude> + +Exclude some parts (comma seperated list) (Example: --exclude=psu) +Can also exclude specific instance: --exclude='psu#1#' + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='psu,CRITICAL,^(?!(on)$)' + +=back + +=cut + diff --git a/storage/synology/mode/raidstatus.pm b/storage/synology/mode/raidstatus.pm new file mode 100644 index 000000000..9489d7886 --- /dev/null +++ b/storage/synology/mode/raidstatus.pm @@ -0,0 +1,152 @@ +################################################################################ +# Copyright 2005-2014 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Mathieu Cinquin +# +#################################################################################### + +package storage::synology::mode::raidstatus; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my $thresholds = { + raid => [ + ['Normal', 'OK'], + ['Repairing', 'OK'], + ['Migrating', 'OK'], + ['Expanding', 'OK'], + ['Deleting', 'OK'], + ['Creating', 'OK'], + ['RaidSyncing', 'OK'], + ['RaidParityChecking', 'OK'], + ['RaidAssembling', 'OK'], + ['Canceling', 'OK'], + ['Degrade', 'WARNING'], + ['Crashed', 'CRITICAL'], + ], +}; + +my %map_states_raid = ( + 1 => 'Normal', + 2 => 'Repairing', + 3 => 'Migrating', + 4 => 'Expanding', + 5 => 'Deleting', + 6 => 'Creating', + 7 => 'RaidSyncing', + 8 => 'RaidParityChecking', + 9 => 'RaidAssembling', + 10 => 'Canceling', + 11 => 'Degrade', + 12 => 'Crashed', +); + + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $oid_synoRaid = '.1.3.6.1.4.1.6574.3.1.1'; + my $oid_synoRaidraidName = '.1.3.6.1.4.1.6574.3.1.1.2'; + my $oid_synoRaidraidStatus = '.1.3.6.1.4.1.6574.3.1.1.3'; + + my $result = $self->{snmp}->get_table(oid => $oid_synoRaid, start => $oid_synoRaidraidName, end => $oid_synoRaidraidStatus, nothing_quit => 1); + + $self->{output}->output_add(severity => 'OK', + short_msg => 'All raid volumes are ok.'); + + foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { + next if ($key !~ /^$oid_synoRaidraidName\.(.*)/); + my $id = $1; + my $raid_name = $result->{$key}; + my $raid_state = $result->{$oid_synoRaidraidStatus . '.' . $id}; + + my $exit = $self->get_severity(section => 'raid', value => $map_states_raid{$raid_state}); + + $self->{output}->output_add(long_msg => sprintf("RAID '%s' status is %s.", $raid_name, $map_states_raid{$raid_state})); + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("RAID '%s' state is %s.", $raid_name, $map_states_raid{$raid_state})); + } + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +sub get_severity { + my ($self, %options) = @_; + my $status = 'UNKNOWN'; # default + + foreach (@{$thresholds->{$options{section}}}) { + if ($options{value} =~ /$$_[0]/i) { + $status = $$_[1]; + return $status; + } + } + + return $status; +} + + +1; + +__END__ + +=head1 MODE + +Check RAID status (SYNOLOGY-RAID-MIB). + +=over 8 + +=back + +=cut diff --git a/storage/synology/mode/systemstatus.pm b/storage/synology/mode/systemstatus.pm new file mode 100644 index 000000000..3a8e0b267 --- /dev/null +++ b/storage/synology/mode/systemstatus.pm @@ -0,0 +1,119 @@ +################################################################################ +# Copyright 2005-2014 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Mathieu Cinquin +# +#################################################################################### + +package storage::synology::mode::systemstatus; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my $thresholds = { + system => [ + ['Normal', 'OK'], + ['Failed', 'CRITICAL'], + ], +}; + +my %map_states_system = ( + 1 => 'Normal', + 2 => 'Failed', +); + + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $oid_synoSystemsystemStatus = '.1.3.6.1.4.1.6574.1.1.0'; # in Celsius + + my $result = $self->{snmp}->get_leef(oids => [$oid_synoSystemsystemStatus], + nothing_quit => 1); + my $system_state = $result->{$oid_synoSystemsystemStatus}; + + my $exit = $self->get_severity(section => 'system', value => $map_states_system{$system_state}); + + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("System status is %s", $map_states_system{$system_state})); + + + $self->{output}->display(); + $self->{output}->exit(); +} + +sub get_severity { + my ($self, %options) = @_; + my $status = 'UNKNOWN'; # default + + foreach (@{$thresholds->{$options{section}}}) { + if ($options{value} =~ /$$_[0]/i) { + $status = $$_[1]; + return $status; + } + } + + return $status; +} + + +1; + +__END__ + +=head1 MODE + +Check system status (SYNOLOGY-SYSTEM-MIB). + +=over 8 + +=back + +=cut diff --git a/storage/synology/mode/temperature.pm b/storage/synology/mode/temperature.pm new file mode 100644 index 000000000..ae645e752 --- /dev/null +++ b/storage/synology/mode/temperature.pm @@ -0,0 +1,119 @@ +################################################################################ +# Copyright 2005-2014 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Mathieu Cinquin +# +#################################################################################### + +package storage::synology::mode::temperature; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use Data::Dumper; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $oid_synoSystemtemperature = '.1.3.6.1.4.1.6574.1.2.0'; # in Celsius + + my $result = $self->{snmp}->get_leef(oids => [$oid_synoSystemtemperature], + nothing_quit => 1); + my $temp = $result->{$oid_synoSystemtemperature}; + + my $exit = $self->{perfdata}->threshold_check(value => $temp, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Device Temperature is %d C degrees", + $temp)); + + $self->{output}->perfdata_add(label => "temperature", unit => 'C', + value => $temp, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + ); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check temperature (SYNOLOGY-SYSTEM-MIB). + +=over 8 + +=item B<--warning> + +Threshold warning in celsius degrees. + +=item B<--critical> + +Threshold critical in celsius degrees. + +=back + +=cut diff --git a/storage/synology/mode/ups.pm b/storage/synology/mode/ups.pm new file mode 100644 index 000000000..f85f424c0 --- /dev/null +++ b/storage/synology/mode/ups.pm @@ -0,0 +1,119 @@ +################################################################################ +# Copyright 2005-2014 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Mathieu Cinquin +# +#################################################################################### + +package storage::synology::mode::ups; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use Data::Dumper; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $oid_synoUPSupsBatteryRuntimeValue = '.1.3.6.1.4.1.6574.4.3.6.1.0'; # in Seconds + + my $result = $self->{snmp}->get_leef(oids => [$oid_synoUPSupsBatteryRuntimeValue], + nothing_quit => 1); + my $time = $result->{$oid_synoUPSupsBatteryRuntimeValue}; + + my $exit = $self->{perfdata}->threshold_check(value => $time, threshold => [ { label => 'warning', 'exit_litteral' => 'warning' }, { label => 'critical', exit_litteral => 'critical' } ]); + + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Estimated Battery Life is %d seconds", + $time)); + + $self->{output}->perfdata_add(label => "time", unit => 's', + value => $time, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + ); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check UPS (SYNOLOGY-UPS-MIB). + +=over 8 + +=item B<--warning> + +Threshold warning in seconds. + +=item B<--critical> + +Threshold critical in seconds. + +=back + +=cut diff --git a/storage/synology/plugin.pm b/storage/synology/plugin.pm new file mode 100644 index 000000000..fbc64d526 --- /dev/null +++ b/storage/synology/plugin.pm @@ -0,0 +1,72 @@ +################################################################################ +# Copyright 2005-2014 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Mathieu Cinquin +# +#################################################################################### + +package storage::synology::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + # $options->{options} = options object + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'hardware' => 'storage::synology::mode::hardware', + 'temperature' => 'storage::synology::mode::temperature', + 'raidstatus' => 'storage::synology::mode::raidstatus', + 'systemstatus' => 'storage::synology::mode::systemstatus', + 'traffic' => 'snmp_standard::mode::traffic', + 'cpu' => 'snmp_standard::mode::cpu', + 'memory' => 'snmp_standard::mode::memory', + 'load' => 'snmp_standard::mode::load', + 'diskusage' => 'snmp_standard::mode::diskusage', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Synology devices in SNMP. + +=cut