<?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 script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708165#M723558</link>
    <description>All,&lt;BR /&gt;&lt;BR /&gt;I have a ping script that I want to build in a condition that it emails me if during the ping routine there are any packet losses.&lt;BR /&gt;&lt;BR /&gt;Here is my script that pipes the output to a log file.&lt;BR /&gt;&lt;BR /&gt;In the log file, I am not sure how to grep for anything other than 0% in the packet loss.&lt;BR /&gt;&lt;BR /&gt;Thank you in advance,&lt;BR /&gt;&lt;BR /&gt;!/usr/bin/ksh&lt;BR /&gt;#&lt;BR /&gt;LOG_DIR=`date +"/tmp/%d"`;export LOG_DIR&lt;BR /&gt;mkdir -p $LOG_DIR &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;RETVAL=0&lt;BR /&gt;PATH=$PATH:/usr/sam/lbin:/usr/sam/bin:/usr/bin:/usr/sbin:/sbin;export PATH&lt;BR /&gt;#&lt;BR /&gt;echo "Subject: ping  sapdev Report for "`date` &amp;gt;&amp;gt;$LOG_DIR/pingsap.$$&lt;BR /&gt;date &amp;gt;&amp;gt; $LOG_DIR/pingsap&lt;BR /&gt;ping 10.10.12.52 -n 20 &amp;gt;&amp;gt;$LOG_DIR/pingsap&lt;BR /&gt;#&lt;BR /&gt;# mail out results&lt;BR /&gt;#&lt;BR /&gt;#sendmail nickd &amp;lt; /tmp/pingsap.$$&lt;BR /&gt;rm $LOG_DIR/pingsap.$$</description>
    <pubDate>Mon, 22 Apr 2002 14:17:23 GMT</pubDate>
    <dc:creator>Nick D'Angelo</dc:creator>
    <dc:date>2002-04-22T14:17:23Z</dc:date>
    <item>
      <title>script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708165#M723558</link>
      <description>All,&lt;BR /&gt;&lt;BR /&gt;I have a ping script that I want to build in a condition that it emails me if during the ping routine there are any packet losses.&lt;BR /&gt;&lt;BR /&gt;Here is my script that pipes the output to a log file.&lt;BR /&gt;&lt;BR /&gt;In the log file, I am not sure how to grep for anything other than 0% in the packet loss.&lt;BR /&gt;&lt;BR /&gt;Thank you in advance,&lt;BR /&gt;&lt;BR /&gt;!/usr/bin/ksh&lt;BR /&gt;#&lt;BR /&gt;LOG_DIR=`date +"/tmp/%d"`;export LOG_DIR&lt;BR /&gt;mkdir -p $LOG_DIR &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;RETVAL=0&lt;BR /&gt;PATH=$PATH:/usr/sam/lbin:/usr/sam/bin:/usr/bin:/usr/sbin:/sbin;export PATH&lt;BR /&gt;#&lt;BR /&gt;echo "Subject: ping  sapdev Report for "`date` &amp;gt;&amp;gt;$LOG_DIR/pingsap.$$&lt;BR /&gt;date &amp;gt;&amp;gt; $LOG_DIR/pingsap&lt;BR /&gt;ping 10.10.12.52 -n 20 &amp;gt;&amp;gt;$LOG_DIR/pingsap&lt;BR /&gt;#&lt;BR /&gt;# mail out results&lt;BR /&gt;#&lt;BR /&gt;#sendmail nickd &amp;lt; /tmp/pingsap.$$&lt;BR /&gt;rm $LOG_DIR/pingsap.$$</description>
      <pubDate>Mon, 22 Apr 2002 14:17:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708165#M723558</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2002-04-22T14:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708166#M723559</link>
      <description>Hi Nick,&lt;BR /&gt;Here is the script that I use. But I dont look for packet loss. This catches connection loss. You can modify it to email you if a host is down or fails. iphosts is a file with all the hostnames of ip addresses that you want to check in one collum. Like so:&lt;BR /&gt;&lt;BR /&gt;servera&lt;BR /&gt;serverb&lt;BR /&gt;serverc&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh &lt;BR /&gt;LANG=C &lt;BR /&gt;HOSTNAME_FILE=iphosts&lt;BR /&gt;for host in $(cat $HOSTNAME_FILE) &lt;BR /&gt;do &lt;BR /&gt;ping $host -n 1 | grep -q '1 packets received' &lt;BR /&gt;if [ $? = 0 ] &lt;BR /&gt;then &lt;BR /&gt;echo "$host: OK" &lt;BR /&gt;else &lt;BR /&gt;echo "$host: FAIL" &lt;BR /&gt;fi &lt;BR /&gt;done</description>
      <pubDate>Mon, 22 Apr 2002 14:24:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708166#M723559</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2002-04-22T14:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708167#M723560</link>
      <description>Hi Nick,&lt;BR /&gt;&lt;BR /&gt;try with&lt;BR /&gt;grep 'loss' &lt;LOGFILE&gt; | awk '{print $7}'&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;RGDS, Holger&lt;/LOGFILE&gt;</description>
      <pubDate>Mon, 22 Apr 2002 14:26:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708167#M723560</guid>
      <dc:creator>Holger Knoppik</dc:creator>
      <dc:date>2002-04-22T14:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708168#M723561</link>
      <description>Generic grep on positive numbers using perl&lt;BR /&gt;&lt;BR /&gt;l1:/u/usr/merijn 102 &amp;gt; for 10 12 100 13.8 0 9 0.0 120&lt;BR /&gt;foreach? echo "--- $i%"&lt;BR /&gt;foreach? echo "$i% packet loss" | perl -ne 'm/([\d.]+)\s*%/&amp;amp;&amp;amp;$1&amp;gt;0&amp;amp;&amp;amp;print'&lt;BR /&gt;foreach? end&lt;BR /&gt;--- 10%&lt;BR /&gt;10% packet loss&lt;BR /&gt;--- 12%&lt;BR /&gt;12% packet loss&lt;BR /&gt;--- 100%&lt;BR /&gt;100% packet loss&lt;BR /&gt;--- 13.8%&lt;BR /&gt;13.8% packet loss&lt;BR /&gt;--- 0%&lt;BR /&gt;--- 9%&lt;BR /&gt;9% packet loss&lt;BR /&gt;--- 0.0%&lt;BR /&gt;--- 120%&lt;BR /&gt;120% packet loss&lt;BR /&gt;l1:/u/usr/merijn 103 &amp;gt;</description>
      <pubDate>Mon, 22 Apr 2002 14:37:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708168#M723561</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-04-22T14:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708169#M723562</link>
      <description>....&lt;BR /&gt;# &lt;BR /&gt;# mail out results &lt;BR /&gt;# &lt;BR /&gt;PCT=`grep \^20 $LOG_DIR/pingsap | awk -F", " '{print $3}' | awk -F"%" '{print $1}'`&lt;BR /&gt;if [ $PCT = 0 ] &lt;BR /&gt;then &lt;BR /&gt;:&lt;BR /&gt;else &lt;BR /&gt;sendmail nickd &amp;lt; /tmp/pingsap&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;rm $LOG_DIR/pingsap</description>
      <pubDate>Mon, 22 Apr 2002 14:41:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708169#M723562</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-04-22T14:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708170#M723563</link>
      <description>take note of the space after the "," in the first awk statement ..</description>
      <pubDate>Mon, 22 Apr 2002 14:44:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708170#M723563</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-04-22T14:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708171#M723564</link>
      <description>Hi Nick,&lt;BR /&gt;Here is what I uses&lt;BR /&gt;&lt;BR /&gt;#!/bin/csh&lt;BR /&gt;set PING = "/etc/ping"&lt;BR /&gt;set COUNT = 3&lt;BR /&gt;&lt;BR /&gt;set RESULT = `$PING $PLOT_SERVER -n $COUNT |grep "packet loss" | awk '{print $7}&lt;BR /&gt;' | sed 's/%//'`&lt;BR /&gt;if ($RESULT &amp;gt;= 100) then&lt;BR /&gt;  echo "$PLOT_SERVER is down"&lt;BR /&gt;  /usr/bin/mailx -s "$PLOT_SERVER is down `date`" sachin &lt;BR /&gt;  exit&lt;BR /&gt;endif&lt;BR /&gt;&lt;BR /&gt;Sachin</description>
      <pubDate>Mon, 22 Apr 2002 15:13:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708171#M723564</guid>
      <dc:creator>Sachin Patel</dc:creator>
      <dc:date>2002-04-22T15:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708172#M723565</link>
      <description>S.K.&lt;BR /&gt;&lt;BR /&gt;Your script sample almost works, however, I only want to grep for % &amp;gt;0 on each ping which is setup to run through cron.&lt;BR /&gt;&lt;BR /&gt;Your script is mailing out the top of the log file on all instances and should only be sending mail on % &amp;gt; 0.&lt;BR /&gt;&lt;BR /&gt;Nickd</description>
      <pubDate>Mon, 22 Apr 2002 16:15:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708172#M723565</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2002-04-22T16:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708173#M723566</link>
      <description>Sachin,&lt;BR /&gt;&lt;BR /&gt;Thanks for your script, but it give me an error, Unmatched `.&lt;BR /&gt;&lt;BR /&gt;??&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 22 Apr 2002 16:23:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708173#M723566</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2002-04-22T16:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708174#M723567</link>
      <description>Here's one I wrote a while ago (backup when I liked csh).  It was mainly to check response time from our default gateway router.&lt;BR /&gt;</description>
      <pubDate>Mon, 22 Apr 2002 17:13:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708174#M723567</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2002-04-22T17:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708175#M723568</link>
      <description>Forgot to mention that the above script is written for Sun.  Modify accordingly if you want to use it on HP for any reason.&lt;BR /&gt;&lt;BR /&gt;Tom</description>
      <pubDate>Mon, 22 Apr 2002 17:14:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708175#M723568</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2002-04-22T17:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708176#M723569</link>
      <description>First of all , sorry for the "done" line, it should not be there .. :)&lt;BR /&gt;Try this ..&lt;BR /&gt;&lt;BR /&gt;# &lt;BR /&gt;# mail out results &lt;BR /&gt;# &lt;BR /&gt;PCT=`grep \^20 $LOG_DIR/pingsap | awk -F", " '{print $3}' | awk -F"%" '{print $1}'` &lt;BR /&gt;if (($PCT &amp;gt; 0)) &lt;BR /&gt;then &lt;BR /&gt;sendmail nickd &amp;lt; /tmp/pingsap&lt;BR /&gt;else &lt;BR /&gt;:&lt;BR /&gt;fi &lt;BR /&gt;rm $LOG_DIR/pingsap</description>
      <pubDate>Mon, 22 Apr 2002 17:27:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708176#M723569</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-04-22T17:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708177#M723570</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;Here is another snippet of using 'ping' that may be useful..&lt;BR /&gt;&lt;BR /&gt;cheers&lt;BR /&gt;&lt;BR /&gt;Chris&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ping ${SG_SERVICE_NAME} -n 3 | grep 100% &amp;gt;/dev/null&lt;BR /&gt;if [ "$?" = 0 ]; then&lt;BR /&gt;   echo "Unable to ping${SG_SERVICE_NAME}"&lt;BR /&gt;   echo "SG package probably down "&lt;BR /&gt;   exit 1&lt;BR /&gt;else&lt;BR /&gt;   echo "Ping of SG successful" &lt;BR /&gt;fi</description>
      <pubDate>Tue, 23 Apr 2002 01:44:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708177#M723570</guid>
      <dc:creator>Chris Richings</dc:creator>
      <dc:date>2002-04-23T01:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708178#M723571</link>
      <description>And my suggestion to catch your recently loss value in your logfile:&lt;BR /&gt;&lt;BR /&gt;LOSS=`tail -5 &lt;YOUR_LOGFILE&gt; | fgrep loss | awk '{print $7}' | tr '%' ' '`&lt;BR /&gt;if [ "$LOSS" -gt 0 ]&lt;BR /&gt;then&lt;BR /&gt;# your email&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Ruediger&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/YOUR_LOGFILE&gt;</description>
      <pubDate>Tue, 23 Apr 2002 06:00:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708178#M723571</guid>
      <dc:creator>Ruediger Noack</dc:creator>
      <dc:date>2002-04-23T06:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708179#M723572</link>
      <description>You can test this. It works !&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;CONN=`ping XX.XX.XX.XX -n 20 |grep "packet loss" | cut -d"," -f3 | cut -d"%" -f1`&lt;BR /&gt;if [ $CONN != 0 ]&lt;BR /&gt;then&lt;BR /&gt;    mailx ...... Connection problem&lt;BR /&gt;else&lt;BR /&gt;    Succesful connection&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Apr 2002 08:53:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708179#M723572</guid>
      <dc:creator>Virginia Borraz</dc:creator>
      <dc:date>2002-04-23T08:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708180#M723573</link>
      <description>Virginia, &lt;BR /&gt;&lt;BR /&gt;Your script is almost perfect for me.&lt;BR /&gt;&lt;BR /&gt;I just wanted to include the last three lines of my ping for example:&lt;BR /&gt;&lt;BR /&gt;--spock PING Statistics----&lt;BR /&gt;20 packets transmitted, 8 packets received, 60% packet loss&lt;BR /&gt;round-trip (ms)  min/avg/max = 20/20/21&lt;BR /&gt;Thu Apr 25 06:57:46 EDT 2002&lt;BR /&gt;&lt;BR /&gt;To the email so that these Microsoft Network "experts" NOT ;-)have the necessary information.&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Thu, 25 Apr 2002 10:15:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/2708180#M723573</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2002-04-25T10:15:04Z</dc:date>
    </item>
  </channel>
</rss>

