<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I wrote a perl script that reads the output of ps, and checks the size of (%mem) of processes defined in a config file. That config file, sets alert levels
 for yellow and red.  Then run that from cron. It would be pretty easy to run from ext as well.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Xymon [mailto:xymon-bounces@xymon.com]
<b>On Behalf Of </b>Jeremy Laidman<br>
<b>Sent:</b> Thursday, June 02, 2016 5:01 AM<br>
<b>To:</b> m.pingel@ndr.de; xymon@xymon.com<br>
<b>Subject:</b> Re: [Xymon] question<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal">On Mon, May 30, 2016 at 10:52 PM <<a href="mailto:m.pingel@ndr.de">m.pingel@ndr.de</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">is it possible to configure a maximum level of memory from a process?</span>
<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Let me rephrase to make sure I understand.  You want to monitor the memory usage of a process (by name, presumably) and if it exceeds a predefined threshold, you would like it to change colour?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">This is not really possible out-of-the-box.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">However, there are ways to do this.  The xymon client data message contains the "ps" section to list all running processes.  Generally, this includes memory usage for each process.  So the Xymon server has the data for it to use.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Example: <a href="https://www.xymon.org/xymon-cgi/svcstatus.sh?CLIENT=claudio.hswn.dk&section=ps">https://www.xymon.org/xymon-cgi/svcstatus.sh?CLIENT=claudio.hswn.dk&section=ps</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Note that there are several columns you might be interested in here.  An absolute MB of memory is shown in the resident size (RZ) and virtual size (VZ), but also the percentage of memory (%MEM).  So, step one is to decide what you're interested
 in, perhaps based on what problem you're trying to detect.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">If you wanted to alert on client data, you could write a server-side task to query every device and do the thresholding.  You could either create a new test such as "procmem", or you could modify the state of the "proc" test.  Here's a
 scriptlet that would probably (untested) do the latter:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">#!/bin/sh<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">PROCMATCH="/usr/sbin/ntpd" # should fetch per-host with hostinfo or xymongrep<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">$XYMON $XYMSRV "xymondboard test=proc fields=hostname,client" | grep ",Y$" | while read LINE; do<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">    HN=`IFS="|"; set - $LINE; echo $1`<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">    PS=`$XYMON $XYMSRV "clientlog $HN section=ps" | grep "$PROCMATCH"`<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">    # parse PS for the appripriate column and generate a "modify" message for the "prox" status<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">done<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Sorry, I don't have access to a Xymon server to test this with just now.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">J<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
<center>This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately
 notify the sender by reply e-mail and destroy all copies of the communication and any attachments.</center>
</body>
</html>