diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2010-01-23 10:51:50 +0000 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2010-01-23 10:51:50 +0000 |
commit | 4e3992d756de63f01f2d1f02c4dccae8624f9a26 (patch) | |
tree | 5f5ea97c1f2447f9fdadaf220c5f9d5f4a736929 /sitesummary-nodes | |
parent | 4621c4dc41a22b6c1b7e3fdb94edc0ca0c62a2f8 (diff) | |
download | sitesummary-4e3992d756de63f01f2d1f02c4dccae8624f9a26.tar.gz sitesummary-4e3992d756de63f01f2d1f02c4dccae8624f9a26.tar.bz2 sitesummary-4e3992d756de63f01f2d1f02c4dccae8624f9a26.tar.xz |
* Allow numbers in Nagios host class names.
* Create Nagios host groups for Debian Edu profile and version
settings.
* Mention ignored laptops in generated Nagios config to make it
easier to figure out why a machine is not monitored.
Diffstat (limited to 'sitesummary-nodes')
-rwxr-xr-x | sitesummary-nodes | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/sitesummary-nodes b/sitesummary-nodes index 0b5b673..385359e 100755 --- a/sitesummary-nodes +++ b/sitesummary-nodes @@ -187,7 +187,7 @@ EOF sub nagios_hostgroup_namewash { my $name = shift; - $name =~ s/[^a-zA-Z_-]+/-/g; # Avoid illegal characteres + $name =~ s/[^0-9a-zA-Z_-]+/-/g; # Avoid illegal characteres return $name; } @@ -233,12 +233,31 @@ sub generate_nagios_config { my $remote = is_remote_nagios_client($hostid); my $nrpestatus = is_remote_nrpe_config_active($hostid); + # Only check laptops that have the nagios tools installed + if (is_laptop($hostid) && ! $remote && ! $nagiosclient) { + print "# Skipping laptop $hostname\n"; + next; + } + my $site = get_site($hostid) || "none"; my $sitegroup = get_sitegroup($hostid); + my $eduprofile = get_debian_edu_profile($hostid); + my $eduversion = get_debian_edu_ver($hostid); push(@groups, nagios_hostgroup_namewash("site-$site")); if ($sitegroup) { push(@groups, nagios_hostgroup_namewash("site-$site-$sitegroup")); } + if ($eduprofile) { + $eduprofile =~ s/^"|"$//g; # Remove "" around the values + for my $profile (split(/,\s*/, $eduprofile)) { + push(@groups, + nagios_hostgroup_namewash("edu-profile-$profile")); + } + } + if ($eduversion) { + $eduversion =~ s/^"|"$//g; # Remove "" around the values + push(@groups, nagios_hostgroup_namewash("edu-version-$eduversion")); + } my $hostclass = get_hostclass($hostid) || "none"; push(@groups, nagios_hostgroup_namewash("hostclass-$hostclass")); @@ -247,9 +266,6 @@ sub generate_nagios_config { $hostgroup{$group} = 1; } - # Only check laptops that have the nagios tools installed - next if is_laptop($hostid) && ! $remote && ! $nagiosclient; - my $defaultroute = get_dnsnameorip(get_default_route($hostid)); # Also check default route host @@ -426,7 +442,12 @@ sub generate_nagios_config { if (is_pkg_installed($hostid, "cron")); } - for my $name (sort keys %hostgroup) { - print_nagios_hostgroup($name) + if (%hostgroup) { + print <<EOF; +##################### host groups ####################### +EOF + for my $name (sort keys %hostgroup) { + print_nagios_hostgroup($name); + } } } |