AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
  • 1.  ping script with email option

    Posted Tue January 10, 2012 07:48 AM

    Originally posted by: misteraix


    Hi

    I need a script to be put in cron and this script should run everyday morning at 06:00 AM.

    I have a filed named "network_hosts" and the below are the contents of the file

    root@[/] #cat network_hosts
    frssit02.standardchartered.co.in
    frssit01.standardchartered.co.in
    cbspssit.standardchartered.co.in
    cbspsuat.standardchartered.co.in
    cbsappfs1.standardchartered.co.in
    cbsappfs2.standardchartered.co.in
    cbdodbfs2.standardchartered.co.in

    All the servers are live except cbdodbfs2.standardchartered.co.in as we have shutdown this lpar.

    The script should ping all the servers at 06:00 AM in the morning.

    Once the script has been run at 06:00 AM it should send me an email to me mentioning which servers are live and which one are dead.

    It would be better if the email I get looks like the below :

    frssit02.standardchartered.co.in - this server is alive
    frssit01.standardchartered.co.in - this server is alive
    cbspssit.standardchartered.co.in - this server is alive
    cbspsuat.standardchartered.co.in - this server is alive
    cbsappfs1.standardchartered.co.in - this server is alive
    cbsappfs2.standardchartered.co.in - this server is alive
    cbdodbfs2.standardchartered.co.in - this server is not alive, please contact the unix support team

    Please assist me with a script which will ping and then email me.
    #AIX-Forum


  • 2.  Re: ping script with email option

    Posted Tue January 10, 2012 08:38 AM

    Originally posted by: Kosala


    By the sound of it, you are looking for some one to do your job :). I suppose there is payment involved :).

    I can't give you a script but the following command can be a starting point.

    ping -c 1 -w 2 host name 1>/dev/null 2>/dev/null

    and try handling the return code ($?). A for loop to run through your serverlist might come handy.

    Cheers,
    Kosala
    #AIX-Forum


  • 3.  Re: ping script with email option

    Posted Tue January 10, 2012 09:31 AM

    Originally posted by: tony.evans


    I've no idea if this site is any good, but hey, can't be much worse than asking a bunch of strangers how to do your job.

    http://linuxcommand.org/writing_shell_scripts.php
    #AIX-Forum


  • 4.  Re: ping script with email option

    Posted Tue January 10, 2012 10:08 AM

    Originally posted by: orphy


    Did you try it on your own first? You shouldn't expect us writing an entire script for you. Asking for that is simply asking for troubles! Try things on your own and come back if you have specific problems.

    http://lmgtfy.com/?q=aix+ping+script
    Orphy
    #AIX-Forum