Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old November 1st, 2005, 01:54 PM
csross csross is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 105 csross User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 28 sec
Reputation Power: 5
script to remote monitor solaris servers

I have 2 Solaris servers that are mirror images of each other, one being live and the other the backup. I need to have server 2 continually check if server 1 is up, and if it isn't, take-on the identity (IP and hostname) of server 1 and continue working.

I was thinking or hoping I could do this in scripts. Maybe having server 2 ping server 1, and if server 2 doesn't get a response from server 1, become server 1.

I don't know how to do that though, and I'm not a heavy scripter.

If anyone has an idea about how I can accomplist this, please let me know.

Thanks

Reply With Quote
  #2  
Old November 1st, 2005, 02:13 PM
stdunbar stdunbar is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: May 2004
Location: Superior, CO, USA
Posts: 1,672 stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 1 h 18 m 59 sec
Reputation Power: 287
Send a message via ICQ to stdunbar Send a message via Yahoo to stdunbar
Sun sells a commercial product to do just this. You set up a private "heartbeat" network (either on the same physical link or a separate one) so that either of the two servers can take on the identity of the other one.

Writing it yourself isn't too bad - testing it is. Do you already have an rdist/rsync script to keep the file systems in sync? That would be the first step. Solaris comes with rdist which is very similar conceptually with the rsync in Linux.

After that, you'll want to look at the ifconfig command so that you can add an IP address when you detect a failure. I say add because it will be much simpler to manage - it won't be a permanent (survives a reboot) unless you also write it to disk.

Your biggest issue may be ARP caching. ARP, the address resolution protocol maps an IP address on your network to an Ethernet address. This information is cached on any machine that ever talked to one of your servers. It has a limited lifespan (TTL or time to live) but it is non-zero. Different O/S's handle this differently. The arp cache on Solaris can get quite big. I'm not sure about Windows.

Basically the issue will be that anything that was talking to the failed server may need some amount of time before it recognizes the second host. If both of the server machines were behind some sort of router or hub that could also be rebooted as part of the fail over process this would speed things up.
__________________
Need Java help? Want to help people who do? Sit down with a cup of Java at the hotjoe forums.

Reply With Quote
  #3  
Old November 2nd, 2005, 02:11 PM
csross csross is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 105 csross User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 28 sec
Reputation Power: 5
Thank you very much.

How can I tell if the server is still alive though? I was thinking about pinging the machine but if it is done in a script, I would have to test some sort of return code from the ping to see if its alive.

Any ideas?

Reply With Quote
  #4  
Old November 3rd, 2005, 11:40 AM
stdunbar stdunbar is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: May 2004
Location: Superior, CO, USA
Posts: 1,672 stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level)stdunbar User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 1 h 18 m 59 sec
Reputation Power: 287
Send a message via ICQ to stdunbar Send a message via Yahoo to stdunbar
As with almost all Unix programs ping exits with a zero if it is able to successfully ping the host and non-zero if not. A very simple script portion to test that would be something like:

Code:
#!/bin/bash

hostname="localhost"

ping $hostname > /dev/null 2>&1

if [ $? -eq 0 ]; then
        echo "The host $hostname is alive"
else
        echo "The host $hostname is not responding"
fi


Note that I used bash syntax - other shells are similar but maddeningly different enough to cause problems.

Reply With Quote
  #5  
Old November 4th, 2005, 01:25 PM
csross csross is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 105 csross User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 28 sec
Reputation Power: 5
Thank you very much for your help. What is the commercial product that does this?

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > script to remote monitor solaris servers


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway