--- /dev/null
+# 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