<?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: scripting help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863345#M98424</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can use the subroutine:&lt;BR /&gt;#################################################&lt;BR /&gt;spng() {&lt;BR /&gt;P=$(/etc/ping $1 64 1 |&lt;BR /&gt;awk 'NR==3||NR==4 {if($7=="100%") {printf("NO");exit}}&lt;BR /&gt;NR==5 {printf("OK") }')&lt;BR /&gt;if [ $P != "OK" ]; then&lt;BR /&gt;  return 1&lt;BR /&gt;else&lt;BR /&gt;  return 0&lt;BR /&gt;fi&lt;BR /&gt;}&lt;BR /&gt;#################################################&lt;BR /&gt;cat listfile | while read ADDR; do&lt;BR /&gt;if spng $ADDR; then&lt;BR /&gt;:&lt;BR /&gt;# The host answers&lt;BR /&gt;else&lt;BR /&gt;&lt;BR /&gt;(/etc/ping $ADDR 1500 10&lt;BR /&gt;fi&lt;BR /&gt;done &amp;gt; logfile&lt;BR /&gt;&lt;BR /&gt;BTW, I'm not sure that ping is a good tool for the purpose.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;</description>
    <pubDate>Sat, 16 Sep 2006 04:54:17 GMT</pubDate>
    <dc:creator>Victor Fridyev</dc:creator>
    <dc:date>2006-09-16T04:54:17Z</dc:date>
    <item>
      <title>scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863341#M98420</link>
      <description>Hello Friends,&lt;BR /&gt;&lt;BR /&gt;I have been asked to write a script that will constantly ping 14 devices ( shop tills ) and record the response time,host address and actual time.&lt;BR /&gt;&lt;BR /&gt;Because this will create a huge logfile I have suggested we run the ping and only alert when the response is over a certian limit.&lt;BR /&gt;&lt;BR /&gt;I have no problem with writing the ping check and limits however I am struggling to get my head around how I can ping 14 devices simaltaniously from one script - any ideas?&lt;BR /&gt;&lt;BR /&gt;cheers</description>
      <pubDate>Fri, 15 Sep 2006 03:38:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863341#M98420</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2006-09-15T03:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863342#M98421</link>
      <description>Hi,&lt;BR /&gt;how about:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;/usr/sbin/ping server1 &amp;amp;&lt;BR /&gt;/usr/sbin/ping server2 &amp;amp;&lt;BR /&gt;..&lt;BR /&gt;/usr/sbin/ping server14 &amp;amp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;run this script and redirect output &lt;BR /&gt;./x.sh &amp;gt; x.log</description>
      <pubDate>Fri, 15 Sep 2006 03:53:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863342#M98421</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-09-15T03:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863343#M98422</link>
      <description>Hi lawrenzo&lt;BR /&gt;&lt;BR /&gt;What about:&lt;BR /&gt;&lt;BR /&gt;( ping $HOST1 &amp;amp;&lt;BR /&gt;ping $HOST2 &amp;amp;&lt;BR /&gt;ping $HOST3 &amp;amp;&lt;BR /&gt;) | do_something&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rgds&lt;BR /&gt;HGH&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Sep 2006 03:53:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863343#M98422</guid>
      <dc:creator>Hemmetter</dc:creator>
      <dc:date>2006-09-15T03:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863344#M98423</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;a flexible way for me seems to be to write&lt;BR /&gt;- one script, monitoring one host supplied as parameter, printing an alert after n unsuccesful attempts to reach this host&lt;BR /&gt;- another script, calling script one for all hosts to monitor in a loop as background processes, like&lt;BR /&gt;&lt;BR /&gt;trap 'kill $pidlist' '1 2 3 15' # to be customized&lt;BR /&gt;for h in $allhosts&lt;BR /&gt;do&lt;BR /&gt;   ./one $h &amp;amp;&lt;BR /&gt;   pidlst="$pidlst $!"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;So you have control over your child processes via $pidlist.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Sat, 16 Sep 2006 04:14:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863344#M98423</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-09-16T04:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863345#M98424</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can use the subroutine:&lt;BR /&gt;#################################################&lt;BR /&gt;spng() {&lt;BR /&gt;P=$(/etc/ping $1 64 1 |&lt;BR /&gt;awk 'NR==3||NR==4 {if($7=="100%") {printf("NO");exit}}&lt;BR /&gt;NR==5 {printf("OK") }')&lt;BR /&gt;if [ $P != "OK" ]; then&lt;BR /&gt;  return 1&lt;BR /&gt;else&lt;BR /&gt;  return 0&lt;BR /&gt;fi&lt;BR /&gt;}&lt;BR /&gt;#################################################&lt;BR /&gt;cat listfile | while read ADDR; do&lt;BR /&gt;if spng $ADDR; then&lt;BR /&gt;:&lt;BR /&gt;# The host answers&lt;BR /&gt;else&lt;BR /&gt;&lt;BR /&gt;(/etc/ping $ADDR 1500 10&lt;BR /&gt;fi&lt;BR /&gt;done &amp;gt; logfile&lt;BR /&gt;&lt;BR /&gt;BTW, I'm not sure that ping is a good tool for the purpose.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;</description>
      <pubDate>Sat, 16 Sep 2006 04:54:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863345#M98424</guid>
      <dc:creator>Victor Fridyev</dc:creator>
      <dc:date>2006-09-16T04:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863346#M98425</link>
      <description>Well, the first issue is that ping is a low level test and will succeed even when the machine is not working correctly. Secondly, ping does NOT return a failed exit code if the ping does not respond. It will return a failure code if the IP address or hostname is wrong but a ping to a reachable host will exit with zero status whether the ping was successful or not.&lt;BR /&gt; &lt;BR /&gt;So you must process the messages reported by ping. Also, ping may hang under some conditions so you'll need to put the ping in the background, then monitor the status every second to see if the ping completes. Naturally, you need to ping just once to see if the host responds -- using multiple pings per host makes parsing tricky. If the ping doesn't complete, kill the ping process and report on the problem.&lt;BR /&gt; &lt;BR /&gt;I have attached a simple script that will take an unlimited list of IP or hostnames (comments ignored) and reports on success or failure. You'll need to modify the script for reporting.&lt;BR /&gt; &lt;BR /&gt;As mentioned, ping is a trivial test for functionality. pings may be fine but the system has big problems. That's why you need a separate monitoring system that queries the system about overall status -- HP OpenView products can do this as well as freeware like Nagios. These products cover both the network health as well as system health.</description>
      <pubDate>Sat, 16 Sep 2006 09:52:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/3863346#M98425</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-09-16T09:52:20Z</dc:date>
    </item>
  </channel>
</rss>

