diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2006-08-27 21:21:46 +0000 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2006-08-27 21:21:46 +0000 |
commit | 139b4c54cfee7d63bcfc457ecf5978a4d39d5265 (patch) | |
tree | b279d96f98145cf81c29a178dd1a0050a963c1a1 /SiteSummary.pm | |
parent | 8602a0decca0e71668855b789bebd81c48960aa5 (diff) | |
download | sitesummary-139b4c54cfee7d63bcfc457ecf5978a4d39d5265.tar.gz sitesummary-139b4c54cfee7d63bcfc457ecf5978a4d39d5265.tar.bz2 sitesummary-139b4c54cfee7d63bcfc457ecf5978a4d39d5265.tar.xz |
* Reduce code duplication in SiteSummary.pm. Add new function
get_sitegroup().
* Extend site-summary script to also entries per sitegroup within a
site.
Diffstat (limited to 'SiteSummary.pm')
-rw-r--r-- | SiteSummary.pm | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/SiteSummary.pm b/SiteSummary.pm index fefb947..bd3107e 100644 --- a/SiteSummary.pm +++ b/SiteSummary.pm @@ -9,10 +9,11 @@ our $VERSION = 0.01; our @ISA = qw(Exporter); our @EXPORT = qw( for_all_hosts - get_filepath_current + get_filepath_current get_site + get_sitegroup get_sitecontact - get_linux_kernel_ver + get_linux_kernel_ver ); my $pwd = "/var/lib/sitesummary/entries"; # Path to the entries @@ -23,27 +24,43 @@ sub get_filepath_current { } # -# Return the site string +# Return the value string from a file, ignoring comments # -sub get_site { - my $hostid = shift; - my $path = get_filepath_current($hostid, "/siteinfo/site"); - my $site; +sub get_file_string { + my ($hostid, $filename) = @_; + my $path = get_filepath_current($hostid, $filename); + my $string; if (open (FILE, $path)) { while(<FILE>) { chomp; s/\#.+$//; next if (/^\s*$/); - $site = $_; + $string = $_; } close(FILE); - return $site; + return $string; } else { return undef; } } # +# Return the site string +# +sub get_site { + my $hostid = shift; + return get_file_string($hostid, "/siteinfo/site"); +} + +# +# Return the sitegroup string +# +sub get_sitegroup { + my $hostid = shift; + return get_file_string($hostid, "/siteinfo/sitegroup"); +} + +# # Return list with the mail addresses listed in sitecontact. # sub get_sitecontact { |