Monitor processes in Linux using Perl script

This is another perl script I wrote to monitor critical processes in Linux and report status to log. This script is alot like the earlier script I wrote to check mount points in that it opens a command and write it to a file in order to use regular expressions to check if something is true or not. Also this script can be edited to monitor any number of process and report it any number of ways including syslog, Nagios, or just system mail.

Enjoy and as always if you use my code… please credit triz solo… we likey props!

Linux, Perl Scripts, Tutorials/Whitepapers

9 comments to Monitor processes in Linux using Perl script

  • j_q

    I think

    $/=”n”; # record seperator
    while(
    ) {

    should be

    $/=”n”; # record seperator
    while()
    {

    Reply
  • triz

    Definitely… I don’t see why I would have done that on purpose.

    Reply
  • Bhavesh

    Instead of this

    while(
    ) {


    use


    while() {

    then it will work properly.

    Reply
  • PAR

    I needed to update update the line as

    while()

    To make it work.

    Very useful script, Thanks.

    Reply
  • PAR

    WordPress seems to have removed the important part. But you need to add PS enclosed in pointy brackets between the curly brackets in the while. Hope that make sense.

    Reply
  • Barqs

    Why do I keep getting this error:

    Use of uninitialized value in pattern match (m//) at ./ProcessMonitor2.pl line 38.

    Reply
  • […] Monitor processes in Linux using Perl script […]

    Reply
  • thepuregeek

    Yea, WordPress does remove the pointy brackets when using html mode. I’ll look into how to keep this from happening in the future.

    Reply
  • Luca Francesca

    Quick question: why use uname -r and not uname -o?

    Just my 2 cents

    Reply

Leave a Reply

Comment
Name*
Mail*
Website*