<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Extracting ping information in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791401#M582071</link>
    <description>Hi&lt;BR /&gt;&lt;BR /&gt;try this:&lt;BR /&gt;&lt;BR /&gt;host=microsoft.com&lt;BR /&gt;ping $host -n 2 |awk -vhost=$host '/^round-trip/{&lt;BR /&gt;gsub("/",",",$NF)&lt;BR /&gt;print host " '"$(date '+%m/%d/%Y %H:%M')"' " "MIN,AVG,MAX " $NF&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;Regards</description>
    <pubDate>Thu, 22 Aug 2002 05:50:45 GMT</pubDate>
    <dc:creator>Andreas Voss</dc:creator>
    <dc:date>2002-08-22T05:50:45Z</dc:date>
    <item>
      <title>Extracting ping information</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791400#M582070</link>
      <description>Hi Friends,&lt;BR /&gt;&lt;BR /&gt;I would like to extract the output of the ping command in a comma deliminated format.&lt;BR /&gt;&lt;BR /&gt;For e.g.,&lt;BR /&gt;$ ping microsoft.com -n 2 &lt;BR /&gt;This will display the last 2 lines as:&lt;BR /&gt;8 packets transmitted, 8 packets received, 0% packet loss&lt;BR /&gt;round-trip (ms)  min/avg/max = 4/6/13&lt;BR /&gt;&lt;BR /&gt;I would like to get the output in the output file as:&lt;BR /&gt;&lt;BR /&gt;-----------------------------------------------&lt;BR /&gt;MICROSOFT.COM    DATE/TIME    MIN,AVG,MAX 4,6,13&lt;BR /&gt;----------------------------------------------&lt;BR /&gt;&lt;BR /&gt;I can use the following command to get the last 2 lines:&lt;BR /&gt;$ ping microsoft.com -n 2 | grep -e &lt;FIELD&gt; &lt;BR /&gt;&lt;BR /&gt;Hope this's not a difficult steps.&lt;BR /&gt;&lt;BR /&gt;Thankx&lt;BR /&gt;Sanjay&lt;BR /&gt;&lt;BR /&gt;&lt;/FIELD&gt;</description>
      <pubDate>Thu, 22 Aug 2002 05:34:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791400#M582070</guid>
      <dc:creator>Sanjay Verma</dc:creator>
      <dc:date>2002-08-22T05:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting ping information</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791401#M582071</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;try this:&lt;BR /&gt;&lt;BR /&gt;host=microsoft.com&lt;BR /&gt;ping $host -n 2 |awk -vhost=$host '/^round-trip/{&lt;BR /&gt;gsub("/",",",$NF)&lt;BR /&gt;print host " '"$(date '+%m/%d/%Y %H:%M')"' " "MIN,AVG,MAX " $NF&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 22 Aug 2002 05:50:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791401#M582071</guid>
      <dc:creator>Andreas Voss</dc:creator>
      <dc:date>2002-08-22T05:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting ping information</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791402#M582072</link>
      <description>Hi Sanjay,&lt;BR /&gt;&lt;BR /&gt;Try something like the following - I'm well aware there are shorter ways to reach the same results but the commands have been written for clarity!!!&lt;BR /&gt;&lt;BR /&gt;SYS=hpx87&lt;BR /&gt;STAT=`ping $SYS -n 2 | tail -1`&lt;BR /&gt;NUMS=`echo $STAT | awk '{print $5}'`&lt;BR /&gt;MIN=`echo $NUMS | cut -d'/' -f1`&lt;BR /&gt;AVG=`echo $NUMS | cut -d'/' -f2`&lt;BR /&gt;MAX=`echo $NUMS | cut -d'/' -f3`&lt;BR /&gt;echo "$SYS : `date` : $MIN,$AVG,$MAX"&lt;BR /&gt;&lt;BR /&gt;Ollie.</description>
      <pubDate>Thu, 22 Aug 2002 05:56:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791402#M582072</guid>
      <dc:creator>Ollie R</dc:creator>
      <dc:date>2002-08-22T05:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting ping information</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791403#M582073</link>
      <description>Hi Andreas,&lt;BR /&gt;&lt;BR /&gt;I really appreciate for your quick help. I need to further add the packet loss values after the MIN/AVG/MAX values, so that it can read as MIN/AVG/MAX/PCKTLOSS   w,x,y,z.&lt;BR /&gt;&lt;BR /&gt;Plus if it's not able to ping the server at any point of time, it should redirect the error mesg. to another output file.&lt;BR /&gt;&lt;BR /&gt;Thanks once again.&lt;BR /&gt;Sanjay&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Aug 2002 06:36:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791403#M582073</guid>
      <dc:creator>Sanjay Verma</dc:creator>
      <dc:date>2002-08-22T06:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting ping information</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791404#M582074</link>
      <description>Hi Sanjay,&lt;BR /&gt;&lt;BR /&gt;Try something like:&lt;BR /&gt;&lt;BR /&gt;========================================&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;file=/tmp/ping.$$&lt;BR /&gt;host=$1&lt;BR /&gt;&lt;BR /&gt;ping $host 8 -n 1 &amp;gt; $file 2&amp;gt;&amp;amp;1&lt;BR /&gt;grep -q -e unknown -e 100% $file&lt;BR /&gt;if [ $? -eq 0 ] ; then&lt;BR /&gt; cat $file &amp;gt;&amp;gt; /tmp/ping.err&lt;BR /&gt; rm $file&lt;BR /&gt; exit 1&lt;BR /&gt;fi&lt;BR /&gt;rm $file&lt;BR /&gt;&lt;BR /&gt;date=`date "+%d/%m/%y-%H:%M"`&lt;BR /&gt;&lt;BR /&gt;ping $host -n 2 |&lt;BR /&gt;awk '/packet loss/{pl=$(NF-2)}&lt;BR /&gt;/round-trip/{n=split($NF,v,"/")}&lt;BR /&gt;END{printf("%s %s %s,%s,%s,%s\n",host,date,v[1],v[2],v[3],pl)}' host=$host date="$date"&lt;BR /&gt;=============================================&lt;BR /&gt;&lt;BR /&gt;Errors stored in /tmp/ping.err&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Thu, 22 Aug 2002 07:34:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791404#M582074</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-08-22T07:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting ping information</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791405#M582075</link>
      <description>Hi Robin,&lt;BR /&gt;&lt;BR /&gt;Thanks for the details. I really appreciate. I've run the script and is working perfectly fine but when the host is not reachable it gives the following error mesg:&lt;BR /&gt;&lt;BR /&gt;cat: Cannot use /...../ping:xxxx as both input and output.&lt;BR /&gt;&lt;BR /&gt;Hope you can light something on this.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Sanjay&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Aug 2002 07:59:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791405#M582075</guid>
      <dc:creator>Sanjay Verma</dc:creator>
      <dc:date>2002-08-22T07:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting ping information</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791406#M582076</link>
      <description>Hi Sanjay,&lt;BR /&gt;&lt;BR /&gt;Can you show me the output of the 1st ping command for this host please?&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Thu, 22 Aug 2002 08:18:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791406#M582076</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-08-22T08:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting ping information</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791407#M582077</link>
      <description>Hi Robin,&lt;BR /&gt;&lt;BR /&gt;The output of the command is:&lt;BR /&gt;&lt;BR /&gt;myserver.com 23/08/02-09:39 11,14,18,0%&lt;BR /&gt;&lt;BR /&gt;But when the host is unreachable (wrong host name) it gives the following output:&lt;BR /&gt;&lt;BR /&gt;cat: Cannot use /home/skverma/SCRIPTS/tmp/ping.test as both input and output.&lt;BR /&gt;&lt;BR /&gt;Hope this is what you requried?&lt;BR /&gt;&lt;BR /&gt;~Sanjay&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Aug 2002 22:17:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791407#M582077</guid>
      <dc:creator>Sanjay Verma</dc:creator>
      <dc:date>2002-08-22T22:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting ping information</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791408#M582078</link>
      <description>Hi Ollie,&lt;BR /&gt;&lt;BR /&gt;Thanks for your contribution. Yes, I've checked and it's working fine but I would like to enhance it to include the packet loss also and if the server is not reachable, the error to be re-directed in some other output file.&lt;BR /&gt;&lt;BR /&gt;Hope this's not very difficult.&lt;BR /&gt;&lt;BR /&gt;~Sanjay&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Aug 2002 22:28:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791408#M582078</guid>
      <dc:creator>Sanjay Verma</dc:creator>
      <dc:date>2002-08-22T22:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting ping information</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791409#M582079</link>
      <description>Hi Ollie,&lt;BR /&gt;&lt;BR /&gt;I've modified the script like this:&lt;BR /&gt;&lt;BR /&gt;$ cat 3_script&lt;BR /&gt;HOST=myserver.com&lt;BR /&gt;STAT=`ping $HOST -n 2 | tail -1`&lt;BR /&gt;NUMS=`echo $STAT | awk '{print $5}'`&lt;BR /&gt;MIN=`echo $NUMS | cut -d'/' -f1`&lt;BR /&gt;AVG=`echo $NUMS | cut -d'/' -f2`&lt;BR /&gt;MAX=`echo $NUMS | cut -d'/' -f3`&lt;BR /&gt;&lt;BR /&gt;NO_PING=`ping melsrv1 -n 1 | tail -2 | grep -i loss`&lt;BR /&gt;A_OUTPUT=`echo $NO_PING | awk '{print $7}'`&lt;BR /&gt;LOSS=`echo $A_OUTPUT | cut -d '%' -f1`&lt;BR /&gt;&lt;BR /&gt;echo "$HOST: `date` : "MIN,AVG,MAX,LOSS: " $MIN,$AVG,$MAX,$LOSS"&lt;BR /&gt;&lt;BR /&gt;It's been a long time since I've brushed my scripting skill. But now only I need to capture the output in other file if the host is not available.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Sanjay&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Aug 2002 22:55:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791409#M582079</guid>
      <dc:creator>Sanjay Verma</dc:creator>
      <dc:date>2002-08-22T22:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting ping information</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791410#M582080</link>
      <description>Any further updates on this Guys??&lt;BR /&gt;&lt;BR /&gt;SKV</description>
      <pubDate>Mon, 26 Aug 2002 03:19:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-ping-information/m-p/2791410#M582080</guid>
      <dc:creator>Sanjay Verma</dc:creator>
      <dc:date>2002-08-26T03:19:04Z</dc:date>
    </item>
  </channel>
</rss>

