Archive
IP Failover notification scripts
The ability to have IP failover on OS X Server, if you have services that absolutely, positively must remain running, is a beautiful thing. You can also configure it to send you an email to a specified address. though the default OS X notification is pretty uniformative. A couple of weeks ago, I got a notification from my one set of servers that looked like this:
From: root@localhost.localhost
Subject: Failover Notification: IP address[es] have gone down
Date: June 25, 2006 8:26:46 AM EDT
To: me@work.com
That was it. So I started looking around, by consulting both a coworker and AFP548.com’s writeups, to see if I could make this a little more informative. The answer was yes, you can. Here’s how.
1. Edit the following script on the failover script: /usr/libexec/NotifyFailover.
2. Look for the following section:
if [ “${_state}” = “up” ]; then
_state=”IP address[es] have come up”
elif [ “${_state}” = “down” ]; then
_state=”IP address[es] have gone down”
fi
Edit the “IP address[es] have come up” and “IP address[es] have gone down” lines to something that’s more informative. I edited mine to say “Primary.server.name has gone down. Failover.server.name has taken over for primary and will function as the mobile home server until Primary.server.name comes back on-line.” and “Primary.server.name has come up and has become available again. Failover.server.name has stopped all its failover services and is resuming its position as the failover server.
The result are emails that look like this:
From: root@localhost.localhost
Subject: Failover Notification: Primary.server.name has gone down. Failover.server.name has taken over for primary and will function as the mobile home server until Primary.server.name comes back on-line.
Date: July 21, 2006 8:40:57 AM EDT
To: me@work.com
From: root@localhost.localhost
Subject: Failover Notification: Primary.server.name has come up and has become available again. Failover.server.name has stopped all its failover services and is resuming its position as the failover server.
Date: July 21, 2006 8:45:28 AM EDT
To: me@work.com
Much more informative.
There’s still nothing in the body of the email though, and maybe you’ll want to add some ability to log what’s happened. So the fix for that is to put a couple of new scripts in the /Library/IPFailover/ip.address.of.primary/ directory. (For an explanation of how this is set up , see AFP548.com’s great writeup on this topic.) There should already be a couple of scripts in here, with a correctly configured failover, named PostAcq , PreAcq and PreRel. All should have numbers after them, like PostAcq10 and PreRel20. You’ll want to put your notification scripts as the last PostAqc and PreRel scripts.
My PostAqc notification script, to let the right people know that the primary’s gone down and the failover has taken over:
#!/bin/bash
# Post Acquire failover notification script
subject=”Primary.server.name has failed”
to=”me@work.com,me@mac.com,me@gmail.com,someonelse@work.com”
body=”Primary.server.name has failed. Failover.server.name has taken over all mobile home folder hosting responsibilities from Primary and will take over Primary.server.name’s functions until the primary server comes back online.”
# Send e-mail advising that a failover event has occured
echo “${body}” | mail -s “${subject}” “${to}”
logger “Sent alert email “${subject}” to “${to}”.”
My PreRel notification script, to let the right people know that the primary is back up and the failover has gone back to waiting:
#!/bin/bash
# Pre-Release script – run on failover server before returning priority to main server
subject=”Failover.server.name is returning priority to Primary.server.name”
to=”me@work.com,me@mac.com,me@gmail.com,someonelse@work.com”
body=”Primary.server.name has become available again. Failover.server.name has stopped all its failover services, unmounted the RAIDs that house the mobile home folders and is resuming its role as the failover server.”
# Send e-mail advising that a failback event has occurred
echo “${body}” | mail -s “${subject}” “${to}”
logger “Sent failback alert email “${subject}” to “${to}”.”
You’ll get emails that look like this:
From: root@localhost.localhost
Subject: Primary.server.name has failed
Date: July 21, 2006 10:19:27 AM EDT
To: me@work.com,me@mac.com,me@gmail.com,someonelse@work.com
Primary.server.name has failed. Failover.server.name has taken over all mobile home folder hosting responsibilities from primary and will take over Primary.server.name’s functions until the primary server comes back online.
From: root@localhost.localhost
Subject: Failover.server.name is returning priority to Primary.server.name
Date: July 21, 2006 10:22:14 AM EDT
To: me@work.com,me@mac.com,me@gmail.com,someonelse@work.com
Primary.server.name has become available again. Failover.server.name has stopped all its failover services, unmounted the RAIDs that house the mobile home folders and is resuming its role as the failover server.
Do you need to do all this, if you have only one set of servers that failover? Probably not. But if there’s any possibility for confusion, setting up a specific notification can help you out a lot with figuring out what’s happened when you first get notification.
UPDATE: It was pointed out to me that my notification email setup is wrong up above. There should be no spaces following the commas separating the email addresses. I’ve made the corrections in the entry.
Happy Fourth of July, everyone.
La and I are enjoying a lovely Independence Day. I took the opportunity offered by a lazy morning to clean up our home server room, something that’s been long overdue. We also went out to see Cars at the afternoon matinee. Weather permitting, we’ll have good weather to watch the fireworks by this evening.
I hope all of my readers, both foreign and domestic, have a happy and tyranny-free day. I’ll leave you with the words that made today possible.
When in the Course of human events it becomes necessary for one people to dissolve the political bands which have connected them with another and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature’s God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.
We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness. — That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed, — That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness. Prudence, indeed, will dictate that Governments long established should not be changed for light and transient causes; and accordingly all experience hath shewn that mankind are more disposed to suffer, while evils are sufferable than to right themselves by abolishing the forms to which they are accustomed. But when a long train of abuses and usurpations, pursuing invariably the same Object evinces a design to reduce them under absolute Despotism, it is their right, it is their duty, to throw off such Government, and to provide new Guards for their future security. — Such has been the patient sufferance of these Colonies; and such is now the necessity which constrains them to alter their former Systems of Government. The history of the present King of Great Britain is a history of repeated injuries and usurpations, all having in direct object the establishment of an absolute Tyranny over these States. To prove this, let Facts be submitted to a candid world.
He has refused his Assent to Laws, the most wholesome and necessary for the public good.
He has forbidden his Governors to pass Laws of immediate and pressing importance, unless suspended in their operation till his Assent should be obtained; and when so suspended, he has utterly neglected to attend to them.
He has refused to pass other Laws for the accommodation of large districts of people, unless those people would relinquish the right of Representation in the Legislature, a right inestimable to them and formidable to tyrants only.
He has called together legislative bodies at places unusual, uncomfortable, and distant from the depository of their Public Records, for the sole purpose of fatiguing them into compliance with his measures.
He has dissolved Representative Houses repeatedly, for opposing with manly firmness his invasions on the rights of the people.
He has refused for a long time, after such dissolutions, to cause others to be elected, whereby the Legislative Powers, incapable of Annihilation, have returned to the People at large for their exercise; the State remaining in the mean time exposed to all the dangers of invasion from without, and convulsions within.
He has endeavoured to prevent the population of these States; for that purpose obstructing the Laws for Naturalization of Foreigners; refusing to pass others to encourage their migrations hither, and raising the conditions of new Appropriations of Lands.
He has obstructed the Administration of Justice by refusing his Assent to Laws for establishing Judiciary Powers.
He has made Judges dependent on his Will alone for the tenure of their offices, and the amount and payment of their salaries.
He has erected a multitude of New Offices, and sent hither swarms of Officers to harass our people and eat out their substance.
He has kept among us, in times of peace, Standing Armies without the Consent of our legislatures.
He has affected to render the Military independent of and superior to the Civil Power.
He has combined with others to subject us to a jurisdiction foreign to our constitution, and unacknowledged by our laws; giving his Assent to their Acts of pretended Legislation:
For quartering large bodies of armed troops among us:
For protecting them, by a mock Trial from punishment for any Murders which they should commit on the Inhabitants of these States:
For cutting off our Trade with all parts of the world:
For imposing Taxes on us without our Consent:
For depriving us in many cases, of the benefit of Trial by Jury:
For transporting us beyond Seas to be tried for pretended offences:
For abolishing the free System of English Laws in a neighbouring Province, establishing therein an Arbitrary government, and enlarging its Boundaries so as to render it at once an example and fit instrument for introducing the same absolute rule into these Colonies
For taking away our Charters, abolishing our most valuable Laws and altering fundamentally the Forms of our Governments:
For suspending our own Legislatures, and declaring themselves invested with power to legislate for us in all cases whatsoever.
He has abdicated Government here, by declaring us out of his Protection and waging War against us.
He has plundered our seas, ravaged our coasts, burnt our towns, and destroyed the lives of our people.
He is at this time transporting large Armies of foreign Mercenaries to compleat the works of death, desolation, and tyranny, already begun with circumstances of Cruelty & Perfidy scarcely paralleled in the most barbarous ages, and totally unworthy the Head of a civilized nation.
He has constrained our fellow Citizens taken Captive on the high Seas to bear Arms against their Country, to become the executioners of their friends and Brethren, or to fall themselves by their Hands.
He has excited domestic insurrections amongst us, and has endeavoured to bring on the inhabitants of our frontiers, the merciless Indian Savages whose known rule of warfare, is an undistinguished destruction of all ages, sexes and conditions.
In every stage of these Oppressions We have Petitioned for Redress in the most humble terms: Our repeated Petitions have been answered only by repeated injury. A Prince, whose character is thus marked by every act which may define a Tyrant, is unfit to be the ruler of a free people.
Nor have We been wanting in attentions to our British brethren. We have warned them from time to time of attempts by their legislature to extend an unwarrantable jurisdiction over us. We have reminded them of the circumstances of our emigration and settlement here. We have appealed to their native justice and magnanimity, and we have conjured them by the ties of our common kindred. to disavow these usurpations, which would inevitably interrupt our connections and correspondence. They too have been deaf to the voice of justice and of consanguinity. We must, therefore, acquiesce in the necessity, which denounces our Separation, and hold them, as we hold the rest of mankind, Enemies in War, in Peace Friends.
We, therefor
e, the Representatives of the United States of America, in General Congress, Assembled, appealing to the Supreme Judge of the world for the rectitude of our intentions, do, in the Name, and by Authority of the good People of these Colonies, solemnly publish and declare, That these United Colonies are, and of Right ought to be Free and Independent States, that they are Absolved from all Allegiance to the British Crown, and that all political connection between them and the State of Great Britain, is and ought to be totally dissolved; and that as Free and Independent States, they have full Power to levy War, conclude Peace contract Alliances, establish Commerce, and to do all other Acts and Things which Independent States may of right do. — And for the support of this Declaration, with a firm reliance on the protection of Divine Providence, we mutually pledge to each other our Lives, our Fortunes and our sacred Honor.
Classic on Intel Macs, courtesy of SheepShaver.
I’ve gotten Mac OS 9.0.4 up and working on an Intel Mac, running off of SheepShaver. I can get out to the internet via ethernet or my workplace’s wireless network, so it looks like TCP is working fine. I can’t see the AppleTalk zones of my workplace though, though, so all printing looks like it’ll need to be set up via LPR. In terms of speed and screen redraw, it’s not that swift but it should be fine for a person who just needs to run one or two Mac OS applications.
Installing SheepShaver was fairly easy. I needed a Mac OS 9 CD (9.0, not 9.1 or 9.2.x.), a copy of a compatible Mac OS ROM (I used MacOS ROM 1.6 from MacOS ROM Update 1.0; use TomeViewer on a PPC Mac to extract the ROM from the installer,) sufficient space on my hard drive and a copy of SheepShaver (available from http://www.gibix.net/projects/sheepshaver/files/SheepShaver-2.3-0.20060514.1.MacOSX.tar.bz2 .)
I started off by launching the SheepShaverGUI program, which is a graphical program used to configure SheepShaver’s settings as well as make the disk images that SheepShaver uses to boot off of. I built a one gig-sized disk image, set that as my boot volume, set my ROM’s location, then had SheepShaver boot off of my OS 9 CD by selecting “Boot From CD-ROM” on the Volumes tab in SheepShaverGUI and hitting the Start button.
From that point, it was like a normal installation of Mac OS 9. Within SheepShaver’s window, the disk image showed up mounted like a normal hard drive. I selected that and installed OS 9 onto it. After that, I applied the Mac OS 9.0.4 update normally. That’s as far as SheepShaver supported, so I shutdown OS 9 and started customizing the settings. Here’s the settings I’m using with SheepShaver:
For Ethernet, using slirp will let you share OS X’s network connection.
Notes:
1. This isn’t like Classic, where OS 9 and OS X applications co-existed on the screen. OS 9’s running in its own X11 window.
2. The OS X hard drive shows up on the Mac OS 9 desktop as a drive called “Unix”. You can copy things from the Unix drive into the Mac OS 9 environment and vice-versa.
3. There’s some weirdness with the Unix drive, where it won’t show some folders. Specifically, it doesn’t show the Mac OS 9 “Applications (Mac OS 9)” or the “System Folder” folders, which is quite bizarre. Nothing I’ve done up to this point makes either folder (even renamed!) visible on the Unix drive.
4. If you have an OS 9 Desktop Folder on your Intel Mac’s drive, SheepShaver will pick up on it while mounting the Unix drive and show whatever is in there on your Mac OS 9 desktop as generic icons. This puzzled me for a bit, before I remembered that on Mac OS, every mounted drive had its own Desktop Folder and everything in those folders from all mounted drives showed up on the desktop.
5. Looks pretty stable, though as noted before, it’s not the swiftest. When I took a peek at Apple System Profiler, the hardware it reported itself running on was a Power Mac 9500 series, with a G4 processor, running at 100MHz.
(Cross-posted at TAB)
Recent Comments