diff options
author | Marius Halden <marius.h@lden.org> | 2016-12-29 23:59:43 +0100 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2016-12-30 00:01:43 +0100 |
commit | f2fa73d4e1d2a298097c2eb06d1d355283096d4e (patch) | |
tree | b27749ae04ed401417dc078d3122489b9ee9631b | |
parent | 530bea6494b9199f21f7cd26c23ad9589177f64c (diff) | |
download | sitesummary-f2fa73d4e1d2a298097c2eb06d1d355283096d4e.tar.gz sitesummary-f2fa73d4e1d2a298097c2eb06d1d355283096d4e.tar.bz2 sitesummary-f2fa73d4e1d2a298097c2eb06d1d355283096d4e.tar.xz |
Hack together some support for check_ssh
-rwxr-xr-x | sitesummary-nodes | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/sitesummary-nodes b/sitesummary-nodes index 2ff836c..1f91226 100755 --- a/sitesummary-nodes +++ b/sitesummary-nodes @@ -22,11 +22,13 @@ Usage: $0 [-hmnw] EOF } +our @ssh_hosts = (); + # Idea for way to provide overrides for the functions in this script -#eval 'require "/etc/sitesummary/sitesummary-nodes-override"'; -#if ($@ && $@ !~ qr{^Can't locate /etc/sitesummary/sitesummary-nodes-override}) { -# die $@; -#}; +eval 'require "/etc/sitesummary/sitesummary-nodes-override"'; +if ($@ && $@ !~ qr{^Can't locate /etc/sitesummary/sitesummary-nodes-override}) { + die $@; +}; my %opts; getopts("hmnw", \%opts) || (usage(), exit(1)); @@ -62,6 +64,16 @@ if ($opts{'h'}) { } exit 0; +sub is_ssh_host { + my ($host) = @_; + + for (@ssh_hosts) { + return 1 if $_ eq $host; + } + + return 0; +} + sub handle_host { my $hostid = shift; my $address = get_dns_address($hostid); @@ -188,7 +200,12 @@ sub print_nagios_service_check { return if exists $nagios_ignore{"$hostname $description"}; my $cmd; if ($remote) { - $cmd = "check_nrpe!$check"; + if (is_ssh_host($hostname)) { + $cmd = "check_ssh!$check"; + } else { + $cmd = "check_nrpe!$check"; + } + if (defined $check_args) { $check_args =~ s/!/ /g; $cmd .= " -a $check_args"; @@ -259,6 +276,7 @@ sub generate_nagios_config { my $redirect = ""; my $nagiosclient = is_nagios_client($hostid); my $remote = is_remote_nagios_client($hostid); + my $sshhost = is_ssh_host($hostname); my $nrpestatus = is_remote_nrpe_config_active($hostid); # Only check laptops that have the nagios tools installed @@ -389,7 +407,7 @@ sub generate_nagios_config { # The rest of the checks only work if NRPE is installed and configured next unless ((!$remote && $nagiosclient) - || ($remote && defined $nrpestatus)); + || ($remote && (defined $nrpestatus || $sshhost))); # These work without any argument passing. @@ -464,7 +482,7 @@ sub generate_nagios_config { # These need argument passing (as in dont_blame_nrpe=1) next unless ((!$remote && $nagiosclient) - || ($remote && "args" eq $nrpestatus)); + || ($remote && ("args" eq $nrpestatus || $sshhost))); print_nagios_service_check($remote, $hostname, "swap", "check_swap", "10%!5%"); |