LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-20-2013, 02:52 PM   #1
the_zone
Member
 
Registered: Nov 2008
Distribution: Slackware
Posts: 83

Rep: Reputation: 7
sending notifications between 2 pc's


I have two machines with slackware 14.0.
One, a supermicro server, running as (compute/login) server with enough disk space for users. Unfortunately it can not be woken up via an event in the BIOS. wol does work.

The second one, just a p4 with disks, will be used as backup server, probably I will use rsync. This one has an event wake-up and wol. This machine will only run when required an woken up by the first.

I need some way to know that the second was woken up by the first one.

I read about netcat and send-notify which can be used to display messages in a terminal. This is not really what I need.
 
Old 05-20-2013, 02:57 PM   #2
SavoTU
Member
 
Registered: Apr 2005
Distribution: Slackware64 Current
Posts: 199

Rep: Reputation: 40
Not sure if this will help but when i am waiting for things to boot i usually just use ping it should respond when its awake.
 
Old 05-20-2013, 04:08 PM   #3
ttk
Senior Member
 
Registered: May 2012
Location: Sebastopol, CA
Distribution: Slackware64
Posts: 1,038
Blog Entries: 27

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
If the second machine is powered down until woken, at which time it boots, then you can put a notification statement in the second machine's rc.local. Then it will notify you when it has finished booting up.

The statement you put in rc.local depends on the kind of notification you want:
Email: echo 'The backup machine just booted up' | mutt -x -s 'boot notification' you@yourdomain.com
HTTP: wget -q -O /dev/null 'http://yourdomain.com/cgi-bin/notification.cgi?note=backup+machine+booted'
.. etc

Or is the second machine suspended, to be unsuspended on WOL? That would require something else, perhaps a script running in the background which detects coming out of a long suspension:
perl -e 'my $tm = time(); while(1){sleep(3); if(time()-$tm > 60){print("put notification code here\n");} $tm = time();}'

There's probably some ACPI message that can be intercepted, but I'm not savvy enough on ACPI to know it. Maybe someone else can suggest how to use it.
 
Old 05-20-2013, 04:38 PM   #4
NeoMetal
Member
 
Registered: Aug 2004
Location: MD
Distribution: Slackware
Posts: 114

Rep: Reputation: 24
You can create pm-utils hooks such as described here https://wiki.archlinux.org/index.php...your_own_hooks to execute something on resume, what mechanism would be best for the actual notifying I don't really know, you could say, have machine A first execute something to wake up Machine B, then machine B on resume uses ssh to launch a second script to do the actual work, or in the case of rsync, simply run the rsync from machine B to pull data when it wakes up; and then machine A just wakes up B whenever it wants to be backed up.
 
Old 05-20-2013, 06:43 PM   #5
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
I keep certain files in sync among all of my systems. Seldom are all of them running at the same time.

I use rwall for visual confirmation of a system having booted successfully. For non visual confirmation (automation), which you likely seek, I use nothing more than ping (I run ping only once: ping -c1 -W1 $BACKUP_SERVER).

In your case, a script could run the wol command and then a simple while/done loop with a 10 second wait period (sleep 10) until ping returns an exit code of 0. Included in the while loop would be a self-forced termination counter that includes ample time for fsck delays during booting. Then run the script manually or from cron or at.
 
Old 05-20-2013, 10:35 PM   #6
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Hmm. How about an SNMP trap?
 
Old 05-21-2013, 07:10 AM   #7
the_zone
Member
 
Registered: Nov 2008
Distribution: Slackware
Posts: 83

Original Poster
Rep: Reputation: 7
@all

that is a lot of useful input. I need some time to digest that.
 
Old 05-23-2013, 04:09 AM   #8
the_zone
Member
 
Registered: Nov 2008
Distribution: Slackware
Posts: 83

Original Poster
Rep: Reputation: 7
I have decided that, by permission of.... , both machines will be on a different domain.
Therefor
- ping will not work
- snmp traps are under investigation
- ssh can work, see below.

I want to let the backup server check if the server at home is awake, if not, let wake it.
That could pose a problem if my Zyxel router does not support wol.
As far as I understood the entry for a pc with a certain mac/ip-address in the arp table stays active for 300 seconds in a router.
I need to check if I can manipulate this manually.

Nevertheless I have a backup plan.
I have a hp thin client which is relative power-friendly which I can leave powered-on.
So the wol of the server can be controlled from this thin client.

basically the back-up server script would look something like (give or take ...) :

Code:
#!/bin/sh

# only works with keys
ssh $USER@$SERVER exit
if [ $? = 0 ]
then
  #server alive, start rsync
  ssh $USER@SERVER "/etc/rc.d/rc.backup"
else
  #server not alive, wake up via thin-client
  ssh $USER@$THIN_CLIENT "/etc/rc.d/rc.wol"
  #wait at least 60 seconds
  sleep 60
  # then check every 10 seconds
  for i in $(seq 1 1 10)
  do
    ssh $USER@$SERVER exit
    if [ $? = 0 ]
    then
      #server alive, start rsync
      ssh $USER@SERVER "/etc/rc.d/rc.backup"
      # we are done, exit
      exit 
    fi
    sleep 10
  done
fi

best regards

ST

Last edited by the_zone; 05-23-2013 at 04:11 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Python script sending email notifications to only one user kaplan71 Programming 3 10-03-2012 05:54 PM
sending of email notifications LayTech Linux - Newbie 7 07-23-2010 08:24 AM
Sending email notifications on a Squid proxy server RedHelix Linux - Server 4 09-12-2009 10:54 AM
Postfix - how to disable sending undelivered mail notifications tikit Linux - Networking 0 08-06-2009 04:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration