Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
Directory
rhousand
byrhousand, March 31, 2014
Script errored due to empty $minutessincestart:
sub nagios {
my $self = shift;
my %params = @_;
if (! $self->{nagios_level}) {
if ($params{mode} =~ /server::jobs::failed/) {
if ($self->{lastrunstatus} ne "succeeded") {
if ($self->{lastrunstatus} eq "failed") {
$self->add_nagios_critical(
sprintf "%s failed: %s", $self->{name}, $self->{lastrunstatusmessage});
} elsif ($self->{lastrunstatus} eq "retry" || $self->{lastrunstatus} eq "canceled") {
$self->add_nagios_warning(
sprintf "%s %s: %s", $self->{name}, $self->{lastrunstatus}, $self->{lastrunstatusmessage});
} else {
if ($self->{lastrunstatus}) {
print "else: $params{mode} $self->{name} $self->{lastrunstatus}
";
$self->add_nagios(
$self->check_thresholds($self->{lastrundurationseconds}, 60, 300),
#sprintf("job %s ran for %d seconds (started %s)
", $self->{name},
sprintf("job %s ran for %d seconds (started %s)", $self->{name},
$self->{lastrundurationseconds}, $self->{lastrundatetime}));
}
}
} else {
print "OK - $self->{name}, $self->{lastrundurationseconds}, $self->{lastrundatetime}
";
}
}
}
}
Script alerted if lastrunstatus was not set:
sub nagios {
my $self = shift;
my %params = @_;
if (! $self->{nagios_level}) {
if ($params{mode} =~ /server::jobs::failed/) {
if ($self->{lastrunstatus} ne "succeeded") {
if ($self->{lastrunstatus} eq "failed") {
$self->add_nagios_critical(
sprintf "%s failed: %s", $self->{name}, $self->{lastrunstatusmessage});
} elsif ($self->{lastrunstatus} eq "retry" || $self->{lastrunstatus} eq "canceled") {
$self->add_nagios_warning(
sprintf "%s %s: %s", $self->{name}, $self->{lastrunstatus}, $self->{lastrunstatusmessage});
} else {
if ($self->{lastrunstatus}) {
print "else: $params{mode} $self->{name} $self->{lastrunstatus}
";
$self->add_nagios(
$self->check_thresholds($self->{lastrundurationseconds}, 60, 300),
#sprintf("job %s ran for %d seconds (started %s)
", $self->{name},
sprintf("job %s ran for %d seconds (started %s)", $self->{name},
$self->{lastrundurationseconds}, $self->{lastrundatetime}));
}
}
} else {
print "OK - $self->{name}, $self->{lastrundurationseconds}, $self->{lastrundatetime}
";
}
}
}
}
sub nagios {
my $self = shift;
my %params = @_;
if (! $self->{nagios_level}) {
if ($params{mode} =~ /server::jobs::failed/) {
if ($self->{lastrunstatus} ne "succeeded") {
if ($self->{lastrunstatus} eq "failed") {
$self->add_nagios_critical(
sprintf "%s failed: %s", $self->{name}, $self->{lastrunstatusmessage});
} elsif ($self->{lastrunstatus} eq "retry" || $self->{lastrunstatus} eq "canceled") {
$self->add_nagios_warning(
sprintf "%s %s: %s", $self->{name}, $self->{lastrunstatus}, $self->{lastrunstatusmessage});
} else {
if ($self->{lastrunstatus}) {
print "else: $params{mode} $self->{name} $self->{lastrunstatus}
";
$self->add_nagios(
$self->check_thresholds($self->{lastrundurationseconds}, 60, 300),
#sprintf("job %s ran for %d seconds (started %s)
", $self->{name},
sprintf("job %s ran for %d seconds (started %s)", $self->{name},
$self->{lastrundurationseconds}, $self->{lastrundatetime}));
}
}
} else {
print "OK - $self->{name}, $self->{lastrundurationseconds}, $self->{lastrundatetime}
";
}
}
}
}
Script alerted if lastrunstatus was not set:
sub nagios {
my $self = shift;
my %params = @_;
if (! $self->{nagios_level}) {
if ($params{mode} =~ /server::jobs::failed/) {
if ($self->{lastrunstatus} ne "succeeded") {
if ($self->{lastrunstatus} eq "failed") {
$self->add_nagios_critical(
sprintf "%s failed: %s", $self->{name}, $self->{lastrunstatusmessage});
} elsif ($self->{lastrunstatus} eq "retry" || $self->{lastrunstatus} eq "canceled") {
$self->add_nagios_warning(
sprintf "%s %s: %s", $self->{name}, $self->{lastrunstatus}, $self->{lastrunstatusmessage});
} else {
if ($self->{lastrunstatus}) {
print "else: $params{mode} $self->{name} $self->{lastrunstatus}
";
$self->add_nagios(
$self->check_thresholds($self->{lastrundurationseconds}, 60, 300),
#sprintf("job %s ran for %d seconds (started %s)
", $self->{name},
sprintf("job %s ran for %d seconds (started %s)", $self->{name},
$self->{lastrundurationseconds}, $self->{lastrundatetime}));
}
}
} else {
print "OK - $self->{name}, $self->{lastrundurationseconds}, $self->{lastrundatetime}
";
}
}
}
}
byrhousand, July 19, 2013
Added $TABLE
CHKIPTBLS=`/sbin/iptables -n -t $TABLE -L |wc -l`
Added nrpe user to sudoers
Defaults!/usr/local/nagios/libexec/check_iptables.sh !requiretty
nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_iptables.sh
I would not recommend adding to following to sudoers.
nagios ALL= NOPASSWD: /sbin/iptables
I also imported utils.sh and used it's exit codes but this may not be required.
. /usr/local/nagios/libexec/utils.sh
exit $STATE_OK
exit $STATE_CRITICAL
CHKIPTBLS=`/sbin/iptables -n -t $TABLE -L |wc -l`
Added nrpe user to sudoers
Defaults!/usr/local/nagios/libexec/check_iptables.sh !requiretty
nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_iptables.sh
I would not recommend adding to following to sudoers.
nagios ALL= NOPASSWD: /sbin/iptables
I also imported utils.sh and used it's exit codes but this may not be required.
. /usr/local/nagios/libexec/utils.sh
exit $STATE_OK
exit $STATE_CRITICAL