A bit of background.. We have several products, which run on a number of unix servers at customer sites, sometimes more than one product runs on each machine. To be able to keep an eye on whats going on, we also provide SNMP agents. Since SNMP usually only allows one agent per machine, we're using a 3rd party software which allows sub-agents.
The main agent asks the sub-agents to check the product they are watching at certain intervals, and shows the results on some sort of monitor (and in a log.) When someone specifically asks for the status, then the main agent asks the subagent for each of its values again. These two checks can happen at the same time.

So, where does Perl come into this? The product that I work on provides a perl script which can be called with certain parameters to check if the system is running properly. The subagent for the product calls this script to get its information. For example, part of our system consists of several ftp processes which fetch statistic files from other products. Could be 10 or more of them running at the same time. The perl script which checks these uses a system call to ps and grep, called once for each ftp-process, to see if they are running.

My problem is this: If the main agent calls this script routinely, and asks about the ftp-processes, the script takes a while to run (several seconds). If a user asks about the status at the same time, the user process usually times out, as the subagent can (apparently) only do one thing at a time, while its waiting for the answer to the usual poll, it can't re-ask to get answers for the user (I will also be looking at the subagent code, to see if I can change that..)
I'm thinking that calling the script every 20 secs, which is then calling 'ps' etc. several times is quite a bit of overhead. Has anyone any ideas how I can optimize this? Maybe start the script at system-start and keep it running, and somehow pass it options/get answers while its running? Or some other methods of checking if certain processes are running? (But without too many extra-modules, if possible, though I guess we could supply those.)

I can summerize the code, if needed, though I'm more looking for generic ideas..

C.


In reply to Perl and SNMP by castaway

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.