cvs: peardoc /en/package/system system-procwatch.xml /en/package/system/system-procwatch constants.xml intro.xml system-procwatch.xml
/en/package/system/system-procwatch/system-procwatch-config frominifile.xml fromxml.xml fromxmlfile.xml

From: Date: Fri, 30 Jan 2004 17:01:17 +0000
Subject: cvs: peardoc /en/package/system system-procwatch.xml /en/package/system/system-procwatch constants.xml intro.xml system-procwatch.xml
/en/package/system/system-procwatch/system-procwatch-config frominifile.xml fromxml.xml fromxmlfile.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-2263@lists.php.net to get a copy of this message
mike Fri Jan 30 12:01:17 2004 EDT Added files: /peardoc/en/package/system/system-procwatch intro.xml Modified files: /peardoc/en/package/system system-procwatch.xml /peardoc/en/package/system/system-procwatch constants.xml system-procwatch.xml /peardoc/en/package/system/system-procwatch/system-procwatch-config frominifile.xml fromxml.xml fromxmlfile.xml Log: * added intro with examples

http://cvs.php.net/diff.php/peardoc/en/package/system/system-procwatch.xml?r1=1.1&r2=1.2&ty=u Index: peardoc/en/package/system/system-procwatch.xml diff -u peardoc/en/package/system/system-procwatch.xml:1.1 peardoc/en/package/system/system-procwatch.xml:1.2 --- peardoc/en/package/system/system-procwatch.xml:1.1 Sat Nov 22 15:15:14 2003 +++ peardoc/en/package/system/system-procwatch.xml Fri Jan 30 12:01:15 2004 @@ -1,12 +1,13 @@ -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <sect1 id="package.system.system-procwatch"> <title>System_ProcWatch</title> + &package.system.system-procwatch.intro; + &package.system.system-procwatch.constants; &package.system.system-procwatch.system-procwatch; &package.system.system-procwatch.system-procwatch-config; &package.system.system-procwatch.system-procwatch-parser; - &package.system.system-procwatch.constants; </sect1> <!-- Keep this comment at the end of the file http://cvs.php.net/diff.php/peardoc/en/package/system/system-procwatch/constants.xml?r1=1.1&r2=1.2&ty=u Index: peardoc/en/package/system/system-procwatch/constants.xml diff -u peardoc/en/package/system/system-procwatch/constants.xml:1.1 peardoc/en/package/system/system-procwatch/constants.xml:1.2 --- peardoc/en/package/system/system-procwatch/constants.xml:1.1 Sat Nov 22 15:15:14 2003 +++ peardoc/en/package/system/system-procwatch/constants.xml Fri Jan 30 12:01:16 2004 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="package.system.system-procwatch.constants"> <refnamediv> <refname>Constants</refname> @@ -16,45 +16,36 @@ <para> <table> <title>Constants defined in ProcWatch.php</title> - <tgroup cols="2"> + <tgroup cols="1"> <thead> <row> <entry>Name</entry> - <entry>Value</entry> </row> </thead> <tbody> <row> - <entry>PHP_PROCWATCH_IS</entry> - <entry>103</entry> + <entry>SYSTEM_PROCWATCH_IS</entry> </row> <row> - <entry>PHP_PROCWATCH_ISNOT</entry> - <entry>104</entry> + <entry>SYSTEM_PROCWATCH_ISNOT</entry> </row> <row> - <entry>PHP_PROCWATCH_MAX</entry> - <entry>106</entry> + <entry>SYSTEM_PROCWATCH_MAX</entry> </row> <row> - <entry>PHP_PROCWATCH_MIN</entry> - <entry>105</entry> + <entry>SYSTEM_PROCWATCH_MIN</entry> </row> <row> - <entry>PHP_PROCWATCH_PRESENCE</entry> - <entry>100</entry> + <entry>SYSTEM_PROCWATCH_PRESENCE</entry> </row> <row> - <entry>PHP_PROCWATCH_PRESENCE_MAX</entry> - <entry>102</entry> + <entry>SYSTEM_PROCWATCH_PRESENCE_MAX</entry> </row> <row> - <entry>PHP_PROCWATCH_PRESENCE_MIN</entry> - <entry>101</entry> + <entry>SYSTEM_PROCWATCH_PRESENCE_MIN</entry> </row> <row> - <entry>PHP_PROCWATCH_SUM</entry> - <entry>107</entry> + <entry>SYSTEM_PROCWATCH_SUM</entry> </row> </tbody> </tgroup> http://cvs.php.net/diff.php/peardoc/en/package/system/system-procwatch/system-procwatch.xml?r1=1.1&r2=1.2&ty=u Index: peardoc/en/package/system/system-procwatch/system-procwatch.xml diff -u peardoc/en/package/system/system-procwatch/system-procwatch.xml:1.1 peardoc/en/package/system/system-procwatch/system-procwatch.xml:1.2 --- peardoc/en/package/system/system-procwatch/system-procwatch.xml:1.1 Sat Nov 22 15:15:14 2003 +++ peardoc/en/package/system/system-procwatch/system-procwatch.xml Fri Jan 30 12:01:16 2004 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="package.system.system-procwatch.system-procwatch"> <refnamediv> <refname><classname>System_ProcWatch</classname></refname> @@ -7,7 +7,7 @@ <refsect1> <title>System_ProcWatch</title> <para>Monitor processes</para> - <para>Usage: <programlisting role="php-highlighted"> + <para>Usage: <programlisting role="php"> 1 require_once &apos;System/ProcWatch.php&apos;; 2 require_once &apos;System/ProcWatch/Config.php&apos;; 3 http://cvs.php.net/diff.php/peardoc/en/package/system/system-procwatch/system-procwatch-config/frominifile.xml?r1=1.1&r2=1.2&ty=u Index: peardoc/en/package/system/system-procwatch/system-procwatch-config/frominifile.xml diff -u peardoc/en/package/system/system-procwatch/system-procwatch-config/frominifile.xml:1.1 peardoc/en/package/system/system-procwatch/system-procwatch-config/frominifile.xml:1.2 --- peardoc/en/package/system/system-procwatch/system-procwatch-config/frominifile.xml:1.1 Sat Nov 22 15:15:15 2003 +++ peardoc/en/package/system/system-procwatch/system-procwatch-config/frominifile.xml Fri Jan 30 12:01:17 2004 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="package.system.system-procwatch.system-procwatch-config.frominifile"> <refnamediv> @@ -27,36 +27,6 @@ <example id="package.system.system-procwatch.system-procwatch-config.frominifile.example"> <title>INI configuration file</title> <programlisting> -<![CDATA[ -; -; Example INI file to configure System::ProcWatch -; -; Be aware that you only can define shell executes! -; For better configurablity use XML configuration files. -; -[httpd] -pattern=/httpd/ -match=command -condition=presence -min=10 -max=50 -execute="echo $msg >> /var/log/procwatch" - -[zombies] -pattern=/Z/ -match=stat -condition=presence -max=0 -execute="kill -9 `echo $pids | sed s/[,\(\)]//g`" - -[mysqld-mem] -pattern=/mysqld/ -match=command -condition=attr -attr=%mem -sum=10 -execute="echo $msg >> /var/log/procwatch" -]]> </programlisting> </example> </refsect1> @@ -94,6 +64,13 @@ </para> </refsect1> + <refsect1 id="package.system.system-procwatch.system-procwatch-config.frominifile.see"> + &title.see; + <para> + <link linkend="package.system.system-procwatch.intro.configuration.ini">Configuration by INI file</link> + </para> + </refsect1> + <refsect1 id="package.system.system-procwatch.system-procwatch-config.frominifile.note"> &title.note; &note.shouldstatic; http://cvs.php.net/diff.php/peardoc/en/package/system/system-procwatch/system-procwatch-config/fromxml.xml?r1=1.1&r2=1.2&ty=u Index: peardoc/en/package/system/system-procwatch/system-procwatch-config/fromxml.xml diff -u peardoc/en/package/system/system-procwatch/system-procwatch-config/fromxml.xml:1.1 peardoc/en/package/system/system-procwatch/system-procwatch-config/fromxml.xml:1.2 --- peardoc/en/package/system/system-procwatch/system-procwatch-config/fromxml.xml:1.1 Sat Nov 22 15:15:15 2003 +++ peardoc/en/package/system/system-procwatch/system-procwatch-config/fromxml.xml Fri Jan 30 12:01:17 2004 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="package.system.system-procwatch.system-procwatch-config.fromxml"> <refnamediv> @@ -59,6 +59,13 @@ </para> </refsect1> + <refsect1 id="package.system.system-procwatch.system-procwatch-config.fromxml.see"> + &title.see; + <para> + <link linkend="package.system.system-procwatch.intro.configuration.xml">Configuration by XML file</link> + </para> + </refsect1> + <refsect1 id="package.system.system-procwatch.system-procwatch-config.fromxml.note"> &title.note; &note.shouldstatic; http://cvs.php.net/diff.php/peardoc/en/package/system/system-procwatch/system-procwatch-config/fromxmlfile.xml?r1=1.1&r2=1.2&ty=u Index: peardoc/en/package/system/system-procwatch/system-procwatch-config/fromxmlfile.xml diff -u peardoc/en/package/system/system-procwatch/system-procwatch-config/fromxmlfile.xml:1.1 peardoc/en/package/system/system-procwatch/system-procwatch-config/fromxmlfile.xml:1.2 --- peardoc/en/package/system/system-procwatch/system-procwatch-config/fromxmlfile.xml:1.1 Sat Nov 22 15:15:15 2003 +++ peardoc/en/package/system/system-procwatch/system-procwatch-config/fromxmlfile.xml Fri Jan 30 12:01:17 2004 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="package.system.system-procwatch.system-procwatch-config.fromxmlfile"> <refnamediv> @@ -23,112 +23,6 @@ <para> Parses an XML file into an config array to configure System_ProcWatch with. </para> - - <example id="package.system.system-procwatch.system-procwatch-config.fromxmlfile.example"> - <title>XML configuration file</title> - <programlisting> -&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt; -&lt;!DOCTYPE procwatch SYSTEM &quot;/usr/share/pear/data/System_ProcWatch/procwatch-1_0.dtd&quot;&gt; -&lt;procwatch&gt; -&lt;!-- - - SPECIAL VARIABLES - ================= - - System_ProcWatch supplies the following special variables, - which will be replaced in the string to execute: - - $msg - This contains a general message, what has happened. - It is quoted in single quotes for save usage and - is available in shell and php executes. - - $pids - This contains all PIDs of the processes that have been - found. They are enclosed by single quotes and parenthesis. - Example: '(433, 444, 455, 466)' - - $procs - This is a somewhat serialized php array in string format - containing all information gained from ps and looks like: - array(array('pid' =&gt; 344, 'command' =&gt; '/usr/sbin/httpd' ...)) - It is only available in php executes and can easily be used - in function callbacks: - &lt;execute type=&quot;php&quot;&gt;get_procs($procs);&lt;/execute&gt; - - - - IMPORTANT NOTE - ============== - - The values of the &quot;match&quot; attribute of the &quot;pattern&quot; element and the - values of the &quot;attr&quot; attribute of the &quot;condition&quot; element are dependent - on the output of ps - more exactly on the column heads of ps. - - Therefore System_ProcWatch and its configuration is highly adjustable. - - ############################################################################ - - SOME EXAMPLE CONFIGURATIONS - =========================== - - This job looks for the count of running httpd processes by - matching the PCRE &quot;/httpd/&quot; against the COMMAND column of ps. - - If there are less than 10 or more than 30 httpd processes found - the speicified string is executed on the shell. ---&gt; - &lt;watch name=&quot;httpd-count&quot;&gt; - &lt;pattern match=&quot;command&quot;&gt;/httpd/&lt;/pattern&gt; - &lt;condition type=&quot;presence&quot;&gt; - &lt;min&gt;10&lt;/min&gt; - &lt;max&gt;30&lt;/max&gt; - &lt;/condition&gt; - &lt;execute type=&quot;shell&quot;&gt;echo $msg $pids &amp;gt;&amp;gt; /var/log/procwatch&lt;/execute&gt; - &lt;/watch&gt; - -&lt;!-- - This job looks for the amount of physical memory all httpd processes use - together by matching the PCRE &quot;/httpd/&quot; against the COMMAND column of ps. - - It adds all %MEM columns of ps that match the pattern together and compares - the reslut to the specified sum. If the result exceeds the sum the specified - string is executet on the shell. ---&gt; - &lt;watch name=&quot;httpd-usage&quot;&gt; - &lt;pattern match=&quot;command&quot;&gt;/httpd/&lt;/pattern&gt; - &lt;condition type=&quot;attr&quot; attr=&quot;%mem&quot;&gt; - &lt;sum&gt;5&lt;/sum&gt; - &lt;/condition&gt; - &lt;execute type=&quot;shell&quot;&gt;echo $msg $pids &amp;gt;&amp;gt; /var/log/procwatch&lt;/execute&gt; - &lt;/watch&gt; - -&lt;!-- - This job looks for zombie processes. - - It matches the PCRE &quot;/Z/&quot; against the STAT column of ps and executes the - specified string on the shell if more than 0 zombies have been found. ---&gt; - &lt;watch name=&quot;ZOMBIES&quot;&gt; - &lt;pattern match=&quot;stat&quot;&gt;/Z/&lt;/pattern&gt; - &lt;condition type=&quot;presence&quot;&gt; - &lt;max&gt;0&lt;/max&gt; - &lt;/condition&gt; - &lt;execute type=&quot;shell&quot;&gt;echo $msg $pids &amp;gt;&amp;gt; /var/log/procwatch&lt;/execute&gt; - &lt;/watch&gt; - -&lt;!-- - This job looks for running processes. - - It matches the PCRE pattern &quot;/R/&quot; against the STAT column of ps and executes - the specified string on the shell if any running processes have been found. ---&gt; - &lt;watch name=&quot;running&quot;&gt; - &lt;pattern match=&quot;stat&quot;&gt;/R/&lt;/pattern&gt; - &lt;condition type=&quot;presence&quot; /&gt; - &lt;execute type=&quot;shell&quot;&gt;echo $msg $pids &amp;gt;&amp;gt; /var/log/procwatch&lt;/execute&gt; - &lt;/watch&gt; - -&lt;/procwatch&gt; - </programlisting> - </example> </refsect1> <refsect1 id="package.system.system-procwatch.system-procwatch-config.fromxmlfile.param"> @@ -165,6 +59,13 @@ </para> </refsect1> + <refsect1 id="package.system.system-procwatch.system-procwatch-config.fromxmlfile.see"> + &title.see; + <para> + <link linkend="package.system.system-procwatch.intro.configuration.xml">Configuration by XML file</link> + </para> + </refsect1> + <refsect1 id="package.system.system-procwatch.system-procwatch-config.fromxmlfile.note"> &title.note; &note.shouldstatic; http://cvs.php.net/co.php/peardoc/en/package/system/system-procwatch/intro.xml?r=1.1&p=1 Index: peardoc/en/package/system/system-procwatch/intro.xml +++ peardoc/en/package/system/system-procwatch/intro.xml <!-- $Revision: 1.1 $ --> <refentry id="package.system.system-procwatch.intro"> <refnamediv> <refname>Intro</refname> <refpurpose>Introduction to System::ProcWatch</refpurpose> </refnamediv> <refsect1 id="package.system.system-procwatch.intro.whatis"> <title>What is System::ProcWatch?</title> <para> System::ProcWatch is a small collection of classes to ease monitoring of system processes based on the Unix program procps (<command>ps</command>). </para> <para> To use System::ProcWatch you simply have to define a ruleset on which based System::ProcWatch operates. A rule (or job, watch) defines what actions should happen if a condition evaluates to true. </para> <para> <!-- XXX TODO: rules/conditions/actions --> To be continued... </para> </refsect1> <refsect1 id="package.system.system-procwatch.intro.shellscripts"> <title>Shell Scripts</title> <para> You can use System::ProcWatch out of the box, by utilizing the shipped shell scripts <command>procwatch</command> and <command>procwatch-lint</command>. </para> <refsect2 id="package.system.system-procwatch.intro.shellscripts.procwatch"> <title><command>procwatch</command></title> <para> The <command>procwatch</command> command is meant to be used for system diagnosis - run as daemon or by cron. </para> <para> The usage is best described by the output of <command>procwatch -h</command>: <programlisting> <![CDATA[ USAGE: $ procwatch (-x|-i) <file> [-d [-s <sec>]] [-a <args>] [-p <file>] OPTIONS: -x | --xml= path to XML configuration file -i | --ini= path to INI configuration file -d | --daemon run procwatch in daemon mode -s | --sleep= seconds to sleep in daemon mode (default=1800) -a | --args= arguments that should be passed to ps (default=aux) -p | --php= php file that should be included -h | --help this help message EXAMPLE: $ procwatch -x /etc/procwatch.xml -d -s 3600 This command will run procwatch in daemon mode with an interval of an hour using the configuration file '/etc/procwatch.xml' ]]> </programlisting> </para> </refsect2> <refsect2 id="package.system.system-procwatch.intro.shellscripts.procwatchlint"> <title><command>procwatch-lint</command></title> <para> The <command>procwatch-lint</command> is meant to validate procwatchs configurtation files written in XML by utilizing XML::DTD::XmlValidator. </para> <para> Once again synopsis is best described by the output of <command>procwatch-lint -h</command>: <programlisting> <![CDATA[ USAGE: $ procwatch -c <file> [-d <dtd>] [-v] OPTIONS: -c | --conf= path to XML configuration file -d | --dtd= path to DTD -v | --verbose verbose output on errors -h | --help this help message EXAMPLE: procwatch-lint -c /etc/procwatch.xml This command will validate the configuration file '/etc/procwatch.xml' using the DTD at '/usr/share/pear/data/System_ProcWatch/procwatch-1.0.dtd' ]]> </programlisting> </para> </refsect2> </refsect1> <refsect1 id="package.system.system-procwatch.intro.configuration"> <title>Configuration</title> <para> There are three methods to configure your System::ProcWatch application: <itemizedlist> <listitem> <simpara>XML string/file</simpara> </listitem> <listitem> <simpara>INI file</simpara> </listitem> <listitem> <simpara>PHP array</simpara> </listitem> </itemizedlist> </para> <refsect2 id="package.system.system-procwatch.intro.configuration.xml"> <title>Xml string/file</title> <para> Configuring System::ProcWatch by XML is the preferred way. It is as simple as powerful. </para> <refsect3 id="package.system.system-procwatch.intro.configuration.xml.root"> <title>The Root Element</title> <para> The root element of aon XML configuration file is the <emphasis>procwatch</emphasis> element. It has one implicit attribute, the <emphasis>version</emphasis> attribute set to &quot;1.0&quot;. </para> <para> The <emphasis>procwatch</emphasis> element symbolizes our ruleset, and the childs of the root are our rules. </para> </refsect3> <refsect3 id="package.system.system-procwatch.intro.configuration.xml.watch"> <title>The Childs of the Root</title> <para> The direct descendants of the root element <emphasis>procwatch</emphasis>, are the <emphasis>watch</emphasis> elements, which can occur 1 time or more often. </para> <para> The <emphasis>watch</emphasis> element has one required attribute, the <emphasis>name</emphasis> attribute, which gives the watch (or job, rule) a descriptive name like &quot;httpd-count&quot;. </para> <para> Each <emphasis>watch</emphasis> element symbolizes a single rule, containing a regular expression to search for, one or more conditions to evaluate and one or more actions to be taken. </para> </refsect3> <refsect3 id="package.system.system-procwatch.intro.configuration.xml.rule"> <title>A Rule</title> <para> A rule consists of three child elements: <itemizedlist> <listitem> <simpara> <emphasis>pattern</emphasis> </simpara> </listitem> <listitem> <simpara> <emphasis>condition</emphasis> </simpara> </listitem> <listitem> <simpara> <emphasis>execute</emphasis> </simpara> </listitem> </itemizedlist> </para> </refsect3> <refsect3 id="package.system.system-procwatch.intro.configuration.xml.rule.pattern"> <title>Rule Element: pattern</title> <para> The <emphasis>pattern</emphasis> element describes the regular expression which should be evaluated against a column of the output of <command>ps</command>. </para> <para> There is one required attribute, the <emphasis>match</emphasis> attribute, defining the column name of the output of <command>ps</command> in lowercase like &quot;command&quot; or &quot;vsz&quot;. </para> <para> This makes System::ProcWatch highliy versatile and should make it usable with any platforms <command>procps</command> program. </para> <para> The <emphasis>pattern</emphasis> elements content solely consits of the perl compatible regular expression to match against the column defined in the <emphasis>match</emphasis> attribute. The PCRE MUST contain the start and end delimiter and MAY contain any PCRE modifiers. </para> <para> Example: <![CDATA[<pattern match="command">/sbin\/httpd/</pattern>]]> </para> </refsect3> <refsect3 id="package.system.system-procwatch.intro.configuration.xml.rule.condition"> <title>Rule Element: condition</title> <para> The <emphasis>condition</emphasis> element defines conditions that MUST evaluate to &true; at all so that later defined actions will be executed. </para> <para> The <emphasis>condition</emphasis> element has one required and one optional attribute, the required one being <emphasis>type</emphasis>, which MUST be one of &quot;presence&quot; or &quot;attr&quot;, and the optional one being <emphasis>attr</emphasis>. However, if the <emphasis>type</emphasis> attribute equals &quot;attr&quot; the <emphasis>attr</emphasis> attribute MUST be present. </para> <para> The <emphasis>attr</emphasis> attribute represents a column of <command>procps</command>' output like &quot;user&quot; or &quot;%mem&quot;. </para> </refsect3> <refsect3 id="package.system.system-procwatch.intro.configuration.xml.condition.conditions"> <title>Conditions</title> <para> Dependent on the content of the <emphasis>type</emphasis> attribute, syntax and behavior of the <emphasis>condition</emphasis> element differ. </para> <para> A <emphasis>condition</emphasis> with <emphasis>type</emphasis> &quot;presence&quot; MAY be empty, thus always evaluating to true. </para> <para> Child Elements of <emphasis>condition</emphasis> may be: <itemizedlist> <listitem> <simpara> <emphasis>min</emphasis> </simpara> <simpara> Found value MUST exceed defined value. </simpara> </listitem> <listitem> <simpara> <emphasis>max</emphasis> </simpara> <simpara> Found value MUST NOT exceed defined value. </simpara> </listitem> <listitem> <simpara> <emphasis>is</emphasis> </simpara> <simpara> Found value MUST be defined value. </simpara> </listitem> <listitem> <simpara> <emphasis>isnot</emphasis> </simpara> <simpara> Found value MUST NOT be defined value. </simpara> </listitem> <listitem> <simpara> <emphasis>sum</emphasis> </simpara> <simpara> The sum of found values MUST NOT exceed defined sum. </simpara> </listitem> </itemizedlist> </para> <para> You may combine them to define for instance a range from min to max. </para> </refsect3> <refsect3 id="package.system.system-procwatch.intro.configuration.xml.rule.execute"> <title>Rule Element: execute</title> <para> The <emphasis>execute</emphasis> element defines actions that should be taken if the <emphasis>condition</emphasis> applies. </para> <para> It has one required attribute, the <emphasis>type</emphasis> attribute, which MUST equal to one of &quot;shell&quot; or &quot;php&quot;. </para> <para> Obviously the contents of the <emphasis>execute</emphasis> element is executed either on the shell through <function>shell_exec</function> or directly in PHP through <function>eval</function>. </para> <para> The <emphasis>execute</emphasis> element MAY occur any times. </para> <para> There are some special variables that will automagically be available in execute statements: <itemizedlist> <listitem> <simpara> <emphasis>$msg</emphasis> </simpara> <simpara> This contains a general message, what has happened. It is quoted in single quotes for save usage and is available in shell and php executes. </simpara> </listitem> <listitem> <simpara> <emphasis>$pids</emphasis> </simpara> <simpara> This contains all PIDs of the processes that have been found. They are enclosed by single quotes and parenthesis. </simpara> <simpara> Example: '(433, 444, 455, 466)' </simpara> </listitem> <listitem> <simpara> <emphasis>$procs</emphasis> </simpara> <simpara> This is a somewhat serialized php array in string format containing all information gained from ps and looks like: array(array('pid' =&gt; 344, 'command' =&gt; '/usr/sbin/httpd' ...)) </simpara> <simpara> It is only available in php executes and can easily be used in function callbacks: </simpara> <simpara> &lt;execute type=&quot;php&quot;&gt;get_procs($procs);&lt;/execute&gt; </simpara> </listitem> </itemizedlist> </para> </refsect3> </refsect2> <refsect2> <title>Example XML configuration file</title> <example id="package.system.system-procwatch.intro.configuration.xml.example"> <title>XML configuration file</title> <programlisting> &lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt; &lt;!DOCTYPE procwatch SYSTEM &quot;/usr/share/pear/data/System_ProcWatch/procwatch-1_0.dtd&quot;&gt; &lt;procwatch&gt; &lt;!-- SOME EXAMPLE CONFIGURATIONS =========================== This job looks for the count of running httpd processes by matching the PCRE &quot;/httpd/&quot; against the COMMAND column of ps. If there are less than 10 or more than 30 httpd processes found the speicified string is executed on the shell. --&gt; &lt;watch name=&quot;httpd-count&quot;&gt; &lt;pattern match=&quot;command&quot;&gt;/httpd/&lt;/pattern&gt; &lt;condition type=&quot;presence&quot;&gt; &lt;min&gt;10&lt;/min&gt; &lt;max&gt;30&lt;/max&gt; &lt;/condition&gt; &lt;execute type=&quot;shell&quot;&gt;echo $msg $pids &amp;gt;&amp;gt; /var/log/procwatch&lt;/execute&gt; &lt;/watch&gt; &lt;!-- This job looks for the amount of physical memory all httpd processes use together by matching the PCRE &quot;/httpd/&quot; against the COMMAND column of ps. It adds all %MEM columns of ps that match the pattern together and compares the reslut to the specified sum. If the result exceeds the sum the specified string is executet on the shell. --&gt; &lt;watch name=&quot;httpd-usage&quot;&gt; &lt;pattern match=&quot;command&quot;&gt;/httpd/&lt;/pattern&gt; &lt;condition type=&quot;attr&quot; attr=&quot;%mem&quot;&gt; &lt;sum&gt;5&lt;/sum&gt; &lt;/condition&gt; &lt;execute type=&quot;shell&quot;&gt;echo $msg $pids &amp;gt;&amp;gt; /var/log/procwatch&lt;/execute&gt; &lt;/watch&gt; &lt;!-- This job looks for zombie processes. It matches the PCRE &quot;/Z/&quot; against the STAT column of ps and executes the specified string on the shell if more than 0 zombies have been found. --&gt; &lt;watch name=&quot;ZOMBIES&quot;&gt; &lt;pattern match=&quot;stat&quot;&gt;/Z/&lt;/pattern&gt; &lt;condition type=&quot;presence&quot;&gt; &lt;max&gt;0&lt;/max&gt; &lt;/condition&gt; &lt;execute type=&quot;shell&quot;&gt;echo $msg $pids &amp;gt;&amp;gt; /var/log/procwatch&lt;/execute&gt; &lt;/watch&gt; &lt;!-- This job looks for running processes. It matches the PCRE pattern &quot;/R/&quot; against the STAT column of ps and executes the specified string on the shell if any running processes have been found. --&gt; &lt;watch name=&quot;running&quot;&gt; &lt;pattern match=&quot;stat&quot;&gt;/R/&lt;/pattern&gt; &lt;condition type=&quot;presence&quot; /&gt; &lt;execute type=&quot;shell&quot;&gt;echo $msg $pids &amp;gt;&amp;gt; /var/log/procwatch&lt;/execute&gt; &lt;/watch&gt; &lt;/procwatch&gt; </programlisting> </example> </refsect2> <refsect2 id="package.system.system-procwatch.intro.configuration.ini"> <title>INI file</title> <para> Configuring by INI file is effectively the same except that only <emphasis>execute</emphasis>s of <emphasis>type</emphasis> &quot;shell&quot; can be defined. </para> </refsect2> <refsect2> <title>Example INI configuration file</title> <example id="package.system.system-procwatch.intro.configuration.ini.example"> <title>INI configuration file</title> <programlisting> <![CDATA[ ; ; Example INI file to configure System::ProcWatch ; ; Be aware that you only can define shell executes! ; For better configurablity use XML configuration files. ; [httpd] pattern=/httpd/ match=command condition=presence min=10 max=50 execute="echo $msg >> /var/log/procwatch" [zombies] pattern=/Z/ match=stat condition=presence max=0 execute="kill -9 `echo $pids | sed s/[,\(\)]//g`" [mysqld-mem] pattern=/mysqld/ match=command condition=attr attr=%mem sum=10 execute="echo $msg >> /var/log/procwatch" ]]> </programlisting> </example> </refsect2> </refsect1> </refentry>
« previous php.pear.doc (#2263) next »