<?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: monitoring script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039886#M93969</link>
    <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This form also works.&lt;BR /&gt;PIDS=$(UNIX95= ps -C httpd -o pid=)&lt;BR /&gt;&lt;BR /&gt;If you use post 1 some day you will whack a process you did not intend to whack.&lt;BR /&gt;&lt;BR /&gt;I had a process kill script working like post 1 and discovered to my horror in the lab that it could take down an entire system.&lt;BR /&gt;&lt;BR /&gt;It was easy enough to pull the script out of production at my current job, but I had to try and convince my previous employer to pull the script. In the end, all I could do was email management a disclaimer warning them that using this one script could damage their systems and hope for the best.&lt;BR /&gt;&lt;BR /&gt;Anyway, good luck.&lt;BR /&gt;&lt;BR /&gt;SEP&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 18 Jul 2007 18:13:51 GMT</pubDate>
    <dc:creator>Steven E. Protter</dc:creator>
    <dc:date>2007-07-18T18:13:51Z</dc:date>
    <item>
      <title>monitoring script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039883#M93966</link>
      <description>Hi there&lt;BR /&gt;&lt;BR /&gt;Command ps -e|grep httpd output is this :&lt;BR /&gt;&lt;BR /&gt; 2528 ?        00:00:00 httpd-matrix&lt;BR /&gt;29651 ?        00:00:00 httpd-matrix&lt;BR /&gt;29652 ?        00:00:00 httpd-matrix&lt;BR /&gt;32038 ?        00:00:00 httpd-matrix&lt;BR /&gt;18798 ?        00:00:00 httpd&lt;BR /&gt;18801 ?        00:00:00 httpd&lt;BR /&gt;18802 ?        00:00:00 httpd&lt;BR /&gt;18803 ?        00:00:00 httpd&lt;BR /&gt;18804 ?        00:00:00 httpd&lt;BR /&gt;&lt;BR /&gt;I need to build a script to monitor httpd:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;adminmail=peterk@mark.com&lt;BR /&gt;&lt;BR /&gt;if [ -z "`ps auxw|grep "httpd"|grep -v grep`" ]; then&lt;BR /&gt;  echo "apache down!!!"|mail -s "apache is down" $adminmail&lt;BR /&gt;&lt;BR /&gt;/etc/init.d/httpd start&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The problem is that the command ps auxw|grep "httpd"|grep -v grep` finds httpd-matrix (mongrel cluster process) and script thinks httpd is there, so it never executes /etc/init.d/httpd start.&lt;BR /&gt;&lt;BR /&gt;The question is, what can I change in this command :&lt;BR /&gt;&lt;BR /&gt;ps auxw|grep "httpd"|grep -v grep &lt;BR /&gt;&lt;BR /&gt;to exclude httpd-matrix from the search results ?&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Jul 2007 17:05:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039883#M93966</guid>
      <dc:creator>Piotr Kirklewski</dc:creator>
      <dc:date>2007-07-18T17:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: monitoring script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039884#M93967</link>
      <description>try ps auxw|grep "httpd"|grep -v grep|grep -v "httpd-matrix"</description>
      <pubDate>Wed, 18 Jul 2007 17:13:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039884#M93967</guid>
      <dc:creator>David Bellamy</dc:creator>
      <dc:date>2007-07-18T17:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: monitoring script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039885#M93968</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;You need to use the UNIX95 option of '-C' of 'ps':&lt;BR /&gt;&lt;BR /&gt;# PIDS=`UNIX95= ps -C httpd -o pid=`&lt;BR /&gt;&lt;BR /&gt;...will return an empty list if no processes with a basename of 'httpd' exist; or a list of one or more processes if it is running.&lt;BR /&gt;&lt;BR /&gt;This eliminates the fuzzy matching of the process list with 'grep' which can lead to spurious matches you don't want!&lt;BR /&gt;&lt;BR /&gt;Note the space (or tab) after 'UNIX95=' and before 'ps'.  This sets the UNIX95 behavior only foir the duration of the command line.  The equal sign after the 'pid' suppresses the header line "PID" from the output.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 18 Jul 2007 17:52:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039885#M93968</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-07-18T17:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: monitoring script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039886#M93969</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This form also works.&lt;BR /&gt;PIDS=$(UNIX95= ps -C httpd -o pid=)&lt;BR /&gt;&lt;BR /&gt;If you use post 1 some day you will whack a process you did not intend to whack.&lt;BR /&gt;&lt;BR /&gt;I had a process kill script working like post 1 and discovered to my horror in the lab that it could take down an entire system.&lt;BR /&gt;&lt;BR /&gt;It was easy enough to pull the script out of production at my current job, but I had to try and convince my previous employer to pull the script. In the end, all I could do was email management a disclaimer warning them that using this one script could damage their systems and hope for the best.&lt;BR /&gt;&lt;BR /&gt;Anyway, good luck.&lt;BR /&gt;&lt;BR /&gt;SEP&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Jul 2007 18:13:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039886#M93969</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2007-07-18T18:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: monitoring script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039887#M93970</link>
      <description>Fine&lt;BR /&gt;It works great with:&lt;BR /&gt;&lt;BR /&gt;ps -e|grep "httpd"|grep -v grep|grep -v "httpd-matrix&lt;BR /&gt;&lt;BR /&gt;If I run the script from command line it's working fine.&lt;BR /&gt;&lt;BR /&gt;But when cron is trying to run it then I get this message:&lt;BR /&gt;&lt;BR /&gt;Starting httpd: Syntax error on line 117 of /etc/httpd/conf.d/ssl.conf:&lt;BR /&gt;&lt;BR /&gt;SSLCertificateFile: file '/etc/httpd/conf/ssl.crt/server.crt' does not exist or is empty [FAILED]&lt;BR /&gt;&lt;BR /&gt;I don't understand why? As everythink is fine when I run the script from root account, I did chmod 777 on it, its in root crontab.&lt;BR /&gt;&lt;BR /&gt;Wht's wrong ?&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jul 2007 03:03:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039887#M93970</guid>
      <dc:creator>Piotr Kirklewski</dc:creator>
      <dc:date>2007-07-19T03:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: monitoring script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039888#M93971</link>
      <description>&lt;!--!*#--&gt;Maybe a suggestion for further "refinement"?&lt;BR /&gt;&lt;BR /&gt;Usually, you want to parse the PID of the httpd parent process (as you may have dozens of children currently servicing different clients).&lt;BR /&gt;&lt;BR /&gt;So you could match like this&lt;BR /&gt;&lt;BR /&gt;httpd_pid=$(UNIX95= ps -e -o pid= -o ppid= -o comm=|awk '$3~/httpd/&amp;amp;&amp;amp;$2==1{print$1}')&lt;BR /&gt;&lt;BR /&gt;if [[ -z $httpd_pid ]]; then&lt;BR /&gt;   # put event handler or notification code here&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;But even this is a poor test because you only see if some httpd parent proc is running&lt;BR /&gt;although the webserver for some reason might not be servicing its clients at all.&lt;BR /&gt;So better fetch a page or better yet, the HTTP server response to a HEAD request.&lt;BR /&gt;You can use any scriptable HTTP client for that like curl, wget, or even netcat or telnet.&lt;BR /&gt;I however, prefer the Perl LWP client reference script which comes with any current Perl installation.&lt;BR /&gt;&lt;BR /&gt;E.g.&lt;BR /&gt;&lt;BR /&gt;$ lwp-request -m head http://localhost/&lt;BR /&gt;200 OK&lt;BR /&gt;Connection: close&lt;BR /&gt;Date: Thu, 19 Jul 2007 08:39:00 GMT&lt;BR /&gt;Accept-Ranges: bytes&lt;BR /&gt;ETag: "8f3d-2028-303d3cc0"&lt;BR /&gt;Server: Apache/2.0.55  HP-UX_Apache-based_Web_Server (Unix) DAV/2 PHP/5.0.4 mod_jk/1.2.10&lt;BR /&gt;Content-Length: 8232&lt;BR /&gt;Content-Type: text/html&lt;BR /&gt;Last-Modified: Fri, 10 Feb 2006 14:03:07 GMT&lt;BR /&gt;Client-Date: Thu, 19 Jul 2007 08:39:00 GMT&lt;BR /&gt;Client-Peer: 127.0.0.1:80&lt;BR /&gt;Client-Response-Num: 1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But still this response is too much.&lt;BR /&gt;All you are usually interested in is the HTTP server's response code, normally a 200 &lt;BR /&gt;signalling successful delivery.&lt;BR /&gt;&lt;BR /&gt;$ lwp-request -m head -sd http://localhost/&lt;BR /&gt;200 OK&lt;BR /&gt;&lt;BR /&gt;This is a painless test with a terse response, easily parsable, and much better than simply a process table lookup.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jul 2007 03:45:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039888#M93971</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2007-07-19T03:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: monitoring script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039889#M93972</link>
      <description>&amp;gt;ps -e|grep "httpd"|grep -v grep|grep -v "httpd-matrix&lt;BR /&gt;&lt;BR /&gt;Should I assume the missing quote on the end is just a typo here?&lt;BR /&gt;&lt;BR /&gt;You can combine the grep -v:&lt;BR /&gt;$ ps -e | grep httpd | grep -v -e grep -e  httpd-matrix&lt;BR /&gt;&lt;BR /&gt;&amp;gt;If I run the script from command line it's working fine.&lt;BR /&gt;&lt;BR /&gt;Is it getting to?: /etc/init.d/httpd start&lt;BR /&gt;&lt;BR /&gt;When you're in a crontab, you don't have the same PATH.  In fact you don't have /sbin there.</description>
      <pubDate>Thu, 19 Jul 2007 03:45:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039889#M93972</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-07-19T03:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: monitoring script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039890#M93973</link>
      <description>Well as I said before its working great if I run the script from comamnd line, the only problem is why its not working when cron is trying to do that ?&lt;BR /&gt;Other scripts that are set in crontab are working fine, so my assumption is that it's Apache only problem.&lt;BR /&gt;On the other server I running similar script but for Apache2 and the situation is similar but cron is comming with different error message:&lt;BR /&gt;&lt;BR /&gt;(13)Permission denied: make_sock: could not bind to address [::]:80 (13)Permission denied: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs&lt;BR /&gt;&lt;BR /&gt;How do you think where is the problem?&lt;BR /&gt;As before if I run this script from command line the everythink is fine.&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jul 2007 04:58:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039890#M93973</guid>
      <dc:creator>Piotr Kirklewski</dc:creator>
      <dc:date>2007-07-19T04:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: monitoring script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039891#M93974</link>
      <description>&lt;!--!*#--&gt;If you are getting ssl.conf related errors&lt;BR /&gt;I assume that you didn't tell Apache to load the SSL engine.&lt;BR /&gt;I don't no what your config looks like,&lt;BR /&gt;but the HP port comes with this load directive in httpd.conf:&lt;BR /&gt;&lt;BR /&gt;&lt;IFDEFINE ssl=""&gt;&lt;BR /&gt;LoadModule ssl_module modules/mod_ssl.so&lt;BR /&gt;&lt;/IFDEFINE&gt;&lt;BR /&gt;&lt;BR /&gt;This means that a macro SSL is required to be set to execute this block,&lt;BR /&gt;which is usually achieved by something like&lt;BR /&gt;&lt;BR /&gt;/opt/hpws/apache/sbin/httpd -k start -DSSL&lt;BR /&gt;&lt;BR /&gt;If you have an apachectl script lingering somewhere look for the startssl case/esac block.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jul 2007 05:20:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/monitoring-script/m-p/4039891#M93974</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2007-07-19T05:20:42Z</dc:date>
    </item>
  </channel>
</rss>

