aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SiteSummary.pm26
-rw-r--r--debian/changelog2
-rwxr-xr-xsitesummary-nodes32
3 files changed, 58 insertions, 2 deletions
diff --git a/SiteSummary.pm b/SiteSummary.pm
index 630c003..f5a1db4 100644
--- a/SiteSummary.pm
+++ b/SiteSummary.pm
@@ -15,6 +15,7 @@ our @EXPORT = qw(
get_sitegroup
get_hostname
get_dns_address
+ get_primary_macaddress
get_linux_kernel_ver
get_debian_edu_profile
get_debian_edu_ver
@@ -81,7 +82,7 @@ sub get_hostclass {
sub get_primary_ip_address {
my $hostid = shift;
my $path = get_filepath_current($hostid, "/system/ifconfig-a");
- # XXX Not implemented
+ # XXX Not properly implemented, just pick the first IP
my $ip;
if (open (FILE, $path)) {
while(<FILE>) {
@@ -99,6 +100,29 @@ sub get_primary_ip_address {
}
#
+# Return the IP address on the primary network interface
+#
+sub get_primary_macaddress {
+ my $hostid = shift;
+ my $path = get_filepath_current($hostid, "/system/ifconfig-a");
+ # XXX Not properly implemented, just pick the first interface
+ my $macaddress;
+ if (open (FILE, $path)) {
+ while(<FILE>) {
+ chomp;
+ if (m/Link encap:Ethernet\s+HWaddr (\S+)\s+/) {
+ $macaddress = $1;
+ last;
+ }
+ }
+ close(FILE);
+ return $macaddress;
+ } else {
+ return undef;
+ }
+}
+
+#
# Return the hostname string
#
sub get_hostname {
diff --git a/debian/changelog b/debian/changelog
index cd1a110..53c80c1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,8 @@
sitesummary (0.0.41) UNRELEASED; urgency=low
* Accept nagios3 clients as nagios clients.
+ * New argument -w to sitesummary-nodes, to list DNS name and MAC address,
+ for use with wakeonlan packages.
-- Petter Reinholdtsen <pere@debian.org> Sun, 8 Jun 2008 14:20:40 +0200
diff --git a/sitesummary-nodes b/sitesummary-nodes
index 1cc8741..cc0b376 100755
--- a/sitesummary-nodes
+++ b/sitesummary-nodes
@@ -10,7 +10,7 @@ use SiteSummary;
use Getopt::Std;
my %opts;
-getopts("mn", \%opts);
+getopts("mnw", \%opts);
my %hostnames;
@@ -18,11 +18,14 @@ for_all_hosts(\&handle_host);
if ($opts{'m'}) {
print_munin_list();
+} elsif ($opts{'w'}) {
+ print_ip_hw_list();
} elsif ($opts{'n'}) { # XXX Nagios config generation do not work yet
generate_nagios_config();
} else {
print_list();
}
+exit 0;
sub handle_host {
my $hostid = shift;
@@ -81,6 +84,33 @@ EOF
}
}
+sub get_primary_macaddress {
+ my $hostid = shift;
+ my $path = get_filepath_current($hostid, "/system/ifconfig-a");
+ # XXX Not properly implemented, just pick the first interface
+ my $macaddress;
+ if (open (FILE, $path)) {
+ while(<FILE>) {
+ chomp;
+ if (m/Link encap:Ethernet\s+HWaddr (\S+)\s+/) {
+ $macaddress = $1;
+ last;
+ }
+ }
+ close(FILE);
+ return $macaddress;
+ } else {
+ return undef;
+ }
+}
+
+sub print_ip_hw_list {
+ for my $hostname (sort keys %hostnames) {
+ my $macaddress = get_primary_macaddress($hostnames{$hostname});
+ print "$hostname $macaddress\n";
+ }
+}
+
sub generate_nagios_config {
for my $hostname (sort keys %hostnames) {
my $hostid = $hostnames{$hostname};