This commit is contained in:
Florian Asche 2014-03-20 10:14:45 +01:00
parent 6cb4b00c9d
commit 1654b1e045
10 changed files with 1346 additions and 0 deletions

View File

@ -0,0 +1,143 @@
###############################################################################
# Copyright 2005-2013 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 <http://www.gnu.org/licenses>.
#
# 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 timeelapsedutable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting timeelapsedutable 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 : Florian Asche <info@florian-asche.de>
#
####################################################################################
package apps::apcupsd::local::mode::batterycharge;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
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 =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'BCHARGE' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
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) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
unit => "",
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 apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=back
=cut

View File

@ -0,0 +1,143 @@
###############################################################################
# Copyright 2005-2013 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 <http://www.gnu.org/licenses>.
#
# 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 timeelapsedutable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting timeelapsedutable 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 : Florian Asche <info@florian-asche.de>
#
####################################################################################
package apps::apcupsd::local::mode::batteryvoltage;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
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 =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'BATTV' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
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) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
unit => "",
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 apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=back
=cut

View File

@ -0,0 +1,78 @@
################################################################################
# Copyright 2005-2013 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 <http://www.gnu.org/licenses>.
#
# 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 : Florian Asche <info@florian-asche.de>
#
####################################################################################
package apps::apcupsd::local::mode::libgetdata;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
sub getdata {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{apchost} . ":" . $self->{option_results}->{apcport} . $self->{option_results}->{command_options2});
my $searchpattern = $self->{option_results}->{searchpattern};
my ($valueok);
my ($value);
#print $stdout;
foreach (split(/\n/, $stdout)) {
if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds)/i) {
$valueok = "1";
$value = $1;
#print $value;
#print "\n";
};
};
if ($valueok == "1") {
#print $value;
return $value;
} else {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => 'NO DATA FOUND');
$self->{output}->display();
$self->{output}->exit();
};
};
1;

View File

@ -0,0 +1,143 @@
###############################################################################
# Copyright 2005-2013 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 <http://www.gnu.org/licenses>.
#
# 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 timeelapsedutable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting timeelapsedutable 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 : Florian Asche <info@florian-asche.de>
#
####################################################################################
package apps::apcupsd::local::mode::linefrequency;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
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 =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'LINEFREQ' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
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) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
unit => "",
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 apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=back
=cut

View File

@ -0,0 +1,143 @@
###############################################################################
# Copyright 2005-2013 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 <http://www.gnu.org/licenses>.
#
# 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 timeelapsedutable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting timeelapsedutable 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 : Florian Asche <info@florian-asche.de>
#
####################################################################################
package apps::apcupsd::local::mode::linevoltage;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
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 =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'LINEV' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
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) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
unit => "",
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 apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=back
=cut

View File

@ -0,0 +1,143 @@
###############################################################################
# Copyright 2005-2013 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 <http://www.gnu.org/licenses>.
#
# 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 timeelapsedutable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting timeelapsedutable 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 : Florian Asche <info@florian-asche.de>
#
####################################################################################
package apps::apcupsd::local::mode::loadpercentage;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
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 =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'LOADPCT' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
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) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
unit => "",
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 apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=back
=cut

View File

@ -0,0 +1,143 @@
###############################################################################
# Copyright 2005-2013 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 <http://www.gnu.org/licenses>.
#
# 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 timeelapsedutable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting timeelapsedutable 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 : Florian Asche <info@florian-asche.de>
#
####################################################################################
package apps::apcupsd::local::mode::outputvoltage;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
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 =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'OUTPUTV' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
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) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
unit => "",
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 apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=back
=cut

View File

@ -0,0 +1,143 @@
###############################################################################
# Copyright 2005-2013 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 <http://www.gnu.org/licenses>.
#
# 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 timeelapsedutable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting timeelapsedutable 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 : Florian Asche <info@florian-asche.de>
#
####################################################################################
package apps::apcupsd::local::mode::temperatur;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
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 =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'ITEMP' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
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) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
unit => "",
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 apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=back
=cut

View File

@ -0,0 +1,143 @@
###############################################################################
# Copyright 2005-2013 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 <http://www.gnu.org/licenses>.
#
# 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 timeelapsedutable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting timeelapsedutable 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 : Florian Asche <info@florian-asche.de>
#
####################################################################################
package apps::apcupsd::local::mode::timeleft;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
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 =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'TIMELEFT' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
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) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
unit => "",
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 apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=back
=cut

View File

@ -0,0 +1,124 @@
################################################################################
# Copyright 2005-2013 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 <http://www.gnu.org/licenses>.
#
# 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 : Florian Asche <info@florian-asche.de>
#
####################################################################################
#
# see http://manned.org/apcaccess
#
#sprung:~# apcaccess #
#APC : 001,048,1163 # version, number of records and number of bytes following
#DATE : 2014-03-15 19:30:58 +0100 # Date and time of last update from UPS
#HOSTNAME : sprung # hostname of computer running apcupsd
#VERSION : 3.14.8 (16 January 2010) debian # apcupsd version number, date and operating system
#UPSNAME : APC_ESX_SERVER # UPS name from configuration file (dumb) or EEPROM (smart)
#CABLE : Custom Cable Smart # Cable type specified in the configuration file
#MODEL : Smart-UPS 620 # UPS model derived from UPS information
#UPSMODE : ShareUPS Master # Mode in which UPS is operating
#STARTTIME: 2014-03-13 22:40:39 +0100 # Date and time apcupsd was started
#STATUS : ONLINE # UPS status (online, charging, on battery etc)
#LINEV : 224.6 Volts # Current input line voltage
#LOADPCT : 58.5 Percent Load Capacity # Percentage of UPS load capacity used as estimated by UPS
#BCHARGE : 100.0 Percent # Current battery capacity charge percentage
#TIMELEFT : 11.0 Minutes # Remaining runtime left on battery as estimated by UPS
#MBATTCHG : 10 Percent # Min battery charge % (BCHARGE) required for system shutdown
#MINTIMEL : 4 Minutes # Min battery runtime (MINUTES) required for system shutdown
#MAXTIME : 0 Seconds # Max battery runtime (TIMEOUT) after which system is shutdown
#MAXLINEV : 227.5 Volts # Maximum input line voltage since apcupsd startup
#MINLINEV : 224.6 Volts # Minimum input line voltage since apcupsd startup
#OUTPUTV : 227.5 Volts # UPS output voltage
#SENSE : High # Current UPS sensitivity setting for voltage fluctuations
#DWAKE : 060 Seconds # Time UPS waits after power off when the power is restored
#DSHUTD : 600 Seconds # Delay before UPS powers down after command received
#DLOWBATT : 02 Minutes # Low battery signal sent when this much runtime remains
#LOTRANS : 208.0 Volts # Input line voltage below which UPS will switch to battery
#HITRANS : 253.0 Volts # Input line voltage above which UPS will switch to battery
#RETPCT : 015.0 Percent # Battery charge % required after power off to restore power
#ALARMDEL : 30 seconds # Delay period before UPS starts sounding alarm
#BATTV : 13.8 Volts # Current battery voltage
#LINEFREQ : 50.0 Hz # Current line frequency in Hertz
#LASTXFER : No transfers since turnon # Reason for last transfer to battery since apcupsd startup
#NUMXFERS : 0 # Number of transfers to battery since apcupsd startup
#TONBATT : 0 seconds # Seconds currently on battery
#CUMONBATT: 0 seconds # Cumulative seconds on battery since apcupsd startup
#XOFFBATT : N/A # Date, time of last transfer off battery since apcupsd startup
#SELFTEST : NO # Date and time of last self test since apcupsd startup
#STESTI : OFF # Self-test interval
#STATFLAG : 0x07000008 Status Flag # UPS status flag in hex
#REG1 : 0x00 Register 1 # Fault register 1 in hex
#REG2 : 0x00 Register 2 # Fault register 2 in hex
#REG3 : 0x00 Register 3 # Fault register 3 in hex
#MANDATE : 08/09/01 # UPS date of manufacture
#SERIALNO : NS0132263041 # UPS serial number
#BATTDATE : 11/01/08 # Date battery last replaced (if set)
#NOMOUTV : 230 Volts # Nominal output voltage to supply when on battery power
#NOMBATTV : 12.0 Volts # Nominal battery voltage
#FIRMWARE : 22.6.I # UPS firmware version
#APCMODEL : CWI # APC model information
#END APC : 2014-03-15 19:31:00 +0100 # Date and time of status information was written
package apps::apcupsd::local::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_simple);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
# $options->{options} = options object
$self->{version} = '0.1';
%{$self->{modes}} = (
'batterycharge' => 'apps::apcupsd::local::mode::batterycharge', # BCHARGE
'temperatur' => 'apps::apcupsd::local::mode::temperatur', # ITEMP
'timeleft' => 'apps::apcupsd::local::mode::timeleft', # TIMELEFT MAXTIME MINTIMEL
'linevoltage' => 'apps::apcupsd::local::mode::linevoltage', # LINEV
'batteryvoltage' => 'apps::apcupsd::local::mode::batteryvoltage', # BATTV
'outputvoltage' => 'apps::apcupsd::local::mode::outputvoltage', # OUTPUTV
'linefrequency' => 'apps::apcupsd::local::mode::linefrequency', # LINEFREQ
'loadpercentage' => 'apps::apcupsd::local::mode::loadpercentage', # LOADPCT
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check apcupsd through local commands (the plugin can use SSH).
=cut