Here is a project I'm working on and the mess it got me into:

The Idea:
I need to create a script that would monitor performance on Windows and Linux servers, and log it to an mySQL database for creating reports later. (I will convert it to .exe with perl2exe to avoid having to install Perl on all the boxes).

My Thoughts:
Since Disk utilization does not change every often, I would check it once a day, and send the data to the DB - no problem here...

Memory monitoring - once every minute seems reasonable, and sending one short update query to mySQL every minute should not be that bad...

CPU - I guess I need to get usage data at least every second or even more often...

The functionality for performance monitoring either is present in currently available modules, or could be obtained via system calls. Net::MySQL is good enough as a DB interface.

The Problems:
1. For memory and especially CPU monitoring, I obviously should have the script/program running all the time. What I couldn't find out is how well does a Perl script perform as a memory-resident program? Any memory leaks, garbage collection problems etc.? I tried to look at doing a multithreaded program, but documentation warned that it (the multi-threading implementation) could be obsolette as it changes frequently...

2. How can I implement timers in the script? I mean, not count-down ones, but rather something like a scheduler, so that I can run all three monitoring jobs (CPU, memory, HDD) from one script at different intervals.

3. When I monitor CPU performance or other frequently changing data, what would be the best way to send that info to the SQL database? Since executing an update query every second doesn't strike me as very efficient, I would think of something like adding the SQL queries together for a while and executing a batch update say, once a minute, or even less frequently. But that brings me to the first question again, in the sense that I don't know how well Perl would free the memory used to store the SQL queries, after I executed them.

Any thoughts and pointers are appreciated.
Many thanks,
Eugene


In reply to Logging system performance into a DB from Perl TSR: a few questions pulled together by bofh_of_oz

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.