<?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: I need a script .... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001218#M777771</link>
    <description>I found the answer</description>
    <pubDate>Tue, 05 Sep 2006 08:52:50 GMT</pubDate>
    <dc:creator>Voda</dc:creator>
    <dc:date>2006-09-05T08:52:50Z</dc:date>
    <item>
      <title>I need a script ....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001211#M777764</link>
      <description>Can anyone help me on making a script which makes possible to compare the time from a log with the real time.&lt;BR /&gt;&lt;BR /&gt;The log file looks like:&lt;BR /&gt;18:26:50  Maximum server connections 32...&lt;BR /&gt;and I want to compare it with the actual time and if it differ more than 5 minutes it sends me an email or a message to the screen. I have an HP-ux and Informix DB which the log is taken. It hangs every three weeks and it doesn't show nothing else that only stop to write on the log file. If you have another idea how to notice or you have a similar experience that the DB act like in this case you are pleased to help me on this.&lt;BR /&gt;I have tried everything like updating the DB, OS with no results.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank in advance to all who can help me&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Sep 2006 11:44:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001211#M777764</guid>
      <dc:creator>Voda</dc:creator>
      <dc:date>2006-09-04T11:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: I need a script ....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001212#M777765</link>
      <description>Hi Voda,&lt;BR /&gt;&lt;BR /&gt;sounds a bit like symptom treatment, but&lt;BR /&gt;try the attached script, using the logfile as $1&lt;BR /&gt;&lt;BR /&gt;But before that, modify the mail address in the script.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Mon, 04 Sep 2006 12:55:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001212#M777765</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2006-09-04T12:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: I need a script ....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001213#M777766</link>
      <description>#!/bin/sh&lt;BR /&gt;LOGF=/tmp/dbmon.log&lt;BR /&gt;if [ -s $LOGF ] ; then&lt;BR /&gt;PREV=$(cat $LOGF)&lt;BR /&gt;else&lt;BR /&gt;PREV=0&lt;BR /&gt;fi&lt;BR /&gt;CURR=$(cat /var/adm/syslog/syslog.log|&lt;BR /&gt;grep "Maximum server connections" |wc -l)&lt;BR /&gt;if [ $CURR -le $PREV ]; then&lt;BR /&gt;echo ALERT|mailx -s "DB HANGS" your@mail&lt;BR /&gt;fi&lt;BR /&gt;echo $CURR &amp;gt; $LOGF&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Run this script from crontab each 5 minutes.&lt;BR /&gt;The script counts strings with the needed pattern. If this number does not differ in 5 minute, you receive mail&lt;BR /&gt;&lt;BR /&gt;HTH</description>
      <pubDate>Mon, 04 Sep 2006 13:45:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001213#M777766</guid>
      <dc:creator>Victor Fridyev</dc:creator>
      <dc:date>2006-09-04T13:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: I need a script ....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001214#M777767</link>
      <description>John,&lt;BR /&gt;&lt;BR /&gt;Your script will use the time from the 10th before last line, as that is the tail default.&lt;BR /&gt;&lt;BR /&gt;Also, why not make awk do all the hard work while it has the data?!&lt;BR /&gt;&lt;BR /&gt;eg:&lt;BR /&gt;&lt;BR /&gt;TOTAL_LOG_SECONDS=$(tail -1 $1 | awk -F"[: ]" '{print $1*3600 + $2*60 + $3}')&lt;BR /&gt;&lt;BR /&gt;or by having awk also find the end:&lt;BR /&gt;&lt;BR /&gt;TOTAL_LOG_SECONDS=$(awk -F"[: ]" 'END{print $1*3600 + $2*60 + $3}' $1)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And finally here is a tweak which remembers the last piece of string that looked like a timestamp in the beginning of a line and then uses that at the END.&lt;BR /&gt;&lt;BR /&gt;TOTAL_LOG_SECONDS=$(awk '/^..:..:/{t=$1} END{split(t,a,":"); print a[1]*3600 + a[2]*60 + a[3]}' $1)&lt;BR /&gt;&lt;BR /&gt;awk could also do the current time, and perl even more easily so.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Sep 2006 21:33:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001214#M777767</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-09-04T21:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: I need a script ....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001215#M777768</link>
      <description>&lt;BR /&gt;Voda,&lt;BR /&gt;&lt;BR /&gt;Here is an other approach&lt;BR /&gt;&lt;BR /&gt;You could create a reference file with the same time as last log file modification time.&lt;BR /&gt;&lt;BR /&gt;Then when the script runs again you expect to see a more recent file.&lt;BR /&gt;If not, sound the bell.&lt;BR /&gt;&lt;BR /&gt;In psuedo code:&lt;BR /&gt;&lt;BR /&gt;touch -r $logdir/log $logdir/ref&lt;BR /&gt;while (1) {&lt;BR /&gt;&lt;BR /&gt;wait 10 minutes&lt;BR /&gt;&lt;BR /&gt;if (find $logdir -name log -newer ref) &lt;BR /&gt;then {&lt;BR /&gt;     # all is well, update reference file&lt;BR /&gt;     touch -r $logdir/log $logdir/ref&lt;BR /&gt;} else {&lt;BR /&gt;     tail $logdir/log | mail ...&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Sep 2006 21:54:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001215#M777768</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-09-04T21:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: I need a script ....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001216#M777769</link>
      <description>Hein,&lt;BR /&gt;&lt;BR /&gt;you are absolutely right that my suggestion does not read the correct line - thanks for pointing that out: I feel embarrassed.&lt;BR /&gt;And if I could handle awk as well as you, I would probably have done that...&lt;BR /&gt;&lt;BR /&gt;Voda,&lt;BR /&gt;you can remedy my prior suggestion by changing the line&lt;BR /&gt;tail  $1 | read  a b&lt;BR /&gt;to&lt;BR /&gt;tail -1 $1 | read  a b&lt;BR /&gt;&lt;BR /&gt;However, finding the root cause would be better.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Tue, 05 Sep 2006 02:20:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001216#M777769</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2006-09-05T02:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: I need a script ....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001217#M777770</link>
      <description>Hi Guys,&lt;BR /&gt;Thanks for your help. The script is working great.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Endrin</description>
      <pubDate>Tue, 05 Sep 2006 08:45:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001217#M777770</guid>
      <dc:creator>Voda</dc:creator>
      <dc:date>2006-09-05T08:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: I need a script ....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001218#M777771</link>
      <description>I found the answer</description>
      <pubDate>Tue, 05 Sep 2006 08:52:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/i-need-a-script/m-p/5001218#M777771</guid>
      <dc:creator>Voda</dc:creator>
      <dc:date>2006-09-05T08:52:50Z</dc:date>
    </item>
  </channel>
</rss>

