Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hello vikas330,

Let's take the questions one by one:

<FS having more than 80% utilization>: The link that I provided you (Perl script to monitor disk space and send an email) provides you the ability to set your own utilization limit. Sample of code based on description from link:

# warning level 10% my $warning_level=10; # compare free disk space with warning level if ($df_free < $warning_level) { my $out = sprintf("Send an Email - Disk space on $dir => %0.2f%% (WARN +ING Low Disk Space)\n",$df_free); print $out; } else { my $out = sprintf("Disk space on $dir => %0.2f%% (OK)\n",$df_free); print $out; }

In your case you can set the value to 20 instead of 10, this will mean that if the disk utilization will reach 80% then an email will be sent to you.

<need to check FS on mutliple machines>: Regarding the multiple machines, here you could have to options. First and simplest option, apply this script on all machines you want to check the FS utilization on a cron tab as described on the link. Sample of description from link:

You can run this script as a cron job: @hourly /path/to/df.pl

By doing so each machine will email you separately in case that you have exceeded 80% utilization.

In case that this is not what you really want to have as I suspect, then you need to do a bit of coding. I would write a script that can ssh on all machines and apply df -h, df -P or install the Filesys::DiskSpace which I find extremely useful and retrieve the data and compare them based on your threshold value (e.g. 80%).

I prefer to use the module Net::OpenSSH::Parallel which can create multiple parallel ssh connections and retrieve all data. I have some samples of codes into an old question of mine (Best module to execute administrator commands on external operating systems (Linux)) where you will find samples of code for (Net::Telnet, Net::SSH, Net::OpenSSH and Net::SSH::Perl) if I remember correctly all will do your task executing bash commands remotely through ssh and telnet.

In case of multiple machines you can create a simple loop where you ssh each machine separately and and collect data separately.

As I said as up to you to play around and see what fits your criteria and how much you want to code.

Regarding the tabular format hippo provided you multiple links where you can read and implement.

Hope this is a more complete answer to your question.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re^3: multiple machines disk space alert by thanos1983
in thread multiple machines disk space alert by vikas330

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-24 20:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found