Sponsored Content
Full Discussion: Disk Monitor
Top Forums Programming Disk Monitor Post 302515757 by sdhn1900 on Wednesday 20th of April 2011 07:55:16 PM
Old 04-20-2011
Disk Monitor

Code:
#!/usr/bin/perl

use strict;
use warnings;
use Filesys::DiskSpace;

# file system to monitor
my $dir = "/opt";

# warning level
my $warning_level=10;

# email setup
my $to='mail@mail.com';
my $subject='Low Disk Space';

# get df
my ($fs_type, $fs_desc, $used, $avail, $fused, $favail) = df $dir;

# calculate 
my $df_free = (($avail) / ($avail+$used)) * 100.0;

# compare 
if ($df_free < $warning_level) {
my $out = sprintf("WARNING Low Disk Space on $dir : %0.2f%%  ()\n",$df_free);

# send email using UNIX/Linux sendmail
open(MAIL, "|/usr/sbin/sendmail -t");

## Mail Header
print MAIL "To: $to\n";
print MAIL "Subject: $subject\n";

## Mail Body
print MAIL $out;

close(MAIL);
}

--------------------------------------
__________________________________________
I am getting following error by running this script. Any help will be appreciated

Code:
>./test2.sh 
Can't locate Filesys/DiskSpace.pm in @INC (@INC contains:  /usr/lib/perl5/5.8.8/s390x-linux-thread-multi /usr/lib/perl5/5.8.8  /usr/lib/perl5/site_perl/5.8.8/s390x-linux-thread-multi  /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl  /usr/lib/perl5/vendor_perl/5.8.8/s390x-linux-thread-multi  /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at  ./test2.sh line 5.
BEGIN failed--compilation aborted  at ./test2.sh line 5.

I commented out "Filesys::DiskSpace"

"Filesys::DiskSpace"
any other alternative?

I do not have access to download "Filesys::DiskSpace".

I commented out this but getting following error now;


Code:
Can't call method "df" without a package or object reference at  ./test2.sh line 18.


Last edited by pludi; 04-21-2011 at 06:05 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automatic monitor disk-space

Hello, I am trying to find a shell script to monitor diskspace. When the script encounteres a disk which above the treashold, I want an email notification. My system runs on a Sun Solaris. Is there anybode around who can help me with such a script? Norbert (3 Replies)
Discussion started by: nfbeerse
3 Replies

2. Filesystems, Disks and Memory

Automatic monitor disk-space

Hello, I am trying to find a shell script to monitor diskspace of all the directories in the server. When the script encounteres a disk which above the treashold, I want an email notification. My system runs on AIX. Is there anybody around who can help me with such a script? ... (3 Replies)
Discussion started by: anuradha
3 Replies

3. Shell Programming and Scripting

Monitor Disk Space

I would like to monitor disk space on solaris system.Need script which will send email if the disk space exceeds 90%. Thanks -sam (3 Replies)
Discussion started by: sam786
3 Replies

4. Shell Programming and Scripting

script to monitor disk space usage

Some times my disk space is used upto 100% due to the application logs . So this script is to monitor the disk space usage and wall message to the users about the disk space usage if it exceeds the limit set in the script. Here for example the limit is set to 80%. This job is added in cron to... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

5. Shell Programming and Scripting

need help for scrip to monitor disk utilization

Hi, I need help to write a script which will monitor disk utilization. Please suggest the best approach to achive this. I am thinking of having sleep inside the script which will run for(eg.) 60 secs and then disk utilization will be checked and depends on the % usage of disk mail will... (1 Reply)
Discussion started by: sunilmenhdiratt
1 Replies

6. Infrastructure Monitoring

Using SNMP to monitor remote processes and disk space

snmpget -v 1 -c COMMUNITYSTR hostname OID what OIDs would I use to get information on all the processes and disk space information that are on a particular host. where can i find out information on all of this? thanks (3 Replies)
Discussion started by: SkySmart
3 Replies

7. Red Hat

How to monitor HP server hard disk failure ?

in red hat 4, 5 any one know any commands or any scritps to monitor HP DL 380 G5/6 server and trigger alarm when hard disk failed. thanks for all support ---------- Post updated at 02:45 PM ---------- Previous update was at 12:00 PM ---------- does HP ProLiant Support Pack support is... (4 Replies)
Discussion started by: maxlee24
4 Replies

8. Shell Programming and Scripting

Script to monitor the disk space details in HP-UX

Hi, I need to monitor the disk space details in HP-UX . I need a command on how to display the information on below format File System Total_Space_KB Used_Space_KB Available_Space_KB %Used /u05 524288000 376235344 138799427 73% /u02 ... (0 Replies)
Discussion started by: ali560045
0 Replies

9. Emergency UNIX and Linux Support

[Solved] DCMU (disk control and monitor utility) sun fire

Hi , during 2 weeks i´ve been trying to find them. i need DCMU packets for managing internal disks on sun fire x4500 and sun fire x4600 on rhel. i have opened to tickets to myoraclesupport but no answer. please anybody could tell me a link or anythiing?? i´ve been searching and searching... (1 Reply)
Discussion started by: pabloli150
1 Replies

10. HP-UX

Need script to monitor "ALL" Disk Spaces

Hi, I have searched the forum and found that there are many scripts that need the path i.e. /tmp, /opt, /var etc to be provided or hard coded for it to calculate the disk space free percentage. What i need is a script that shows the free disk space for all partitions on my HPUX itanium... (5 Replies)
Discussion started by: mohtashims
5 Replies
Config::Perl::V(3pm)					 Perl Programmers Reference Guide				      Config::Perl::V(3pm)

NAME
Config::Perl::V - Structured data retrieval of perl -V output SYNOPSIS
use Config::Perl::V; my $local_config = Config::Perl::V::myconfig (); print $local_config->{config}{osname}; DESCRIPTION
$conf = myconfig () This function will collect the data described in "the hash structure" below, and return that as a hash reference. It optionally accepts an option to include more entries from %ENV. See environment below. Note that this will not work on uninstalled perls when called with "-I/path/to/uninstalled/perl/lib", but it works when that path is in $PERL5LIB or in $PERL5OPT, as paths passed using "-I" are not known when the "-V" information is collected. $conf = plv2hash ($text [, ...]) Convert a sole 'perl -V' text block, or list of lines, to a complete myconfig hash. All unknown entries are defaulted. $info = summary ([$conf]) Return an arbitrary selection of the information. If no $conf is given, "myconfig ()" is used instead. $md5 = signature ([$conf]) Return the MD5 of the info returned by "summary ()" without the "config_args" entry. If "Digest::MD5" is not available, it return a string with only 0's. The hash structure The returned hash consists of 4 parts: build This information is extracted from the second block that is emitted by "perl -V", and usually looks something like Characteristics of this binary (from libperl): Compile-time options: DEBUGGING USE_64_BIT_INT USE_LARGE_FILES Locally applied patches: defined-or MAINT24637 Built under linux Compiled at Jun 13 2005 10:44:20 @INC: /usr/lib/perl5/5.8.7/i686-linux-64int /usr/lib/perl5/5.8.7 /usr/lib/perl5/site_perl/5.8.7/i686-linux-64int /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl . or Characteristics of this binary (from libperl): Compile-time options: DEBUGGING MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP PERL_TRACK_MEMPOOL PERL_USE_SAFE_PUTENV USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Built under linux Compiled at Jan 28 2009 15:26:59 This information is not available anywhere else, including %Config, but it is the information that is only known to the perl binary. The extracted information is stored in 5 entries in the "build" hash: osname This is most likely the same as $Config{osname}, and was the name known when perl was built. It might be different if perl was cross-compiled. The default for this field, if it cannot be extracted, is to copy $Config{osname}. The two may be differing in casing (OpenBSD vs openbsd). stamp This is the time string for which the perl binary was compiled. The default value is 0. options This is a hash with all the known defines as keys. The value is either 0, which means unknown or unset, or 1, which means defined. derived As some variables are reported by a different name in the output of "perl -V" than their actual name in %Config, I decided to leave the "config" entry as close to reality as possible, and put in the entries that might have been guessed by the printed output in a separate block. patches This is a list of optionally locally applied patches. Default is an empty list. environment By default this hash is only filled with the environment variables out of %ENV that start with "PERL", but you can pass the "env" option to myconfig to get more my $conf = Config::Perl::V::myconfig ({ env => qr/^ORACLE/ }); my $conf = Config::Perl::V::myconfig ([ env => qr/^ORACLE/ ]); config This hash is filled with the variables that "perl -V" fills its report with, and it has the same variables that "Config::myconfig" returns from %Config. inc This is the list of default @INC. REASONING
This module was written to be able to return the configuration for the currently used perl as deeply as needed for the CPANTESTERS framework. Up until now they used the output of myconfig as a single text blob, and so it was missing the vital binary characteristics of the running perl and the optional applied patches. BUGS
Please feedback what is wrong TODO
* Implement retrieval functions/methods * Documentation * Error checking * Tests AUTHOR
H.Merijn Brand <h.m.brand@xs4all.nl> COPYRIGHT AND LICENSE
Copyright (C) 2009-2013 H.Merijn Brand This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2014-01-06 Config::Perl::V(3pm)
All times are GMT -4. The time now is 06:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy