Attachment 'sitesummary-nodes.diff'

Download

   1 diff --git a/sitesummary-nodes b/sitesummary-nodes
   2 index 2ff836c..2431680 100755
   3 --- a/sitesummary-nodes
   4 +++ b/sitesummary-nodes
   5 @@ -22,11 +22,13 @@ Usage: $0 [-hmnw]
   6  EOF
   7  }
   8  
   9 +our @ssh_hosts = ();
  10 +
  11  # Idea for way to provide overrides for the functions in this script
  12 -#eval 'require "/etc/sitesummary/sitesummary-nodes-override"';
  13 -#if ($@ && $@ !~ qr{^Can't locate /etc/sitesummary/sitesummary-nodes-override}) {
  14 -#    die $@;
  15 -#};
  16 +eval 'require "/etc/sitesummary/sitesummary-nodes-override"';
  17 +if ($@ && $@ !~ qr{^Can't locate /etc/sitesummary/sitesummary-nodes-override}) {
  18 +    die $@;
  19 +};
  20  
  21  my %opts;
  22  getopts("hmnw", \%opts) || (usage(), exit(1));
  23 @@ -62,6 +64,16 @@ if ($opts{'h'}) {
  24  }
  25  exit 0;
  26  
  27 +sub is_ssh_host {
  28 +    my ($host) = @_;
  29 +
  30 +    for (@ssh_hosts) {
  31 +        return 1 if $_ eq $host;
  32 +    }
  33 +
  34 +    return 0;
  35 +}
  36 +
  37  sub handle_host {
  38      my $hostid = shift;
  39      my $address = get_dns_address($hostid);
  40 @@ -188,10 +200,16 @@ sub print_nagios_service_check {
  41      return if exists $nagios_ignore{"$hostname $description"};
  42      my $cmd;
  43      if ($remote) {
  44 -        $cmd = "check_nrpe!$check";
  45 +        if (is_ssh_host($hostname)) {
  46 +            $cmd = "check_by_ssh!$check";
  47 +        } else {
  48 +            $cmd = "check_nrpe!$check";
  49 +        }
  50 +
  51          if (defined $check_args) {
  52 +            $cmd .= " -a" if (!is_ssh_host($hostname));
  53              $check_args =~ s/!/ /g;
  54 -            $cmd .= " -a $check_args";
  55 +            $cmd .= " $check_args";
  56          }
  57      } else {
  58          $cmd = "$check";
  59 @@ -259,6 +277,7 @@ sub generate_nagios_config {
  60          my $redirect = "";
  61          my $nagiosclient = is_nagios_client($hostid);
  62          my $remote = is_remote_nagios_client($hostid);
  63 +        my $sshhost = is_ssh_host($hostname);
  64          my $nrpestatus = is_remote_nrpe_config_active($hostid);
  65  
  66          # Only check laptops that have the nagios tools installed
  67 @@ -389,7 +408,7 @@ sub generate_nagios_config {
  68  
  69          # The rest of the checks only work if NRPE is installed and configured
  70          next unless ((!$remote && $nagiosclient)
  71 -                     || ($remote && defined $nrpestatus));
  72 +                     || ($remote && (defined $nrpestatus || $sshhost)));
  73  
  74          # These work without any argument passing.
  75  
  76 @@ -464,7 +483,7 @@ sub generate_nagios_config {
  77  
  78          # These need argument passing (as in dont_blame_nrpe=1)
  79          next unless ((!$remote && $nagiosclient)
  80 -                     || ($remote && "args" eq $nrpestatus));
  81 +                     || ($remote && ("args" eq $nrpestatus || $sshhost)));
  82  
  83          print_nagios_service_check($remote, $hostname, "swap",
  84                                     "check_swap", "10%!5%");

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2016-12-30 00:40:04, 2.6 KB) [[attachment:sitesummary-nodes.diff]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.