[debian-edu-commits] debian-edu/ 12/64: * Change wakeupclients to use fping to check for alive clints, to speed up the script. Reduce sleep time between wakeups to 5 seconds.

Mike Gabriel sunweaver at debian.org
Wed Oct 23 09:51:49 UTC 2013


This is an automated email from the git hooks/post-receive script.

sunweaver pushed a commit to branch master
in repository shutdown-at-night.

commit e5daae71cfeae2c45c6e557bbd9e848f36592856
Author: Petter Reinholdtsen <pere at hungry.com>
Date:   Fri Jun 13 06:55:33 2008 +0000

      * Change wakeupclients to use fping to check for alive clints, to speed
        up the script.  Reduce sleep time between wakeups to 5 seconds.
    
    git-svn-id: svn+ssh://svn.debian.org/svn/debian-edu/trunk/src/shutdown-at-night@41444 6e500793-9bee-0310-a5b0-9d0909bd054d
---
 debian/changelog |    2 ++
 debian/control   |    2 +-
 wakeupclients    |   14 ++++++++------
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 1d85c7b..32c8086 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ shutdown-at-night (0.2) UNRELEASED; urgency=low
   * Add server side cron job to start waking up clients at 06:30.
   * Change wakeupclients to log progress, and to check if a client is up
     before trying to wake it.
+  * Change wakeupclients to use fping to check for alive clints, to speed
+    up the script.  Reduce sleep time between wakeups to 5 seconds.
   * Correct typos in the shutdown-at-night script.
 
  -- Petter Reinholdtsen <pere at debian.org>  Sun,  8 Jun 2008 18:18:53 +0200
diff --git a/debian/control b/debian/control
index 5258be5..2f62fba 100644
--- a/debian/control
+++ b/debian/control
@@ -7,7 +7,7 @@ Build-Depends: debhelper (>= 5), cdbs
 
 Package: shutdown-at-night
 Architecture: all
-Depends: ${misc:Depends}, wakeonlan, ng-utils
+Depends: ${misc:Depends}, wakeonlan, ng-utils, fping
 Recommends: nvram-wakeup
 Description: System to shut down clients at night, and wake them in the morning
  Schedule shutdown in the evening, and uses nvram-wakeup or wakeonlan to wake
diff --git a/wakeupclients b/wakeupclients
index 40fe44f..b0b8a5d 100755
--- a/wakeupclients
+++ b/wakeupclients
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-my $delay = 20;
+my $delay = 5;
 my $wakeuplist = "/etc/shutdown-at-night/clients";
 
 my %hwaddrs;
@@ -17,13 +17,16 @@ while (<CLIENTS>) {
 }
 close(CLIENTS);
 
+my %alive;
+map { $alive{$_} = 1; } get_alive_list(keys %hwaddrs);
+
 # Calculate when to start, assuming 20-30 seconds between each host
 #my $duration = $delay * scalar keys %hwaddrs;
 #my $allup = time();
 
 # Start sending wakeup calls
 for my $ip (sort keys %hwaddrs) {
-    if (!alive($ip)) {
+    if (! defined $alive{$ip}) {
         syslog("sending wake-on-lan package to $ip [$hwaddrs{$ip}]");
         wakeup($ip, $hwaddrs{$ip});
         sleep $delay;
@@ -40,10 +43,9 @@ sub wakeup {
     `wakeonlan -i $ip $hwaddr`;
 }
 
-sub alive {
-    my $address = shift;
-    my $retval = system("ping -q -q -c 3 $address >/dev/null");
-    return (0 == $retval);
+sub get_alive_list {
+    my @addresses = @_;
+    return split(/\s+/, `fping -a @addresses`);
 }
 
 sub syslog {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/pkg-team/shutdown-at-night.git



More information about the debian-edu-commits mailing list