diff options
31 files changed, 1176 insertions, 183 deletions
@@ -17,6 +17,11 @@ puppetmaster. You need to be running verison 0.25 or later of puppet. +! Upgrade Notice ! + + * the irc bot variables changed, they previously had $nagios_ prepended + but no longer have that. So you will need to change your local config + to use $nsa_server instead of $nagios_nsa_server, for example. Monitor ------- @@ -51,9 +56,9 @@ Services Services can be monitored by using the "nagios::service" component. -The simplest form is:: +The simplest form is: - nagios::service { 'check_http': + nagios::service { 'check_http': check_command => 'http_port!80', } @@ -65,6 +70,16 @@ Obviously, the check command must either be defined using nagios_command objects (some are supplied in nagios::defaults::commands) or in the nagios configuration files directly. +NRPE Services +------------- + +NRPE Services can be defines as i.e.: + + nagios::service { 'CPU Usage': use_nrpe => 'true', + check_command => "check_cpu", + nrpe_args => "-t 60" + } + Upgrade Notes ============= @@ -91,7 +106,7 @@ IRC bot Notifications can easily be sent to an IRC channel by using a bot. To do so, simply include 'nagios::irc_bot' on the nagios server and define the right -$nagios_nsa_* variables (see the 'Variables' section below). +$nsa_* variables (see the 'Variables' section below). You can then use the notification commands 'notify-by-irc' and 'host-notify-by-irc' with service and host definitions to make them report @@ -165,6 +180,16 @@ For the irc_bot class: - nsa_realname: The IRC bot user's real name that will be displayed. By default, the real name is 'Nagios'. +- nsa_usenotices: The IRC bot will by default "say" to the channel the + nagios message, but you can switch this variable to + 'notice' if you would prefer them to be sent as IRC + NOTICE messages. + +PNP4Nagios Nagios Grapher integration +===================================== + +see README.pnp4nagios + Examples ======== diff --git a/files/configs/cgi.cfg b/files/configs/cgi.cfg new file mode 120000 index 0000000..db9667b --- /dev/null +++ b/files/configs/cgi.cfg @@ -0,0 +1 @@ +Debian/cgi.cfg
\ No newline at end of file diff --git a/files/configs/nagios.cfg b/files/configs/nagios.cfg new file mode 120000 index 0000000..1409b9e --- /dev/null +++ b/files/configs/nagios.cfg @@ -0,0 +1 @@ +Debian/nagios.cfg
\ No newline at end of file diff --git a/files/irc_bot/riseup-nagios-server.pl b/files/irc_bot/riseup-nagios-server.pl index 7880dde..7180758 100644 --- a/files/irc_bot/riseup-nagios-server.pl +++ b/files/irc_bot/riseup-nagios-server.pl @@ -101,7 +101,11 @@ sub socket_has_data { my $self = shift; $self->{socket}->recv(my $data, 1024); - $self->{conn}->privmsg($CFG::Nsa{'channel'}, $data); + if ($CFG::Nsa{'usenotices'}) { + $self->{conn}->notice($CFG::Nsa{'channel'}, $data); + } else { + $self->{conn}->privmsg($CFG::Nsa{'channel'}, $data); + } } sub irc_on_connect { diff --git a/files/nrpe/nrpe_commands.cfg b/files/nrpe/nrpe_commands.cfg new file mode 100644 index 0000000..b725a36 --- /dev/null +++ b/files/nrpe/nrpe_commands.cfg @@ -0,0 +1,5 @@ +# default plugins +command[check_users]=/usr/lib/nagios/plugins/check_users $ARG1$ +command[check_disk]=/usr/lib/nagios/plugins/check_disk $ARG1$ -x "/dev" -x "/dev/shm" -x "/lib/init/rw" +command[check_apt]=sudo /usr/lib/nagios/plugins/check_apt -u $ARG1$ +command[check_swap]=/usr/lib/nagios/plugins/check_swap $ARG1$ diff --git a/files/nsca/nsca.cfg b/files/nsca/nsca.cfg index 238869f..0b019ea 100644 --- a/files/nsca/nsca.cfg +++ b/files/nsca/nsca.cfg @@ -21,7 +21,7 @@ pid_file=/var/run/nsca.pid # Port number we should wait for connections on. # This must be a non-priveledged port (i.e. > 1024). -server_port=5677 +server_port=5667 @@ -79,10 +79,15 @@ debug=0 # COMMAND FILE # This is the location of the Nagios command file that the daemon # should write all service check results that it receives. - +# Note to debian users: nagios 1.x and nagios 2.x have +# different default locations for this file. this is the +# default location for nagios 1.x: +#command_file=/var/run/nagios/nagios.cmd +# and this is the default location for nagios2: +#command_file=/var/lib/nagios2/rw/nagios.cmd +# and this is the default location for nagios3: command_file=/var/lib/nagios3/rw/nagios.cmd - # ALTERNATE DUMP FILE # This is used to specify an alternate file the daemon should # write service check results to in the event the command file @@ -96,7 +101,6 @@ command_file=/var/lib/nagios3/rw/nagios.cmd alternate_dump_file=/var/run/nagios/nsca.dump - # AGGREGATED WRITES OPTION # This option determines whether or not the nsca daemon will # aggregate writes to the external command file for client diff --git a/files/plugins/check_mysql_health b/files/plugins/check_mysql_health index f0599f2..9292ae0 100755 --- a/files/plugins/check_mysql_health +++ b/files/plugins/check_mysql_health @@ -61,6 +61,7 @@ sub new { bufferpool_hitrate => undef, wait_free => undef, log_waits => undef, + have_innodb => undef, warningrange => $params{warningrange}, criticalrange => $params{criticalrange}, }; @@ -76,7 +77,15 @@ sub init { my $dummy; $self->debug("enter init"); $self->init_nagios(); - if ($params{mode} =~ /server::instance::innodb::bufferpool::hitrate/) { + ($dummy, $self->{have_innodb}) + = $self->{handle}->fetchrow_array(q{ + SHOW VARIABLES LIKE 'have_innodb' + }); + if ($self->{have_innodb} eq "NO") { + $self->add_nagios_critical("the innodb engine has a problem (have_innodb=no)"); + } elsif ($self->{have_innodb} eq "DISABLED") { + # add_nagios_ok later + } elsif ($params{mode} =~ /server::instance::innodb::bufferpool::hitrate/) { ($dummy, $self->{bufferpool_reads}) = $self->{handle}->fetchrow_array(q{ SHOW /*!50000 global */ STATUS LIKE 'Innodb_buffer_pool_reads' @@ -123,6 +132,15 @@ sub init { $self->{log_waits_rate} = $self->{delta_log_waits} / $self->{delta_timestamp}; } + } elsif ($params{mode} =~ /server::instance::innodb::needoptimize/) { +#fragmentation=$(($datafree * 100 / $datalength)) + +#http://www.electrictoolbox.com/optimize-tables-mysql-php/ + my @result = $self->{handle}->fetchall_array(q{ +SHOW TABLE STATUS WHERE Data_free / Data_length > 0.1 AND Data_free > 102400 +}); +printf "%s\n", Data::Dumper::Dumper(\@result); + } } @@ -130,7 +148,9 @@ sub nagios { my $self = shift; my %params = @_; my $now = $params{lookback} ? '_now' : ''; - if (! $self->{nagios_level}) { + if ($self->{have_innodb} eq "DISABLED") { + $self->add_nagios_ok("the innodb engine has been disabled"); + } elsif (! $self->{nagios_level}) { if ($params{mode} =~ /server::instance::innodb::bufferpool::hitrate/) { my $refkey = 'bufferpool_hitrate'.($params{lookback} ? '_now' : ''); $self->add_nagios( @@ -468,6 +488,35 @@ sub init { ($dummy, $self->{threads_connected}) = $self->{handle}->fetchrow_array(q{ SHOW /*!50000 global */ STATUS LIKE 'Threads_connected' }); + } elsif ($params{mode} =~ /server::instance::createdthreads/) { + ($dummy, $self->{threads_created}) = $self->{handle}->fetchrow_array(q{ + SHOW /*!50000 global */ STATUS LIKE 'Threads_created' + }); + $self->valdiff(\%params, qw(threads_created)); + $self->{threads_created_per_sec} = $self->{delta_threads_created} / + $self->{delta_timestamp}; + } elsif ($params{mode} =~ /server::instance::runningthreads/) { + ($dummy, $self->{threads_running}) = $self->{handle}->fetchrow_array(q{ + SHOW /*!50000 global */ STATUS LIKE 'Threads_running' + }); + } elsif ($params{mode} =~ /server::instance::cachedthreads/) { + ($dummy, $self->{threads_cached}) = $self->{handle}->fetchrow_array(q{ + SHOW /*!50000 global */ STATUS LIKE 'Threads_cached' + }); + } elsif ($params{mode} =~ /server::instance::abortedconnects/) { + ($dummy, $self->{connects_aborted}) = $self->{handle}->fetchrow_array(q{ + SHOW /*!50000 global */ STATUS LIKE 'Aborted_connects' + }); + $self->valdiff(\%params, qw(connects_aborted)); + $self->{connects_aborted_per_sec} = $self->{delta_connects_aborted} / + $self->{delta_timestamp}; + } elsif ($params{mode} =~ /server::instance::abortedclients/) { + ($dummy, $self->{clients_aborted}) = $self->{handle}->fetchrow_array(q{ + SHOW /*!50000 global */ STATUS LIKE 'Aborted_clients' + }); + $self->valdiff(\%params, qw(clients_aborted)); + $self->{clients_aborted_per_sec} = $self->{delta_clients_aborted} / + $self->{delta_timestamp}; } elsif ($params{mode} =~ /server::instance::threadcachehitrate/) { ($dummy, $self->{threads_created}) = $self->{handle}->fetchrow_array(q{ SHOW /*!50000 global */ STATUS LIKE 'Threads_created' @@ -629,22 +678,26 @@ sub init { $self->valdiff(\%params, qw(handler_read_first handler_read_key handler_read_next handler_read_prev handler_read_rnd handler_read_rnd_next)); - $self->{index_usage_now} = 100 - (100.0 * ($self->{delta_handler_read_rnd} + - $self->{delta_handler_read_rnd_next}) / - ($self->{delta_handler_read_first} + - $self->{delta_handler_read_key} + + my $delta_reads = $self->{delta_handler_read_first} + + $self->{delta_handler_read_key} + $self->{delta_handler_read_next} + - $self->{delta_handler_read_prev} + - $self->{delta_handler_read_rnd} + - $self->{delta_handler_read_rnd_next})); - $self->{index_usage} = 100 - (100.0 * ($self->{handler_read_rnd} + - $self->{handler_read_rnd_next}) / - ($self->{handler_read_first} + - $self->{handler_read_key} + + $self->{delta_handler_read_prev} + + $self->{delta_handler_read_rnd} + + $self->{delta_handler_read_rnd_next}; + my $reads = $self->{handler_read_first} + + $self->{handler_read_key} + $self->{handler_read_next} + - $self->{handler_read_prev} + - $self->{handler_read_rnd} + - $self->{handler_read_rnd_next})); + $self->{handler_read_prev} + + $self->{handler_read_rnd} + + $self->{handler_read_rnd_next}; + $self->{index_usage_now} = ($delta_reads == 0) ? 0 : + 100 - (100.0 * ($self->{delta_handler_read_rnd} + + $self->{delta_handler_read_rnd_next}) / + $delta_reads); + $self->{index_usage} = ($reads == 0) ? 0 : + 100 - (100.0 * ($self->{handler_read_rnd} + + $self->{handler_read_rnd_next}) / + $reads); } elsif ($params{mode} =~ /server::instance::tabletmpondisk/) { ($dummy, $self->{created_tmp_tables}) = $self->{handle}->fetchrow_array(q{ SHOW /*!50000 global */ STATUS LIKE 'Created_tmp_tables' @@ -667,6 +720,20 @@ sub init { SHOW /*!50000 global */ STATUS LIKE 'Open_files' }); $self->{pct_open_files} = 100 * $self->{open_files} / $self->{open_files_limit}; + } elsif ($params{mode} =~ /server::instance::needoptimize/) { + $self->{fragmented} = []; + #http://www.electrictoolbox.com/optimize-tables-mysql-php/ + my @result = $self->{handle}->fetchall_array(q{ + SHOW TABLE STATUS + }); + foreach (@result) { + my ($name, $engine, $data_length, $data_free) = + ($_->[0], $_->[1], $_->[6 ], $_->[9]); + next if ($params{name} && $params{name} ne $name); + my $fragmentation = $data_length ? $data_free * 100 / $data_length : 0; + push(@{$self->{fragmented}}, + [$name, $fragmentation, $data_length, $data_free]); + } } elsif ($params{mode} =~ /server::instance::myisam/) { $self->{engine_myisam} = DBD::MySQL::Server::Instance::MyISAM->new( %params @@ -693,6 +760,41 @@ sub nagios { $self->add_perfdata(sprintf "threads_connected=%d;%d;%d", $self->{threads_connected}, $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::instance::createdthreads/) { + $self->add_nagios( + $self->check_thresholds($self->{threads_created_per_sec}, 10, 20), + sprintf "%.2f threads created/sec", $self->{threads_created_per_sec}); + $self->add_perfdata(sprintf "threads_created_per_sec=%.2f;%.2f;%.2f", + $self->{threads_created_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::instance::runningthreads/) { + $self->add_nagios( + $self->check_thresholds($self->{threads_running}, 10, 20), + sprintf "%d running threads", $self->{threads_running}); + $self->add_perfdata(sprintf "threads_running=%d;%d;%d", + $self->{threads_running}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::instance::cachedthreads/) { + $self->add_nagios( + $self->check_thresholds($self->{threads_cached}, 10, 20), + sprintf "%d cached threads", $self->{threads_cached}); + $self->add_perfdata(sprintf "threads_cached=%d;%d;%d", + $self->{threads_cached}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::instance::abortedconnects/) { + $self->add_nagios( + $self->check_thresholds($self->{connects_aborted_per_sec}, 1, 5), + sprintf "%.2f aborted connections/sec", $self->{connects_aborted_per_sec}); + $self->add_perfdata(sprintf "connects_aborted_per_sec=%.2f;%.2f;%.2f", + $self->{connects_aborted_per_sec}, + $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /server::instance::abortedclients/) { + $self->add_nagios( + $self->check_thresholds($self->{clients_aborted_per_sec}, 1, 5), + sprintf "%.2f aborted (client died) connections/sec", $self->{clients_aborted_per_sec}); + $self->add_perfdata(sprintf "clients_aborted_per_sec=%.2f;%.2f;%.2f", + $self->{clients_aborted_per_sec}, + $self->{warningrange}, $self->{criticalrange}); } elsif ($params{mode} =~ /server::instance::threadcachehitrate/) { my $refkey = 'threadcache_hitrate'.($params{lookback} ? '_now' : ''); $self->add_nagios( @@ -776,7 +878,7 @@ sub nagios { $self->check_thresholds($self->{$refkey}, "1", "2"); $self->add_nagios_ok( sprintf "table lock contention %.2f%% (uptime < 10800)", - $self->{refkey}); + $self->{$refkey}); } $self->add_perfdata(sprintf "tablelock_contention=%.2f%%;%s;%s", $self->{table_lock_contention}, @@ -818,6 +920,16 @@ sub nagios { $self->{open_files}, $self->{open_files_limit} * $self->{warningrange} / 100, $self->{open_files_limit} * $self->{criticalrange} / 100); + } elsif ($params{mode} =~ /server::instance::needoptimize/) { + foreach (@{$self->{fragmented}}) { + $self->add_nagios( + $self->check_thresholds($_->[1], 10, 25), + sprintf "table %s is %.2f%% fragmented", $_->[0], $_->[1]); + if ($params{name}) { + $self->add_perfdata(sprintf "'%s_frag'=%.2f%%;%d;%d", + $_->[0], $_->[1], $self->{warningrange}, $self->{criticalrange}); + } + } } elsif ($params{mode} =~ /server::instance::myisam/) { $self->{engine_myisam}->nagios(%params); $self->merge_nagios($self->{engine_myisam}); @@ -879,6 +991,9 @@ sub new { timeout => $params{timeout}, warningrange => $params{warningrange}, criticalrange => $params{criticalrange}, + verbose => $params{verbose}, + report => $params{report}, + labelformat => $params{labelformat}, version => 'unknown', instance => undef, handle => undef, @@ -905,17 +1020,36 @@ sub init { my %params = @_; $params{handle} = $self->{handle}; $params{uptime} = $self->{uptime}; + $self->set_global_db_thresholds(\%params); if ($params{mode} =~ /^server::instance/) { $self->{instance} = DBD::MySQL::Server::Instance->new(%params); } elsif ($params{mode} =~ /^server::sql/) { - $self->{genericsql} = $self->{handle}->fetchrow_array($params{selectname}); - if ($self->{genericsql} =~ /^\s*\d+\s*$/) { - $self->{genericsql} = sprintf "%d", $self->{genericsql}; - } elsif ($self->{genericsql} =~ /^\s*\d*\.\d+\s*$/) { - $self->{genericsql} = sprintf "%.2f", $self->{genericsql}; + $self->set_local_db_thresholds(%params); + if ($params{regexp}) { + # sql output is treated as text + if ($params{name2} eq $params{name}) { + $self->add_nagios_unknown(sprintf "where's the regexp????"); + } else { + $self->{genericsql} = + $self->{handle}->fetchrow_array($params{selectname}); + if (! defined $self->{genericsql}) { + $self->add_nagios_unknown(sprintf "got no valid response for %s", + $params{selectname}); + } + } } else { - $self->add_nagios_unknown(sprintf "got no valid response for %s", - $params{selectname}); + # sql output must be a number (or array of numbers) + @{$self->{genericsql}} = + $self->{handle}->fetchrow_array($params{selectname}); + if (! (defined $self->{genericsql} && + (scalar(grep { /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/ } @{$self->{genericsql}})) == + scalar(@{$self->{genericsql}}))) { + $self->add_nagios_unknown(sprintf "got no valid response for %s", + $params{selectname}); + } else { + # name2 in array + # units in array + } } } elsif ($params{mode} =~ /^server::uptime/) { # already set with the connection. but use minutes here @@ -1001,17 +1135,55 @@ sub nagios { $self->{connection_time}, $self->{warningrange}, $self->{criticalrange}); } elsif ($params{mode} =~ /^server::sql/) { - $self->add_nagios( - $self->check_thresholds($self->{genericsql}, 1, 5), - sprintf "%s: %s%s", - $params{name2} ? lc $params{name2} : lc $params{selectname}, - $self->{genericsql}, - $params{units} ? $params{units} : ""); - $self->add_perfdata(sprintf "\'%s\'=%s%s;%s;%s", - $params{name2} ? lc $params{name2} : lc $params{selectname}, - $self->{genericsql}, - $params{units} ? $params{units} : "", - $self->{warningrange}, $self->{criticalrange}); + if ($params{regexp}) { + if (substr($params{name2}, 0, 1) eq '!') { + $params{name2} =~ s/^!//; + if ($self->{genericsql} !~ /$params{name2}/) { + $self->add_nagios_ok( + sprintf "output %s does not match pattern %s", + $self->{genericsql}, $params{name2}); + } else { + $self->add_nagios_critical( + sprintf "output %s matches pattern %s", + $self->{genericsql}, $params{name2}); + } + } else { + if ($self->{genericsql} =~ /$params{name2}/) { + $self->add_nagios_ok( + sprintf "output %s matches pattern %s", + $self->{genericsql}, $params{name2}); + } else { + $self->add_nagios_critical( + sprintf "output %s does not match pattern %s", + $self->{genericsql}, $params{name2}); + } + } + } else { + $self->add_nagios( + # the first item in the list will trigger the threshold values + $self->check_thresholds($self->{genericsql}[0], 1, 5), + sprintf "%s: %s%s", + $params{name2} ? lc $params{name2} : lc $params{selectname}, + # float as float, integers as integers + join(" ", map { + (sprintf("%d", $_) eq $_) ? $_ : sprintf("%f", $_) + } @{$self->{genericsql}}), + $params{units} ? $params{units} : ""); + my $i = 0; + # workaround... getting the column names from the database would be nicer + my @names2_arr = split(/\s+/, $params{name2}); + foreach my $t (@{$self->{genericsql}}) { + $self->add_perfdata(sprintf "\'%s\'=%s%s;%s;%s", + $names2_arr[$i] ? lc $names2_arr[$i] : lc $params{selectname}, + # float as float, integers as integers + (sprintf("%d", $t) eq $t) ? $t : sprintf("%f", $t), + $params{units} ? $params{units} : "", + ($i == 0) ? $self->{warningrange} : "", + ($i == 0) ? $self->{criticalrange} : "" + ); + $i++; + } + } } elsif ($params{mode} =~ /^my::([^:.]+)/) { $self->{my}->nagios(%params); $self->merge_nagios($self->{my}); @@ -1134,34 +1306,153 @@ sub merge_nagios { push(@{$self->{nagios}->{perfdata}}, @{$child->{nagios}->{perfdata}}); } - sub calculate_result { my $self = shift; - if ($ENV{NRPE_MULTILINESUPPORT} && + my $labels = shift || {}; + my $multiline = 0; + map { + $self->{nagios_level} = $ERRORS{$_} if + (scalar(@{$self->{nagios}->{messages}->{$ERRORS{$_}}})); + } ("OK", "UNKNOWN", "WARNING", "CRITICAL"); + if ($ENV{NRPE_MULTILINESUPPORT} && length join(" ", @{$self->{nagios}->{perfdata}}) > 200) { - foreach my $level ("CRITICAL", "WARNING", "UNKNOWN", "OK") { - # first the bad news - if (scalar(@{$self->{nagios}->{messages}->{$ERRORS{$level}}})) { - $self->{nagios_message} .= - "\n".join("\n", @{$self->{nagios}->{messages}->{$ERRORS{$level}}}); - } - } - $self->{nagios_message} =~ s/^\n//g; - $self->{perfdata} = join("\n", @{$self->{nagios}->{perfdata}}); + $multiline = 1; + } + my $all_messages = join(($multiline ? "\n" : ", "), map { + join(($multiline ? "\n" : ", "), @{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } grep { + scalar(@{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } ("CRITICAL", "WARNING", "UNKNOWN", "OK")); + my $bad_messages = join(($multiline ? "\n" : ", "), map { + join(($multiline ? "\n" : ", "), @{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } grep { + scalar(@{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } ("CRITICAL", "WARNING", "UNKNOWN")); + my $all_messages_short = $bad_messages ? $bad_messages : 'no problems'; + my $all_messages_html = "<table style=\"border-collapse: collapse;\">". + join("", map { + my $level = $_; + join("", map { + sprintf "<tr valign=\"top\"><td class=\"service%s\">%s</td></tr>", + $level, $_; + } @{$self->{nagios}->{messages}->{$ERRORS{$_}}}); + } grep { + scalar(@{$self->{nagios}->{messages}->{$ERRORS{$_}}}) + } ("CRITICAL", "WARNING", "UNKNOWN", "OK")). + "</table>"; + if (exists $self->{identstring}) { + $self->{nagios_message} .= $self->{identstring}; + } + if ($self->{report} eq "long") { + $self->{nagios_message} .= $all_messages; + } elsif ($self->{report} eq "short") { + $self->{nagios_message} .= $all_messages_short; + } elsif ($self->{report} eq "html") { + $self->{nagios_message} .= $all_messages_short."\n".$all_messages_html; + } + if ($self->{labelformat} eq "pnp4nagios") { + $self->{perfdata} = join(" ", @{$self->{nagios}->{perfdata}}); } else { - foreach my $level ("CRITICAL", "WARNING", "UNKNOWN", "OK") { - # first the bad news - if (scalar(@{$self->{nagios}->{messages}->{$ERRORS{$level}}})) { - $self->{nagios_message} .= - join(", ", @{$self->{nagios}->{messages}->{$ERRORS{$level}}}).", "; + $self->{perfdata} = join(" ", map { + my $perfdata = $_; + if ($perfdata =~ /^(.*?)=(.*)/) { + my $label = $1; + my $data = $2; + if (exists $labels->{$label} && + exists $labels->{$label}->{$self->{labelformat}}) { + $labels->{$label}->{$self->{labelformat}}."=".$data; + } else { + $perfdata; + } + } else { + $perfdata; + } + } @{$self->{nagios}->{perfdata}}); + } +} + +sub set_global_db_thresholds { + my $self = shift; + my $params = shift; + my $warning = undef; + my $critical = undef; + return unless defined $params->{dbthresholds}; + $params->{name0} = $params->{dbthresholds}; + # :pluginmode :name :warning :critical + # mode empty + # + eval { + if ($self->{handle}->fetchrow_array(q{ + SELECT table_name + FROM information_schema.tables + WHERE table_schema = ? + AND table_name = 'CHECK_MYSQL_HEALTH_THRESHOLDS'; + }, $self->{database})) { # either --database... or information_schema + my @dbthresholds = $self->{handle}->fetchall_array(q{ + SELECT * FROM check_mysql_health_thresholds + }); + $params->{dbthresholds} = \@dbthresholds; + foreach (@dbthresholds) { + if (($_->[0] eq $params->{cmdlinemode}) && + (! defined $_->[1] || ! $_->[1])) { + ($warning, $critical) = ($_->[2], $_->[3]); + } } } - $self->{nagios_message} =~ s/, $//g; - $self->{perfdata} = join(" ", @{$self->{nagios}->{perfdata}}); + }; + if (! $@) { + if ($warning) { + $params->{warningrange} = $warning; + $self->trace("read warningthreshold %s from database", $warning); + } + if ($critical) { + $params->{criticalrange} = $critical; + $self->trace("read criticalthreshold %s from database", $critical); + } } - foreach my $level ("OK", "UNKNOWN", "WARNING", "CRITICAL") { - if (scalar(@{$self->{nagios}->{messages}->{$ERRORS{$level}}})) { - $self->{nagios_level} = $ERRORS{$level}; +} + +sub set_local_db_thresholds { + my $self = shift; + my %params = @_; + my $warning = undef; + my $critical = undef; + # :pluginmode :name :warning :critical + # mode name0 + # mode name2 + # mode name + # + # first: argument of --dbthresholds, it it exists + # second: --name2 + # third: --name + if (ref($params{dbthresholds}) eq 'ARRAY') { + my $marker; + foreach (@{$params{dbthresholds}}) { + if ($_->[0] eq $params{cmdlinemode}) { + if (defined $_->[1] && $params{name0} && $_->[1] eq $params{name0}) { + ($warning, $critical) = ($_->[2], $_->[3]); + $marker = $params{name0}; + last; + } elsif (defined $_->[1] && $params{name2} && $_->[1] eq $params{name2}) { + ($warning, $critical) = ($_->[2], $_->[3]); + $marker = $params{name2}; + last; + } elsif (defined $_->[1] && $params{name} && $_->[1] eq $params{name}) { + ($warning, $critical) = ($_->[2], $_->[3]); + $marker = $params{name}; + last; + } + } + } + if ($warning) { + $self->{warningrange} = $warning; + $self->trace("read warningthreshold %s for %s from database", + $marker, $warning); + } + if ($critical) { + $self->{criticalrange} = $critical; + $self->trace("read criticalthreshold %s for %s from database", + $marker, $critical); } } } @@ -1246,9 +1537,30 @@ sub save_state { my $self = shift; my %params = @_; my $extension = ""; - mkdir $params{statefilesdir} unless -d $params{statefilesdir}; - my $statefile = sprintf "%s/%s_%s", - $params{statefilesdir}, $params{hostname}, $params{mode}; + my $mode = $params{mode}; + if ($params{connect} && $params{connect} =~ /(\w+)\/(\w+)@(\w+)/) { + $params{connect} = $3; + } elsif ($params{connect}) { + # just to be sure + $params{connect} =~ s/\//_/g; + } + if ($^O =~ /MSWin/) { + $mode =~ s/::/_/g; + $params{statefilesdir} = $self->system_vartmpdir(); + } + if (! -d $params{statefilesdir}) { + eval { + use File::Path; + mkpath $params{statefilesdir}; + }; + } + if ($@ || ! -w $params{statefilesdir}) { + $self->add_nagios($ERRORS{CRITICAL}, + sprintf "statefilesdir %s does not exist or is not writable\n", + $params{statefilesdir}); + return; + } + my $statefile = sprintf "%s_%s", $params{hostname}, $mode; $extension .= $params{differenciator} ? "_".$params{differenciator} : ""; $extension .= $params{socket} ? "_".$params{socket} : ""; $extension .= $params{port} ? "_".$params{port} : ""; @@ -1263,12 +1575,17 @@ sub save_state { $extension =~ s/\s/_/g; $statefile .= $extension; $statefile = lc $statefile; - open(STATE, ">$statefile"); - if ((ref($params{save}) eq "HASH") && exists $params{save}->{timestamp}) { - $params{save}->{localtime} = scalar localtime $params{save}->{timestamp}; + $statefile = sprintf "%s/%s", $params{statefilesdir}, $statefile; + if (open(STATE, ">$statefile")) { + if ((ref($params{save}) eq "HASH") && exists $params{save}->{timestamp}) { + $params{save}->{localtime} = scalar localtime $params{save}->{timestamp}; + } + printf STATE Data::Dumper::Dumper($params{save}); + close STATE; + } else { + $self->add_nagios($ERRORS{CRITICAL}, + sprintf "statefile %s is not writable", $statefile); } - printf STATE Data::Dumper::Dumper($params{save}); - close STATE; $self->debug(sprintf "saved %s to %s", Data::Dumper::Dumper($params{save}), $statefile); } @@ -1277,8 +1594,18 @@ sub load_state { my $self = shift; my %params = @_; my $extension = ""; - my $statefile = sprintf "%s/%s_%s", - $params{statefilesdir}, $params{hostname}, $params{mode}; + my $mode = $params{mode}; + if ($params{connect} && $params{connect} =~ /(\w+)\/(\w+)@(\w+)/) { + $params{connect} = $3; + } elsif ($params{connect}) { + # just to be sure + $params{connect} =~ s/\//_/g; + } + if ($^O =~ /MSWin/) { + $mode =~ s/::/_/g; + $params{statefilesdir} = $self->system_vartmpdir(); + } + my $statefile = sprintf "%s_%s", $params{hostname}, $mode; $extension .= $params{differenciator} ? "_".$params{differenciator} : ""; $extension .= $params{socket} ? "_".$params{socket} : ""; $extension .= $params{port} ? "_".$params{port} : ""; @@ -1293,13 +1620,15 @@ sub load_state { $extension =~ s/\s/_/g; $statefile .= $extension; $statefile = lc $statefile; + $statefile = sprintf "%s/%s", $params{statefilesdir}, $statefile; if ( -f $statefile) { our $VAR1; eval { require $statefile; }; if($@) { -printf "rumms\n"; + $self->add_nagios($ERRORS{CRITICAL}, + sprintf "statefile %s is corrupt", $statefile); } $self->debug(sprintf "load %s", Data::Dumper::Dumper($VAR1)); return $VAR1; @@ -2825,7 +3154,7 @@ sub init { foreach my $line (split(/\n/, $data)) { if ($line =~ /\[(.*)\]/) { $in_section = $1; - } elsif ($line =~ /(.*)=(.*)/) { + } elsif ($line =~ /(.*?)\s*=\s*(.*)/) { $self->{config}->{$in_section}->{$1} = $2; } } @@ -2871,10 +3200,10 @@ use lib dirname($0); use vars qw ($PROGNAME $REVISION $CONTACT $TIMEOUT $STATEFILESDIR $needs_restart %commandline); $PROGNAME = "check_mysql_health"; -$REVISION = '$Revision: 2.1.3 $'; +$REVISION = '$Revision: 2.1.7 $'; $CONTACT = 'gerhard.lausser@consol.de'; $TIMEOUT = 60; -$STATEFILESDIR = '/var/run'; +$STATEFILESDIR = '/var/tmp/check_mysql_health'; $needs_restart = 0; my @modes = ( @@ -2890,6 +3219,21 @@ my @modes = ( ['server::instance::threadcachehitrate', 'threadcache-hitrate', undef, 'Hit rate of the thread-cache' ], + ['server::instance::createdthreads', + 'threads-created', undef, + 'Number of threads created per sec' ], + ['server::instance::runningthreads', + 'threads-running', undef, + 'Number of currently running threads' ], + ['server::instance::cachedthreads', + 'threads-cached', undef, + 'Number of currently cached threads' ], + ['server::instance::abortedconnects', + 'connects-aborted', undef, + 'Number of aborted connections per sec' ], + ['server::instance::abortedclients', + 'clients-aborted', undef, + 'Number of aborted connections (because the client died) per sec' ], ['server::instance::replication::slavelag', 'slave-lag', ['replication-slave-lag'], 'Seconds behind master' ], @@ -2929,6 +3273,9 @@ my @modes = ( ['server::instance::tabletmpondisk', 'tmp-disk-tables', undef, 'Percent of temp tables created on disk' ], + ['server::instance::needoptimize', + 'table-fragmentation', undef, + 'Show tables which should be optimized' ], ['server::instance::openfiles', 'open-files', undef, 'Percent of opened files' ], @@ -2946,6 +3293,67 @@ my @modes = ( 'any sql command returning a single number' ], ); +# rrd data store names are limited to 19 characters +my %labels = ( + bufferpool_hitrate => { + groundwork => 'bp_hitrate', + }, + bufferpool_hitrate_now => { + groundwork => 'bp_hitrate_now', + }, + bufferpool_free_waits_rate => { + groundwork => 'bp_freewaits', + }, + innodb_log_waits_rate => { + groundwork => 'inno_log_waits', + }, + keycache_hitrate => { + groundwork => 'kc_hitrate', + }, + keycache_hitrate_now => { + groundwork => 'kc_hitrate_now', + }, + threads_created_per_sec => { + groundwork => 'thrds_creat_per_s', + }, + connects_aborted_per_sec => { + groundwork => 'conn_abrt_per_s', + }, + clients_aborted_per_sec => { + groundwork => 'clnt_abrt_per_s', + }, + thread_cache_hitrate => { + groundwork => 'tc_hitrate', + }, + thread_cache_hitrate_now => { + groundwork => 'tc_hitrate_now', + }, + qcache_lowmem_prunes_rate => { + groundwork => 'qc_lowm_prnsrate', + }, + slow_queries_rate => { + groundwork => 'slow_q_rate', + }, + tablecache_hitrate => { + groundwork => 'tac_hitrate', + }, + tablecache_fillrate => { + groundwork => 'tac_fillrate', + }, + tablelock_contention => { + groundwork => 'tl_contention', + }, + tablelock_contention_now => { + groundwork => 'tl_contention_now', + }, + pct_tmp_table_on_disk => { + groundwork => 'tmptab_on_disk', + }, + pct_tmp_table_on_disk_now => { + groundwork => 'tmptab_on_disk_now', + }, +); + sub print_usage () { print <<EOUS; Usage: @@ -2998,6 +3406,9 @@ EOUS --units one of %, KB, MB, GB. This is used for a better output of mode=sql and for specifying thresholds for mode=tablespace-free + --labelformat + one of pnp4nagios (which is the default) or groundwork. + It is used to shorten performance data labels to 19 characters. In mode sql you can url-encode the statement so you will not have to mess around with special characters in your Nagios service definitions. @@ -3076,6 +3487,7 @@ my @params = ( "perfdata", "warning=s", "critical=s", + "dbthresholds:s", "absolute|a", "environment|e=s%", "method=s", @@ -3087,7 +3499,10 @@ my @params = ( "units=s", "lookback=i", "3", + "statefilesdir=s", "with-mymodules-dyn-dir=s", + "report=s", + "labelformat=s", "extra-opts:s"); if (! GetOptions(\%commandline, @params)) { @@ -3151,11 +3566,22 @@ if (exists $commandline{method}) { $commandline{method} = "dbi"; } +if (exists $commandline{report}) { + # short, long, html +} else { + $commandline{report} = "long"; +} + +if (exists $commandline{labelformat}) { + # groundwork +} else { + $commandline{labelformat} = "pnp4nagios"; +} + if (exists $commandline{'with-mymodules-dyn-dir'}) { - $DBD::MYSQL::Server::my_modules_dyn_dir = $commandline{'with-mymodules-dyn-dir -'}; + $DBD::MySQL::Server::my_modules_dyn_dir = $commandline{'with-mymodules-dyn-dir'}; } else { - $DBD::MYSQL::Server::my_modules_dyn_dir = '/usr/local/nagios/libexec'; + $DBD::MySQL::Server::my_modules_dyn_dir = '/usr/local/nagios/libexec'; } if (exists $commandline{environment}) { @@ -3233,6 +3659,14 @@ if (exists $commandline{shell}) { system("/bin/sh"); } +if (! exists $commandline{statefilesdir}) { + if (exists $ENV{OMD_ROOT}) { + $commandline{statefilesdir} = $ENV{OMD_ROOT}."/var/tmp/check_mysql_health"; + } else { + $commandline{statefilesdir} = $STATEFILESDIR; + } +} + if (exists $commandline{name}) { # objects can be encoded like an url # with s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; @@ -3267,16 +3701,16 @@ if ($commandline{mode} =~ /^my-([^\-.]+)/) { exit 3; } -$commandline{mode} = ( - map { $_->[0] } - grep { - ($commandline{mode} eq $_->[1]) || - ( defined $_->[2] && grep { $commandline{mode} eq $_ } @{$_->[2]}) - } @modes -)[0]; my %params = ( timeout => $TIMEOUT, - mode => $commandline{mode}, + mode => ( + map { $_->[0] } + grep { + ($commandline{mode} eq $_->[1]) || + ( defined $_->[2] && grep { $commandline{mode} eq $_ } @{$_->[2]}) + } @modes + )[0], + cmdlinemode => $commandline{mode}, method => $commandline{method} || $ENV{NAGIOS__SERVICEMYSQL_METH} || $ENV{NAGIOS__HOSTMYSQL_METH} || 'dbi', @@ -3300,6 +3734,7 @@ my %params = ( $ENV{NAGIOS__HOSTMYSQL_PASS}, warningrange => $commandline{warning}, criticalrange => $commandline{critical}, + dbthresholds => $commandline{dbthresholds}, absolute => $commandline{absolute}, lookback => $commandline{lookback}, selectname => $commandline{name} || $commandline{tablespace} || $commandline{datafile}, @@ -3309,7 +3744,10 @@ my %params = ( units => $commandline{units}, lookback => $commandline{lookback} || 0, eyecandy => $commandline{eyecandy}, - statefilesdir => $STATEFILESDIR, + statefilesdir => $commandline{statefilesdir}, + verbose => $commandline{verbose}, + report => $commandline{report}, + labelformat => $commandline{labelformat}, ); my $server = undef; @@ -3318,14 +3756,14 @@ my $cluster = undef; if ($params{mode} =~ /^(server|my)/) { $server = DBD::MySQL::Server->new(%params); $server->nagios(%params); - $server->calculate_result(); + $server->calculate_result(\%labels); $nagios_message = $server->{nagios_message}; $nagios_level = $server->{nagios_level}; $perfdata = $server->{perfdata}; } elsif ($params{mode} =~ /^cluster/) { $cluster = DBD::MySQL::Cluster->new(%params); $cluster->nagios(%params); - $cluster->calculate_result(); + $cluster->calculate_result(\%labels); $nagios_message = $cluster->{nagios_message}; $nagios_level = $cluster->{nagios_level}; $perfdata = $cluster->{perfdata}; diff --git a/manifests/base.pp b/manifests/base.pp index 0f8b777..d4d6590 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -26,6 +26,13 @@ class nagios::base { mode => 0644, owner => root, group => root; } + file { 'nagios_commands_cfg': + path => "${nagios::defaults::vars::int_nagios_cfgdir}/commands.cfg", + ensure => present, + notify => Service['nagios'], + mode => 0644, owner => root, group => root; + } + file { 'nagios_cgi_cfg': path => "${nagios::defaults::vars::int_cfgdir}/cgi.cfg", source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/cgi.cfg", diff --git a/manifests/command/imap_pop3.pp b/manifests/command/imap_pop3.pp index 174b09c..3735136 100644 --- a/manifests/command/imap_pop3.pp +++ b/manifests/command/imap_pop3.pp @@ -1,7 +1,15 @@ class nagios::command::imap_pop3 { - nagios_command{ - 'check_imap': - command_line => '$USER1$/check_imap -H $ARG1$ -p $ARG2$'; + case $operatingsystem { + debian,ubuntu: { } # Debian/Ubuntu already define those checks + default: { + nagios_command { + 'check_imap': + command_line => '$USER1$/check_imap -H $ARG1$ -p $ARG2$'; + } + } + } + + nagios_command { 'check_imap_ssl': command_line => '$USER1$/check_imap -H $ARG1$ -p $ARG2$ -S'; 'check_pop3': diff --git a/manifests/command/nrpe.pp b/manifests/command/nrpe.pp new file mode 100644 index 0000000..7539a26 --- /dev/null +++ b/manifests/command/nrpe.pp @@ -0,0 +1,14 @@ +class nagios::command::nrpe { + + # this command runs a program $ARG1$ with arguments $ARG2$ + nagios_command { + 'check_nrpe': + command_line => '/usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$' + } + + # this command runs a program $ARG1$ with no arguments + nagios_command { + 'check_nrpe_1arg': + command_line => '/usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$' + } +} diff --git a/manifests/command/nrpe_timeout.pp b/manifests/command/nrpe_timeout.pp new file mode 100644 index 0000000..3415566 --- /dev/null +++ b/manifests/command/nrpe_timeout.pp @@ -0,0 +1,11 @@ +class nagios::command::nrpe_timeout { + nagios_command { + 'check_nrpe_timeout': + command_line => '/usr/lib/nagios/plugins/check_nrpe -t $ARG1$ -H $HOSTADDRESS$ -c $ARG2$ -a $ARG3$' + } + + nagios_command { + 'check_nrpe_1arg_timeout': + command_line => '/usr/lib/nagios/plugins/check_nrpe -t $ARG1$ -H $HOSTADDRESS$ -c $ARG2$' + } +} diff --git a/manifests/command/smtp.pp b/manifests/command/smtp.pp index 04f8543..29d97f8 100644 --- a/manifests/command/smtp.pp +++ b/manifests/command/smtp.pp @@ -1,14 +1,22 @@ class nagios::command::smtp { - nagios_command{ - 'check_smtp': - command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$'; + case $operatingsystem { + debian,ubuntu: { } # Debian/Ubuntu already define those checks + default: { + nagios_command { + 'check_smtp': + command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$'; + 'check_ssmtp': + command_line => '$USER1$/check_ssmtp -H $ARG1$ -p $ARG2$ -S'; + } + } + } + + nagios_command { 'check_smtp_tls': - command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$ -S'; + command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$ -S'; 'check_smtp_cert': - command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$ -S -D $ARG3$'; - 'check_ssmtp': - command_line => '$USER1$/check_ssmtp -H $ARG1$ -p $ARG2$ -S'; + command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$ -S -D $ARG3$'; 'check_ssmtp_cert': - command_line => '$USER1$/check_ssmtp -H $ARG1$ -p $ARG2$ -S -D $ARG3$'; + command_line => '$USER1$/check_ssmtp -H $ARG1$ -p $ARG2$ -S -D $ARG3$'; } } diff --git a/manifests/defaults/commands.pp b/manifests/defaults/commands.pp index 195c8e3..bb19638 100644 --- a/manifests/defaults/commands.pp +++ b/manifests/defaults/commands.pp @@ -29,6 +29,8 @@ class nagios::defaults::commands { command_line => '$USER1$/check_tcp -H $ARG1$ -p $ARG2$'; check_jabber: command_line => '$USER1$/check_jabber -H $ARG1$'; + check_git: + command_line => '$USER1$/check_tcp -H $ARG1$ -p 9418'; } } default: { @@ -109,7 +111,7 @@ class nagios::defaults::commands { # from mysql module check_mysql_health: - command_line => '$USER1$/check_mysql_health --hostname $ARG1$ --port $ARG2$ --username $ARG3$ --password $ARG4$ --mode $ARG5$ --database $ARG6$'; + command_line => '$USER1$/check_mysql_health --hostname $ARG1$ --port $ARG2$ --username $ARG3$ --password $ARG4$ --mode $ARG5$ --database $ARG6$ $ARG7$ $ARG8$'; # better check_dns check_dns2: @@ -129,7 +131,7 @@ class nagios::defaults::commands { nagios_command { 'notify-host-by-email': - command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\nHost: \\$HOSTNAME\\$\\nState: \$HOSTSTATE\$\\nAddress: \$HOSTADDRESS\$\\nInfo: \$HOSTOUTPUT\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Host Alert: \$HOSTNAME\$ is \$HOSTSTATE\$ **\" \$CONTACTEMAIL\$"; + command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\nHost: \$HOSTNAME\$\\nState: \$HOSTSTATE\$\\nAddress: \$HOSTADDRESS\$\\nInfo: \$HOSTOUTPUT\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Host Alert: \$HOSTNAME\$ is \$HOSTSTATE\$ **\" \$CONTACTEMAIL\$"; 'notify-service-by-email': command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\n\\nService: \$SERVICEDESC\$\\nHost: \$HOSTALIAS\$\\nAddress: \$HOSTADDRESS\$\\nState: \$SERVICESTATE\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\\nAdditional Info:\\n\\n\$SERVICEOUTPUT\$\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Service Alert: \$HOSTALIAS\$/\$SERVICEDESC\$ is \$SERVICESTATE\$ **\" \$CONTACTEMAIL\$"; } diff --git a/manifests/irc_bot.pp b/manifests/irc_bot.pp index 77c5fa8..a034fe0 100644 --- a/manifests/irc_bot.pp +++ b/manifests/irc_bot.pp @@ -1,83 +1,21 @@ -class nagios::irc_bot( - $nsa_socket = 'absent', - $nsa_server, - $nsa_port = 6667, - $nsa_nickname, - $nsa_password = '', - $nsa_channel, - $nsa_pidfile = 'absent', - $nsa_realname = 'Nagios' -) { - $real_nsa_socket = $nsa_socket ? { - 'absent' => $::operatingsystem ? { - centos => '/var/run/nagios-nsa/nsa.socket', - default => '/var/run/nagios3/nsa.socket' - }, - default => $nsa_socket, - } - $real__nsa_pidfile = $nsa_pidfile ? { - 'absent' => $::operatingsystem ? { - centos => '/var/run/nagios-nsa/nsa.pid', - default => '/var/run/nagios3/nsa.pid' - }, - default => $nsa_pidfile, - } - - file { - '/usr/local/bin/riseup-nagios-client.pl': - source => 'puppet:///modules/nagios/irc_bot/riseup-nagios-client.pl', - owner => root, group => root, mode => 0755; - '/usr/local/bin/riseup-nagios-server.pl': - source => 'puppet:///modules/nagios/irc_bot/riseup-nagios-server.pl', - owner => root, group => root, mode => 0755; - '/etc/init.d/nagios-nsa': - content => template("nagios/irc_bot/${::operatingsystem}/nagios-nsa.sh.erb"), - require => File['/usr/local/bin/riseup-nagios-server.pl'], - owner => root, group => root, mode => 0755; - '/etc/nagios_nsa.cfg': - ensure => present, - content => template('nagios/irc_bot/nsa.cfg.erb'), - owner => nagios, group => root, mode => 0400; - } - - package { 'libnet-irc-perl': - ensure => present, +class nagios::irc_bot { + if ( ! ($nsa_server and $nsa_nickname and $nsa_channel) ) { + fail("Please provide values at least for \$nsa_server, \$nsa_nickname and \$nsa_channel") } - service { "nagios-nsa": - ensure => "running", - hasstatus => true, - require => [ File["/etc/nagios_nsa.cfg"], - Package["libnet-irc-perl"], - Service['nagios'] ], - } - - case $::operatingsystem { + case $operatingsystem { centos: { - Package['libnet-irc-perl']{ - name => 'perl-Net-IRC', - } - Service['nagios-nsa']{ - enable => true, - } + $nsa_default_socket = '/var/run/nagios-nsa/nsa.socket' + $nsa_default_pidfile = '/var/run/nagios-nsa/nsa.pid' + include nagios::irc_bot::centos } - debian,ubuntu: { - exec { "nagios_nsa_init_script": - command => "/usr/sbin/update-rc.d nagios-nsa defaults", - unless => "/bin/ls /etc/rc3.d/ | /bin/grep nagios-nsa", - require => File["/etc/init.d/nagios-nsa"], - before => Service['nagios-nsa'], - } + default: { + $nsa_default_socket = '/var/run/nagios3/nsa.socket' + $nsa_default_pidfile = '/var/run/nagios3/nsa.pid' + include nagios::irc_bot::base } } - nagios_command { - 'notify-by-irc': - command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($SERVICEDESC$) $NOTIFICATIONTYPE$ n.$SERVICEATTEMPT$ $SERVICESTATETYPE$ $SERVICEEXECUTIONTIME$s $SERVICELATENCY$s $SERVICEOUTPUT$ $SERVICEPERFDATA$"'; - 'host-notify-by-irc': - command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($HOSTALIAS$) $NOTIFICATIONTYPE$ n.$HOSTATTEMPT$ $HOSTSTATETYPE$ took $HOSTEXECUTIONTIME$s $HOSTOUTPUT$ $HOSTPERFDATA$ $HOSTLATENCY$s"'; - } - if $nagios::manage_shorewall { include shorewall::rules::out::irc } diff --git a/manifests/irc_bot/base.pp b/manifests/irc_bot/base.pp new file mode 100644 index 0000000..6fab2ac --- /dev/null +++ b/manifests/irc_bot/base.pp @@ -0,0 +1,69 @@ +class nagios::irc_bot::base { + + # Default values for the two first variables are defined in nagios::irc_bot + $nsa_socket = $nsa_socket ? { + '' => $nsa_default_socket, + default => $nsa_socket, + } + $nsa_pidfile = $nsa_pidfile ? { + '' => $nsa_default_pidfile, + default => $nsa_pidfile, + } + $nsa_port = $nsa_port ? { + '' => '6667', + default => $nsa_port, + } + $nsa_realname = $nsa_realname ? { + '' => 'Nagios', + default => $nsa_realname, + } + + if (! $nsa_password) { + $nsa_password = '' + } + + if (! $nsa_usenotices) { + $nsa_usenotices = '' + } + + file { "/usr/local/bin/riseup-nagios-client.pl": + owner => root, group => 0, mode => 0755, + source => "puppet:///modules/nagios/irc_bot/riseup-nagios-client.pl", + } + file { "/usr/local/bin/riseup-nagios-server.pl": + owner => root, group => 0, mode => 0755, + source => "puppet:///modules/nagios/irc_bot/riseup-nagios-server.pl", + } + file { "/etc/init.d/nagios-nsa": + owner => root, group => 0, mode => 0755, + content => template("nagios/irc_bot/${operatingsystem}/nagios-nsa.sh.erb"), + require => File["/usr/local/bin/riseup-nagios-server.pl"], + } + file { "/etc/nagios_nsa.cfg": + ensure => present, + owner => nagios, group => 0, mode => 0400, + content => template('nagios/irc_bot/nsa.cfg.erb'), + notify => Service["nagios-nsa"], + } + + package { "libnet-irc-perl": + ensure => present, + } + + service { "nagios-nsa": + ensure => "running", + hasstatus => true, + enable => true, + require => [File["/etc/nagios_nsa.cfg"], + File["/etc/init.d/nagios-nsa"], + Package["libnet-irc-perl"], + Service['nagios'] ], + } + + nagios_command { + "notify-by-irc": + command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($SERVICEDESC$) $NOTIFICATIONTYPE$ $SERVICEATTEMPT$/$MAXSERVICEATTEMPTS$ $SERVICESTATETYPE$ $SERVICEEXECUTIONTIME$s $SERVICELATENCY$s $SERVICEOUTPUT$ $SERVICEPERFDATA$"'; + "host-notify-by-irc": + command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($HOSTALIAS$) $NOTIFICATIONTYPE$ $HOSTATTEMPT$/$MAXHOSTATTEMPTS$ $HOSTSTATETYPE$ took $HOSTEXECUTIONTIME$s $HOSTOUTPUT$ $HOSTPERFDATA$ $HOSTLATENCY$s"'; + } +} diff --git a/manifests/irc_bot/centos.pp b/manifests/irc_bot/centos.pp new file mode 100644 index 0000000..e77e93a --- /dev/null +++ b/manifests/irc_bot/centos.pp @@ -0,0 +1,7 @@ +class nagios::irc_bot::centos inherits nagios::irc_bot::base { + + Package['libnet-irc-perl']{ + name => 'perl-Net-IRC', + } + +} diff --git a/manifests/irc_bot/disable.pp b/manifests/irc_bot/disable.pp new file mode 100644 index 0000000..d6b7c55 --- /dev/null +++ b/manifests/irc_bot/disable.pp @@ -0,0 +1,8 @@ +class nagios::irc_bot::disable inherits nagios::irc_bot::base { + + Service['nagios-nsa'] { + ensure => stopped, + enable => false, + } + +} diff --git a/manifests/nrpe.pp b/manifests/nrpe.pp new file mode 100644 index 0000000..5c05ed4 --- /dev/null +++ b/manifests/nrpe.pp @@ -0,0 +1,22 @@ +class nagios::nrpe { + + case $operatingsystem { + 'FreeBSD': { + if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/usr/local/etc' } + if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/spool/nagios/nrpe2.pid' } + if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/local/libexec/nagios' } + + include nagios::nrpe::freebsd + } + default: { + if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/run/nrpe.pid' } + if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/lib/nagios/plugins' } + + case $kernel { + linux: { include nagios::nrpe::linux } + default: { include nagios::nrpe::base } + } + } + } + +} diff --git a/manifests/nrpe/base.pp b/manifests/nrpe/base.pp new file mode 100644 index 0000000..17abb04 --- /dev/null +++ b/manifests/nrpe/base.pp @@ -0,0 +1,50 @@ +class nagios::nrpe::base { + + if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/etc/nagios' } + if $processorcount == '' { $processorcount = 1 } + + package { "nagios-nrpe-server": ensure => present; + "nagios-plugins-basic": ensure => present; + "libwww-perl": ensure => present; # for check_apache + } + + # Special-case lenny. the package doesn't exist + if $lsbdistcodename != 'lenny' { + package { "libnagios-plugin-perl": ensure => present; } + } + + file { [ $nagios_nrpe_cfgdir, "$nagios_nrpe_cfgdir/nrpe.d" ]: + ensure => directory } + + if $nagios_nrpe_dont_blame == '' { $nagios_nrpe_dont_blame = 1 } + file { "$nagios_nrpe_cfgdir/nrpe.cfg": + content => template('nagios/nrpe/nrpe.cfg'), + owner => root, group => 0, mode => 644; + } + + # default commands + nagios::nrpe::command { "basic_nrpe": + source => [ "puppet:///modules/site-nagios/configs/nrpe/nrpe_commands.${fqdn}.cfg", + "puppet:///modules/site-nagios/configs/nrpe/nrpe_commands.cfg", + "puppet:///modules/nagios/nrpe/nrpe_commands.cfg" ], + } + # the check for load should be customized for each server based on number + # of CPUs and the type of activity. + $warning_1_threshold = 7 * $processorcount + $warning_5_threshold = 6 * $processorcount + $warning_15_threshold = 5 * $processorcount + $critical_1_threshold = 10 * $processorcount + $critical_5_threshold = 9 * $processorcount + $critical_15_threshold = 8 * $processorcount + nagios::nrpe::command { "check_load": + command_line => "${nagios_plugin_dir}/check_load -w ${warning_1_threshold},${warning_5_threshold},${warning_15_threshold} -c ${critical_1_threshold},${critical_5_threshold},${critical_15_threshold}", + } + + service { "nagios-nrpe-server": + ensure => running, + enable => true, + pattern => "nrpe", + subscribe => File["$nagios_nrpe_cfgdir/nrpe.cfg"], + require => Package["nagios-nrpe-server"], + } +} diff --git a/manifests/nrpe/command.pp b/manifests/nrpe/command.pp new file mode 100644 index 0000000..e6ebdae --- /dev/null +++ b/manifests/nrpe/command.pp @@ -0,0 +1,33 @@ +define nagios::nrpe::command ( + $ensure = present, + $command_line = '', + $source = '' ) +{ + if ($command_line == '' and $source == '') { + fail ( "Either one of 'command_line' or 'source' must be given to nagios::nrpe::command." ) + } + + if $nagios_nrpe_cfg_dir == '' { + $nagios_nrpe_cfgdir = $nagios::nrpe::base::nagios_nrpe_cfgdir + } + + file { "$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg": + ensure => $ensure, + mode => 644, owner => root, group => 0, + notify => Service['nagios-nrpe-server'], + require => File [ "$nagios_nrpe_cfgdir/nrpe.d" ] + } + + case $source { + '': { + File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] { + content => template( "nagios/nrpe/nrpe_command.erb" ), + } + } + default: { + File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] { + source => $source, + } + } + } +} diff --git a/manifests/nrpe/freebsd.pp b/manifests/nrpe/freebsd.pp new file mode 100644 index 0000000..063b79b --- /dev/null +++ b/manifests/nrpe/freebsd.pp @@ -0,0 +1,16 @@ +class nagios::nrpe::freebsd inherits nagios::nrpe::base { + + Package["nagios-nrpe-server"] { name => "nrpe" } + Package["nagios-plugins-basic"] { name => "nagios-plugins" } + Package["libnagios-plugin-perl"] { name => "p5-Nagios-Plugin" } + Package["libwww-perl"] { name => "p5-libwww" } + + # TODO check_cpustats.sh is probably not working as of now. the package 'sysstat' is not available under FreeBSD + + Service["nagios-nrpe-server"] { + pattern => "^/usr/local/sbin/nrpe2", + path => "/usr/local/etc/rc.d", + name => "nrpe2", + hasstatus => "false", + } +} diff --git a/manifests/nrpe/linux.pp b/manifests/nrpe/linux.pp new file mode 100644 index 0000000..14e007f --- /dev/null +++ b/manifests/nrpe/linux.pp @@ -0,0 +1,9 @@ +class nagios::nrpe::linux inherits nagios::nrpe::base { + + package { + "nagios-plugins-standard": ensure => present; + "ksh": ensure => present; # for check_cpustats.sh + "sysstat": ensure => present; # for check_cpustats.sh + } + +} diff --git a/manifests/nrpe/xinetd.pp b/manifests/nrpe/xinetd.pp new file mode 100644 index 0000000..e13ed76 --- /dev/null +++ b/manifests/nrpe/xinetd.pp @@ -0,0 +1,11 @@ +# This is created only to cope with cases where we're not the only ones +# administering a machine and NRPE is running in xinetd. +class nagios::nrpe::xinetd inherits base { + + Service ["nagios-nrpe-server"] { + ensure => stopped, + } + + # TODO manage the xinetd config file that glues with NRPE + +} diff --git a/manifests/nsca/server.pp b/manifests/nsca/server.pp index 8ba0116..bd5389d 100644 --- a/manifests/nsca/server.pp +++ b/manifests/nsca/server.pp @@ -6,6 +6,7 @@ class nagios::nsca::server { ensure => running, hasstatus => false, hasrestart => true, + require => Package['nsca'], } file { '/etc/nsca.cfg': diff --git a/manifests/service.pp b/manifests/service.pp index a739317..71f78b0 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -11,16 +11,33 @@ define nagios::service ( $notification_options = '', $contact_groups = '', $use = 'generic-service', - $service_description = 'absent' ) + $service_description = 'absent', + $use_nrpe = '', + $nrpe_args = '', + $nrpe_timeout = 10 ) { # TODO: this resource should normally accept all nagios_host parameters $real_name = "${::hostname}_${name}" + if ($use_nrpe == 'true') { + include nagios::command::nrpe_timeout + + if ($nrpe_args != '') { + $real_check_command = "check_nrpe_timeout!$nrpe_timeout!$check_command!\"$nrpe_args\"" + } + else { + $real_check_command = "check_nrpe_1arg_timeout!$nrpe_timeout!$check_command" + } + } + else { + $real_check_command = "$check_command" + } + @@nagios_service { "${real_name}": ensure => $ensure, - check_command => $check_command, + check_command => $real_check_command, host_name => $host_name, use => $use, notify => Service[nagios], diff --git a/manifests/service/imap.pp b/manifests/service/imap.pp new file mode 100644 index 0000000..b703db4 --- /dev/null +++ b/manifests/service/imap.pp @@ -0,0 +1,32 @@ +define nagios::service::imap( + $ensure = 'present', + $host = 'absent', + $port = '143', + $tls = true, + $tls_port = '993' +){ + + $real_host = $host ? { + 'absent' => $name, + default => $host + } + + nagios::service{ + "imap_${name}_${port}": + ensure => $ensure; + "imaps_${name}_${tls_port}": + ensure => $tls ? { + true => $ensure, + default => 'absent' + }; + } + + if $ensure != 'absent' { + Nagios::Service["imap_${name}_${port}"]{ + check_command => "check_imap!${real_host}!${port}", + } + Nagios::Service["imaps_${name}_${tls_port}"]{ + check_command => "check_imap_ssl!${real_host}!${tls_port}", + } + } +} diff --git a/manifests/service/mysql.pp b/manifests/service/mysql.pp index 95f0970..94881d8 100644 --- a/manifests/service/mysql.pp +++ b/manifests/service/mysql.pp @@ -21,6 +21,18 @@ define nagios::service::mysql( fail("Please specify a hostname, ip address or socket to check a mysql instance.") } + if $check_name != undef { + $real_check_name = "!--name $check_name" + } + + if $check_warning != undef { + $real_check_warning = "!--warning $check_warning" + } + + if $check_critical != undef { + $real_check_critical = "!--critical $check_critical" + } + case $check_mode { 'tcp': { if ($check_host == 'localhost') { @@ -42,6 +54,6 @@ define nagios::service::mysql( nagios::service { "mysql_health_${name}": ensure => $ensure, - check_command => "check_mysql_health!${check_host}!${check_port}!${check_username}!${check_password}!${name}!${check_database}", + check_command => "check_mysql_health!${real_check_host}!${check_port}!${check_username}!${check_password}!${check_health_mode}!${check_database}${real_check_name}${real_check_warning}${real_check_critical}", } } diff --git a/manifests/service/pop.pp b/manifests/service/pop.pp new file mode 100644 index 0000000..9ec4aec --- /dev/null +++ b/manifests/service/pop.pp @@ -0,0 +1,32 @@ +define nagios::service::pop( + $ensure = 'present', + $host = 'absent', + $port = '110', + $tls = true, + $tls_port = '995' +){ + + $real_host = $host ? { + 'absent' => $name, + default => $host + } + + nagios::service{ + "pop_${name}_${port}": + ensure => $ensure; + "pops_${name}_${tls_port}": + ensure => $tls ? { + true => $ensure, + default => 'absent' + }; + } + + if $ensure != 'absent' { + Nagios::Service["pop_${name}_${port}"]{ + check_command => "check_pop3!${real_host}!${port}", + } + Nagios::Service["pops_${name}_${tls_port}"]{ + check_command => "check_pop3_ssl!${real_host}!${tls_port}", + } + } +} diff --git a/templates/irc_bot/Debian/nagios-nsa.sh.erb b/templates/irc_bot/Debian/nagios-nsa.sh.erb index 16fa2ea..43c0e79 100644 --- a/templates/irc_bot/Debian/nagios-nsa.sh.erb +++ b/templates/irc_bot/Debian/nagios-nsa.sh.erb @@ -2,8 +2,8 @@ ### BEGIN INIT INFO # Provides: nagios-nsa -# Required-Start: $remote_fs $syslog $nagios -# Required-Stop: $remote_fs $syslog $nagios +# Required-Start: $remote_fs $syslog nagios3 +# Required-Stop: $remote_fs $syslog nagios3 # Default-Start: 2 3 4 5 # Default-Stop: 1 6 0 # Short-Description: Nagios Simple IRC Agent @@ -51,6 +51,7 @@ cleanup() { case $1 in start) + cleanup start ;; stop) diff --git a/templates/irc_bot/nsa.cfg.erb b/templates/irc_bot/nsa.cfg.erb index cc7d274..9109b55 100644 --- a/templates/irc_bot/nsa.cfg.erb +++ b/templates/irc_bot/nsa.cfg.erb @@ -10,4 +10,6 @@ 'channel' => '<%= scope.lookupvar('nagios::irc_bot::nsa_channel') %>', 'pidfile' => '<%= scope.lookupvar('nagios::irc_bot::real_nsa_pidfile') %>', # set to undef to disable 'realname' => "<%= scope.lookupvar('nagios::irc_bot::nsa_realname') %>", + 'realname' => "<%= scope.lookupvar('nagios::irc_bot::nsa_realname') %>", + 'usenotices' => "<%= scope.lookupvar('nagios::irc_bot::nsa_usenotices') %>", ); diff --git a/templates/nrpe/nrpe.cfg b/templates/nrpe/nrpe.cfg new file mode 100644 index 0000000..5368bc8 --- /dev/null +++ b/templates/nrpe/nrpe.cfg @@ -0,0 +1,205 @@ +############################################################################# +# Sample NRPE Config File +# Written by: Ethan Galstad (nagios@nagios.org) +# +# Last Modified: 02-23-2006 +# +# NOTES: +# This is a sample configuration file for the NRPE daemon. It needs to be +# located on the remote host that is running the NRPE daemon, not the host +# from which the check_nrpe client is being executed. +############################################################################# + + +# PID FILE +# The name of the file in which the NRPE daemon should write it's process ID +# number. The file is only written if the NRPE daemon is started by the root +# user and is running in standalone mode. + +pid_file=<%= nagios_nrpe_pid_file %> + + + +# PORT NUMBER +# Port number we should wait for connections on. +# NOTE: This must be a non-priviledged port (i.e. > 1024). +# NOTE: This option is ignored if NRPE is running under either inetd or xinetd + +server_port=5666 + + + +# SERVER ADDRESS +# Address that nrpe should bind to in case there are more than one interface +# and you do not want nrpe to bind on all interfaces. +# NOTE: This option is ignored if NRPE is running under either inetd or xinetd + +<%- if has_variable?("nagios_nrpe_server_address") then %> +<%- if not nagios_nrpe_server_address.to_s.empty? then %> +server_address=<%= nagios_nrpe_server_address %> +<%- end %> +<%- end %> + + +# NRPE USER +# This determines the effective user that the NRPE daemon should run as. +# You can either supply a username or a UID. +# +# NOTE: This option is ignored if NRPE is running under either inetd or xinetd + +nrpe_user=nagios + + + +# NRPE GROUP +# This determines the effective group that the NRPE daemon should run as. +# You can either supply a group name or a GID. +# +# NOTE: This option is ignored if NRPE is running under either inetd or xinetd + +nrpe_group=nagios + + + +# ALLOWED HOST ADDRESSES +# This is an optional comma-delimited list of IP address or hostnames +# that are allowed to talk to the NRPE daemon. +# +# Note: The daemon only does rudimentary checking of the client's IP +# address. I would highly recommend adding entries in your /etc/hosts.allow +# file to allow only the specified host to connect to the port +# you are running this daemon on. +# +# NOTE: This option is ignored if NRPE is running under either inetd or xinetd + +<%- if nagios_nrpe_allowed_hosts.to_s.empty? then %> +allowed_hosts=127.0.0.1 +<%- else %> +allowed_host=127.0.0.1,<%= nagios_nrpe_allowed_hosts %> +<%- end %> + +# COMMAND ARGUMENT PROCESSING +# This option determines whether or not the NRPE daemon will allow clients +# to specify arguments to commands that are executed. This option only works +# if the daemon was configured with the --enable-command-args configure script +# option. +# +# *** ENABLING THIS OPTION IS A SECURITY RISK! *** +# Read the SECURITY file for information on some of the security implications +# of enabling this variable. +# +# Values: 0=do not allow arguments, 1=allow command arguments + +dont_blame_nrpe=1 + + +# COMMAND PREFIX +# This option allows you to prefix all commands with a user-defined string. +# A space is automatically added between the specified prefix string and the +# command line from the command definition. +# +# *** THIS EXAMPLE MAY POSE A POTENTIAL SECURITY RISK, SO USE WITH CAUTION! *** +# Usage scenario: +# Execute restricted commmands using sudo. For this to work, you need to add +# the nagios user to your /etc/sudoers. An example entry for alllowing +# execution of the plugins from might be: +# +# nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/ +# +# This lets the nagios user run all commands in that directory (and only them) +# without asking for a password. If you do this, make sure you don't give +# random users write access to that directory or its contents! + +# command_prefix=/usr/bin/sudo + + + +# DEBUGGING OPTION +# This option determines whether or not debugging messages are logged to the +# syslog facility. +# Values: 0=debugging off, 1=debugging on + +debug=0 + + + +# COMMAND TIMEOUT +# This specifies the maximum number of seconds that the NRPE daemon will +# allow plugins to finish executing before killing them off. + +command_timeout=60 + + + +# WEEK RANDOM SEED OPTION +# This directive allows you to use SSL even if your system does not have +# a /dev/random or /dev/urandom (on purpose or because the necessary patches +# were not applied). The random number generator will be seeded from a file +# which is either a file pointed to by the environment valiable $RANDFILE +# or $HOME/.rnd. If neither exists, the pseudo random number generator will +# be initialized and a warning will be issued. +# Values: 0=only seed from /dev/[u]random, 1=also seed from weak randomness + +#allow_weak_random_seed=1 + + + +# INCLUDE CONFIG FILE +# This directive allows you to include definitions from an external config file. + +#include=<somefile.cfg> + + + +# INCLUDE CONFIG DIRECTORY +# This directive allows you to include definitions from config files (with a +# .cfg extension) in one or more directories (with recursion). + +#include_dir=<somedirectory> +#include_dir=<someotherdirectory> +include_dir=<%= nagios_nrpe_cfgdir %>/nrpe.d + + + +# COMMAND DEFINITIONS +# Command definitions that this daemon will run. Definitions +# are in the following format: +# +# command[<command_name>]=<command_line> +# +# When the daemon receives a request to return the results of <command_name> +# it will execute the command specified by the <command_line> argument. +# +# Unlike Nagios, the command line cannot contain macros - it must be +# typed exactly as it should be executed. +# +# Note: Any plugins that are used in the command lines must reside +# on the machine that this daemon is running on! The examples below +# assume that you have plugins installed in a /usr/local/nagios/libexec +# directory. Also note that you will have to modify the definitions below +# to match the argument format the plugins expect. Remember, these are +# examples only! + +# The following examples use hardcoded command arguments... + +#command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10 +#command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 +#command[check_disk1]=/usr/lib/nagios/plugins/check_disk -w 20 -c 10 -p /dev/hda1 +#command[check_disk2]=/usr/lib/nagios/plugins/check_disk -w 20 -c 10 -p /dev/hdb1 +#command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z +#command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200 + +# The following examples allow user-supplied arguments and can +# only be used if the NRPE daemon was compiled with support for +# command arguments *AND* the dont_blame_nrpe directive in this +# config file is set to '1'... + +#command[check_users]=/usr/lib/nagios/plugins/check_users -w $ARG1$ -c $ARG2$ +#command[check_load]=/usr/lib/nagios/plugins/check_load -w $ARG1$ -c $ARG2$ +#command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ +#command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$ + +# +# local configuration: +# if you'd prefer, you can instead place directives here + |