How can I go about writing to a log file when AIX is shutting down, and again when it comes back up?
This is for the purpose of tracking total downtime.
Thanks in advance.
For AIX 4.3.3, I suppose you could put a script into /etc/rc.shutdown or in an /etc/rc.d/rcX.d script that when the system is shutting down it writes to a log file a statement that the system is shutting down and then the results of the date command. In the same script, for startup, you can have the script write to the same or a different log file that the system is coming up and give the date command output.
For info about the rc.d subdirectories, see /etc/rc.d/samples/README.txt.
If you aren't at 4.3.3, you could do basically the same thing through /etc/rc.shutdown and inittab.
The last command records the date/time mmm dd HH:MM when the system is shutdown and then again when it is rebooted. I would think that you could write a simple awk script to rip thru the last output and report back the downtime.
Since it deals with time, it would be more complex than the 2 minutes I have to post right now. But if you want I could come up with something by tomorrow. Just let me know. Einstein47 (Love is like PI - natural, irrational, endless, and very important.)
last shutdown | sed -n 1,1p
last reboot | sed -n 1,1p
execute the above two commands as script. Most of the time it works. ( I have to calculate the hours and minutes, Calculating inside a script is a big headache(!)
There is also `errpt` and `uptime`. If none of those system stamps are accurate enough, it may be simpler to stick a one-line script in /etc/rc.shutdown and one in /etc/inittab that just stamps a log file. Up to you which method you use. I like that sed from rraj. IBM Certified -- AIX 4.3 Obfuscation
There already is an rc entry in the inittab, so Yegolev is right, you should call it something else.
And I'd put the the logfile in the script, not in your inittab. Don't forget, you also will need to know when the system shuts down, so you are going to have to write something for /etc/rc.shutdown.
I think I've got it working. I put a script the calls both the last shutdown and last reboot commands, and it runs in the inittab.
I wasn't sure what the first element in the line was, but I guess it's some kind of unique identifier, and that's why rc wouldn't work (because it's already there). Correct me if I'm wrong.
Also, I'm redirecting in the script, not in the inittab (like bi suggested). Everything looks like it's working. I'm going to test a little more, but thanks to everyone who helped me out.
Many of the suggestions provided will account for downtime if the definition of downtime is that period the Server is shutdown, however in reality downtime should include those times that the Server may be up and running, but one or more critical services are not available. Not trying to nitpick here, but feel that this shouldn't be overlooked.
Many of our AIX machines run SAP/Oracle, and most of the others run just Oracle. That does not mean, however, that just because a machine is up that SAP is running. We have lots of discussion of what an "outage" means just because of such things, but the definition I think we all agree on is that it's an outage if the client cannot do any work. That's a really vague sort of thing and unfortunately management has a keen interest in it.
Your app probably has its own inittab line and perhaps a shutdown script as well, maybe you can tweak that a bit if it suits your purposes. It would also probably suit your purposes to implement an inaccurate system, like the simple one in this post, so that someone (from your team, of course) has to massage the outage data before it goes in a report. IBM Certified -- AIX 4.3 Obfuscation
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.