#!/usr/bin/perl # # Generate list of nodes to load from /etc/munin/munin.conf to check # all the machines reporting to sitesummary. use strict; use warnings; use SiteSummary; use Getopt::Std; sub usage { print <) { if (m/^ii *$pkgname /) { close($fh); return 1 } } close($fh); } return undef; } sub is_munin_client { my $hostid = shift; return is_pkg_installed($hostid, "munin-node"); } sub is_nagios_client { my $hostid = shift; return is_pkg_installed($hostid, "nagios-nrpe-server") || is_pkg_installed($hostid, "nagios-text") || is_pkg_installed($hostid, "nagios2") || is_pkg_installed($hostid, "nagios3"); } sub print_munin_list { for my $hostname (sort keys %hostnames) { next unless (is_munin_client($hostnames{$hostname})); # Using hostname as address, to avoid hardcoding IP addresses in # the file. Might be an idea to fetch the IP address from # system/ifconfig-a print < { name => 'samba', package => 'samba' }, 389 => { name => 'ldap', package => 'slapd' }, 631 => { name => 'CUPS', package => 'cupsys' }, 4949 => { name => 'munin', package => 'munin-node' }, 7100 => { name => 'xfs', package => 'xfs' }, # check X font server ); for my $port (sort { $a <=> $b } keys %tcpservices) { next if (exists $tcpservices{$port}->{package} && ! is_pkg_installed($hostid, $tcpservices{$port}->{package})); my $servicename = $tcpservices{$port}->{name}; print_nagios_service_check(0, $hostname, $servicename, "check_tcp", $port); } # The rest of the checks only work if NRPE is installed and configured next unless (is_nagios_client($hostid)); print_nagios_service_check($remote, $hostname, "swap", "check_swap", "10%!5%"); print_nagios_service_check($remote, $hostname, "current users", "check_users", "20!50"); print_nagios_service_check($remote, $hostname, "processes total", "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"); # check disk free space my $path = get_filepath_current($hostid, "/system/procmounts"); if ( -e $path ) { open (F, "<", $path) || die "unable to read from $path"; my %checked; while () { chomp; my ($device, $partition, $fs, $opts) = split; next if (exists $checked{$device}); next if ($fs eq "devpts" || $fs eq "autofs" || $fs eq "binfmt_misc" || $fs eq "fusectl" || $fs eq "iso9660" || $fs eq "nfs" || $fs eq "nfsd" || $fs eq "proc" || $fs eq "rootfs" || $fs eq "rpc_pipefs" || $fs eq "sysfs" || $fs eq "tmpfs" || $fs eq "usbfs"); $checked{$device} = 1; my $warn = 10; my $crit = 5; print_nagios_service_check($remote, $hostname, "disk $partition", "check_disk", "$warn%!$crit%!$partition"); } } # 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") if is_pkg_installed($hostid, "squid"); # Check SSH server print_nagios_service_check($remote, $hostname, "ssh", "check_ssh") if is_pkg_installed($hostid, "openssh-server"); print_nagios_service_check($remote, $hostname, "http", "check_http") if (is_pkg_installed($hostid, "apache") || is_pkg_installed($hostid, "apache2")); print_nagios_service_check($remote, $hostname, "ntp time server", "check_ntp", "-H!localhost") if (is_pkg_installed($hostid, "ntp") || is_pkg_installed($hostid, "ntp-server")); # Detect if cron no longer is running print_nagios_service_check($remote, $hostname, "process - cron", "check_procs_command", "1:15!1:25!cron") if (is_pkg_installed($hostid, "cron")); print_nagios_service_check($remote, $hostname, "dhcp", "check_dhcp") if is_pkg_installed($hostid, "dhcp3-server"); } }