<?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: notification script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804427#M267136</link>
    <description>Here is a very handy-dandy Perl script for executing commands with a timeout. The command will exit with a status of 14 (SIGALRM) is the command times out. The signal handlers within Perl make it one of the best ways to do this from within a scripting language.&lt;BR /&gt;&lt;BR /&gt;In your script that is invoked by cron you should set and export the PATH that contains&lt;BR /&gt;your "pmi" executable. You should also make sure that you have a symbolic link in /usr/bin that points to the "real" perl exectutable.&lt;BR /&gt;&lt;BR /&gt;e.g. ln -s /opt/perl/bin/perl /usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;Your cronned script should look something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;PATH=${PATH}:/usr/bin:/xxx/yyy&lt;BR /&gt;export PATH&lt;BR /&gt;&lt;BR /&gt;# NOTE: /xxx/yyy is the directory that holds&lt;BR /&gt;# the pmi command; you should also set and # export any env variables needed by the &lt;BR /&gt;# command&lt;BR /&gt;&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;&lt;BR /&gt;timeoutcmd.pl -t 30 pmi -f &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;STAT=${?}&lt;BR /&gt;if [[ ${STAT} -ne 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Pmi failed; status ${STAT}" | mail mickey@mouse.com&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 12 Jun 2006 14:08:09 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2006-06-12T14:08:09Z</dc:date>
    <item>
      <title>notification script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804424#M267133</link>
      <description>Hi All. &lt;BR /&gt;Could someone help me to write a script on a hpux 11i. All it has to do is running one time per hour and giving the only the command "pmi -f" and if it doesn't return an output i can receive an printout like "application has stoped" and receive an email. &lt;BR /&gt;I'm not so familiar with scripting.&lt;BR /&gt;Thanks</description>
      <pubDate>Mon, 12 Jun 2006 13:09:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804424#M267133</guid>
      <dc:creator>Endrin</dc:creator>
      <dc:date>2006-06-12T13:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: notification script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804425#M267134</link>
      <description>Hi Endrin:&lt;BR /&gt;&lt;BR /&gt;Here's a general purpose process monitor. You can create a 'cron' task for it. Assume that you want to look for a process called "myproc" and mail/page if it isn't running: &lt;BR /&gt;&lt;BR /&gt;# [ -z "`UNIX95= ps -C myproc -o pid= -o comm=`" ] &amp;amp;&amp;amp; mailx -s "myproc" is not running!" root &amp;lt; /dev/null&lt;BR /&gt;&lt;BR /&gt;Change the 'myproc' to match the basename of the process that you're interested in monitoring. As shown, this generates a mail to 'root'.&lt;BR /&gt;&lt;BR /&gt;For example, since you want to watch a process called "pmi", substitute that string for "myproc" in the above code.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 12 Jun 2006 13:13:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804425#M267134</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-06-12T13:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: notification script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804426#M267135</link>
      <description>Hello James,&lt;BR /&gt;I just want to be more specific on this. The "pmi -f" lists a group of processes of the main application. When the application freeze up this command couldn't be executed. When I enter this command in the moment the system has hanged it stays on hold without giving a printout of the processes running. In that moment I can understand that the system has stopped and I want that the script gives the command "pmi" and if it returns a printout it says ok otherwise if the command doesn't return anything and stays on hold, the script wait for 30 sec and if he doesn't get a printout he send an email or a message and says that the system has stopped.&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jun 2006 13:36:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804426#M267135</guid>
      <dc:creator>Endrin</dc:creator>
      <dc:date>2006-06-12T13:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: notification script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804427#M267136</link>
      <description>Here is a very handy-dandy Perl script for executing commands with a timeout. The command will exit with a status of 14 (SIGALRM) is the command times out. The signal handlers within Perl make it one of the best ways to do this from within a scripting language.&lt;BR /&gt;&lt;BR /&gt;In your script that is invoked by cron you should set and export the PATH that contains&lt;BR /&gt;your "pmi" executable. You should also make sure that you have a symbolic link in /usr/bin that points to the "real" perl exectutable.&lt;BR /&gt;&lt;BR /&gt;e.g. ln -s /opt/perl/bin/perl /usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;Your cronned script should look something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;PATH=${PATH}:/usr/bin:/xxx/yyy&lt;BR /&gt;export PATH&lt;BR /&gt;&lt;BR /&gt;# NOTE: /xxx/yyy is the directory that holds&lt;BR /&gt;# the pmi command; you should also set and # export any env variables needed by the &lt;BR /&gt;# command&lt;BR /&gt;&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;&lt;BR /&gt;timeoutcmd.pl -t 30 pmi -f &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;STAT=${?}&lt;BR /&gt;if [[ ${STAT} -ne 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Pmi failed; status ${STAT}" | mail mickey@mouse.com&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jun 2006 14:08:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804427#M267136</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-06-12T14:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: notification script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804428#M267137</link>
      <description>Since "pmi -f" hangs, you may have to do something like:&lt;BR /&gt;&lt;BR /&gt;!#/usr/bin/sh&lt;BR /&gt;#&lt;BR /&gt;#Set your Environment&lt;BR /&gt;pmi -f &amp;gt; /tmp/app_test.dat &amp;amp;&lt;BR /&gt;&lt;BR /&gt;#If PMI Hangs, it should not write the file.&lt;BR /&gt;if [ -f /tmp/app_test.dat ]&lt;BR /&gt;then&lt;BR /&gt;  rm /tmp/app_test.dat&lt;BR /&gt;else&lt;BR /&gt;  mailx -s "App TEST Failed" admin@mydomain.com&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Something to start with anyway.&lt;BR /&gt;&lt;BR /&gt;...jcd...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jun 2006 14:08:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804428#M267137</guid>
      <dc:creator>Joseph C. Denman</dc:creator>
      <dc:date>2006-06-12T14:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: notification script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804429#M267138</link>
      <description>Put a &lt;BR /&gt;&lt;BR /&gt;sleep 30 after&lt;BR /&gt;&lt;BR /&gt;pmi -f &amp;gt; app_test.dat &amp;amp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;...jcd...</description>
      <pubDate>Mon, 12 Jun 2006 14:18:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804429#M267138</guid>
      <dc:creator>Joseph C. Denman</dc:creator>
      <dc:date>2006-06-12T14:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: notification script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804430#M267139</link>
      <description>&lt;!--!*#--&gt;Hi (again) Endin:&lt;BR /&gt;&lt;BR /&gt;Here's a simple Perl script to alert you to your hung command:&lt;BR /&gt;&lt;BR /&gt;# cat ./mympi&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $cmd   ="pmi -f";&lt;BR /&gt;my $tmout = $ARGV[0] =~ /\d+/ ? $ARGV[0] : 30;&lt;BR /&gt;eval {&lt;BR /&gt;    local   $SIG{ALRM} = sub { die "alarm call" };&lt;BR /&gt;    alarm   $tmout;&lt;BR /&gt;    system("$cmd");&lt;BR /&gt;    alarm   0;&lt;BR /&gt;};&lt;BR /&gt;alarm 0;&lt;BR /&gt;die "time-out!" if $@ &amp;amp;&amp;amp; $@ =~ /alarm call/;&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...Run as:&lt;BR /&gt;&lt;BR /&gt;# ./mypmi || mailx -s "Application stopped" root &amp;lt; /dev/null&lt;BR /&gt;&lt;BR /&gt;...If your command doesn't finish in 30-seconds (by default) you will get an email alert notification.  You can dynamically change the timeout by specifying the number of seconds at runtime:&lt;BR /&gt;&lt;BR /&gt;# ./mypmi || mailx -s "Application stopped" root &amp;lt; /dev/null&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 12 Jun 2006 15:52:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804430#M267139</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-06-12T15:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: notification script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804431#M267140</link>
      <description>And just a sanity check on running a script like this. If you decide to check every 5 minutes, be prepared for hundreds of emails on a weekend or holiday unless you have staff available to read the email 24x7. It is common to run these types of scripts and forget that the script will keep sending email forever until the problem is resolved. This can be very expensive if the destination is a cellphone or text pager.&lt;BR /&gt; &lt;BR /&gt;To avoid this type of problem, run the script with the response time under consideration. In other words, if it takes 30 minutes to locate someone to fix the problem, don't run the script more than once every 15-20 minutes. Be sure to consider problems during the weekend too.</description>
      <pubDate>Mon, 12 Jun 2006 17:02:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804431#M267140</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-06-12T17:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: notification script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804432#M267141</link>
      <description>It works. Thank you all.&lt;BR /&gt;I will assign the respective points to each of you.</description>
      <pubDate>Tue, 13 Jun 2006 14:12:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/notification-script/m-p/3804432#M267141</guid>
      <dc:creator>Endrin</dc:creator>
      <dc:date>2006-06-13T14:12:04Z</dc:date>
    </item>
  </channel>
</rss>

