aboutsummaryrefslogtreecommitdiffstats
path: root/sitesummary-nodes
diff options
context:
space:
mode:
Diffstat (limited to 'sitesummary-nodes')
-rwxr-xr-xsitesummary-nodes99
1 files changed, 62 insertions, 37 deletions
diff --git a/sitesummary-nodes b/sitesummary-nodes
index 626ec68..77c0f8b 100755
--- a/sitesummary-nodes
+++ b/sitesummary-nodes
@@ -17,13 +17,12 @@ Usage: $0 [-hmnw]
-h Show usage information
-m Generate munin configuration for all munin clients
-n Generate nagios configuration for all nagios clients
- -r Do not generate nagios checks requiring nrpe configuration on remote hosts
-w List all client DNS/IP-addresses and MAC addresses
EOF
}
my %opts;
-getopts("hmnwr", \%opts) || (usage(), exit(1));
+getopts("hmnw", \%opts) || (usage(), exit(1));
my %hostnames;
@@ -145,11 +144,28 @@ sub is_remote_nagios_client {
is_pkg_installed($hostid, "nagios3"));
}
+sub is_remote_nrpe_config_active {
+ my $hostid = shift;
+
+ my $path = get_filepath_current($hostid, "/nagios/sitesummary-nrpe.cfg");
+ if (open(my $fh, $path)) {
+ while (<$fh>) {
+ if (m/^dont_blame_nrpe=1$/) {
+ close($fh);
+ return "args";
+ }
+ }
+ close($fh);
+ return "noargs";
+ }
+ return undef;
+}
+
+
sub print_nagios_service_check {
my ($remote, $hostname, $description, $check, $check_args) = @_;
my $template = "server-service";
my $cmd;
- return if $opts{'r'} && $remote;
if ($remote) {
$cmd = "check_nrpe!$check";
if (defined $check_args) {
@@ -193,6 +209,7 @@ sub generate_nagios_config {
my $redirect = "";
my $nagiosclient = is_nagios_client($hostid);
my $remote = is_remote_nagios_client($hostid);
+ my $nrpestatus = is_remote_nrpe_config_active($hostid);
# Only check laptops that have the nagios tools installed
next if is_laptop($hostid) && ! $remote && ! $nagiosclient;
@@ -244,7 +261,48 @@ sub generate_nagios_config {
is_pkg_installed($hostid, "apache2"));
# The rest of the checks only work if NRPE is installed and configured
- next unless ($nagiosclient);
+ next unless ((!$remote && $nagiosclient)
+ || ($remote && defined $nrpestatus));
+
+ # These work without any argument passing.
+
+ # Check for APT upgrades
+ print_nagios_service_check($remote, $hostname, "apt-updates",
+ "check_apt");
+
+# print_nagios_service_check($remote, $hostname, "dhcp",
+# "check_dhcp")
+# if is_pkg_installed($hostid, "dhcp3-server");
+
+ # Check DNS server
+ print_nagios_service_check($remote, $hostname, "dns",
+ "check_dns")
+ if is_pkg_installed($hostid, "pdns-server");
+
+ # Check FTP server
+ print_nagios_service_check($remote, $hostname, "ftp",
+ "check_ftp")
+ if is_pkg_installed($hostid, "proftpd");
+
+ # Check IMAPS server
+ print_nagios_service_check($remote, $hostname, "imaps",
+ "check_imaps")
+ if is_pkg_installed($hostid, "courier-imap-ssl");
+
+ # check software raid status
+ if ( -e get_filepath_current($hostid, "/system/mdstat") ) {
+ print_nagios_service_check($remote, $hostname, "sw-raid",
+ "check_linux_raid");
+ }
+
+ # Check NFS server
+ print_nagios_service_check($remote, $hostname, "nfs",
+ "check_nfs")
+ if is_pkg_installed($hostid, "nfs-kernel-server");
+
+ # These need argument passing (as in dont_blame_nrpe=1)
+ next unless ((!$remote && $nagiosclient)
+ || ($remote && "args" eq $nrpestatus));
print_nagios_service_check($remote, $hostname, "swap",
"check_swap", "10%!5%");
@@ -254,8 +312,6 @@ sub generate_nagios_config {
"check_procs", "500!1000");
print_nagios_service_check($remote, $hostname, "processes zombie",
"check_procs_zombie", "20!100");
- print_nagios_service_check($remote, $hostname, "apt-updates",
- "check_apt");
# Check unix load
print_nagios_service_check($remote, $hostname, "load as in top",
"check_load", "75,75,75!90,90,90");
@@ -293,33 +349,12 @@ sub generate_nagios_config {
}
}
- # check software raid status
- if ( -e get_filepath_current($hostid, "/system/mdstat") ) {
- print_nagios_service_check($remote, $hostname, "sw-raid",
- "check_linux_raid");
- }
-
# check munin if munin-node is installed
# check hw raid status
# check hardware status
# check LDAP and LDAPS using the protocol
- # Check DNS server
- print_nagios_service_check($remote, $hostname, "dns",
- "check_dns")
- if is_pkg_installed($hostid, "pdns-server");
-
- # Check IMAPS server
- print_nagios_service_check($remote, $hostname, "imaps",
- "check_imaps")
- if is_pkg_installed($hostid, "courier-imap-ssl");
-
- # Check NFS server
- print_nagios_service_check($remote, $hostname, "nfs",
- "check_nfs")
- if is_pkg_installed($hostid, "nfs-kernel-server");
-
# Check Squid web proxy
print_nagios_service_check($remote, $hostname, "squid",
"check_squid", "3128!http://www")
@@ -334,15 +369,5 @@ sub generate_nagios_config {
print_nagios_service_check($remote, $hostname, "process - cron",
"check_procs_cron", "1:15!1:25")
if (is_pkg_installed($hostid, "cron"));
-
-# print_nagios_service_check($remote, $hostname, "dhcp",
-# "check_dhcp")
-# if is_pkg_installed($hostid, "dhcp3-server");
-
- # Check FTP server
- print_nagios_service_check($remote, $hostname, "ftp",
- "check_ftp")
- if is_pkg_installed($hostid, "proftpd");
-
}
}