From: Michael Brown Date: Thu, 21 Jun 2001 16:26:20 +0000 (+0000) Subject: A spong.groups file that parses the hosts hash and automatically generates the X-Git-Tag: spong-2_4_6~17 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e9166147ce5e5dbc5825b3dcf7e669b1e45aa4a;p=spong.git A spong.groups file that parses the hosts hash and automatically generates the groups from that. --- diff --git a/config/spong.groups.auto b/config/spong.groups.auto new file mode 100755 index 0000000..56f2ac1 --- /dev/null +++ b/config/spong.groups.auto @@ -0,0 +1,60 @@ +# spong.groups - Defines groups for grouping of hosts +# This file parses the hosts hash and adds each host to its appropriate group +# or groups. You need to put entries for each group in this file, at least. + +# $Id: spong.groups.auto,v 1.1 2001/06/21 16:26:20 supermathie Exp $ + +%GROUPS = ( + 'all' => { + name => 'All Systems', + summary => 'This group contains all hosts monitored by spong' }, + + 'fw-all' => { + name => "Firewall - All", + summary => "All firewalls" }, + + 'ns-all' => { + name => "DNS name servers - All", + summary => 'All DNS name servers' }, + + 'mail-all' => { + name => 'Mail servers', + summary => 'All mail servers' }, + + 'other' => { + name => "Other services", + summary => "Other services" }, +); + +foreach $host (sort keys(%HOSTS)) { + $groups = $HOSTS{$host}{"group"} || "other"; + foreach $group (split(/[\s,]+/,$groups)) { + if (!defined($GROUPS{$group})) { + &debug("warning - $host in nonexistant group $group\n"); last; + } + if (!defined($GROUPS{$group}{"members"})) { + $GROUPS{$group}{"members"} = []; + } + push(@{$GROUPS{$group}{"members"}}, $host); + } +} + +## This is code to print out a corresponding groups hash. +# print "\%GROUPS = (\n"; +# foreach $group (keys(%GROUPS)) { +# $disp = $group || "other"; +# $name = $GROUPS{$group}{"name"} || $disp; +# $summ = $GROUPS{$group}{"summary"} || $name; +# +# print "\t'$disp' => {\n\tname => '$name',\n\tsummary => '$summ',\n"; +# print "\tmembers => [\n"; +# foreach $host (@{$GROUPS{$group}{"members"}}) { +# print "\t\t'$host',\n"; +# } +# print "\t] },\n\n"; +# } +# print ");\n\n"; +# print "1;\n"; + +1; +# vim:syn=perl:expandtab:ts=3:sw=3:ai:si