How do I set up a shell script using ifconfig?

I am running on AIX 5.3. I have a remote AIX server running on a generator. Many times the generator goes out and I only have a window of 15 mins with the network up and 30 mins the server is powered. I need help creating a script using ifconfig, where it goes out and checks the network every 5 mins and to see if the network is up. If the network is up thats fine. If the script detects the network is down, then I want the script to check the network in 5 mins to make sure the network has come back up or not and then repeat the same step; check it again in 5 mins, totaling 15 mins of checking. If the network has been down for 15 mins, then I want the script to shutdown the server before the generator runs out of power. I need this server to always perform a clean shutdown and not to abrubtly shutoff because the power goes out.

I don't think you want to use ifconfig for this type of monitoring. Using the ping utility is a better option or check the interface status with entstat. this could accidently bring the server down though if your having network issues. you could also run into issues if the power cycles in the middle of your script. you may think the network is up when 2 minutes later it goes off again and as a result your server may not shutdown in time.

Can you enable some remote monitoring to trigger an alarm/page to force someone manually do a shutdown remotely via modem perhaps?

Well I could try ping but I am horrible at shell scripting. Would you be able to write me a basic script of how to check if the network is up, to check it 3 times in 5 min intervals and if it is up continue, but if it is down then shutdown the server??

Also, we can't enable any remote work on it. The server is in a trailer in a remote area working off a generator. We have someone go out once a month to check on it. We have been having a lot of crashing shutdowns. My goal is to get a script running to get clean shutdowns.

THANK YOU