Sponsored Content
Top Forums Shell Programming and Scripting Check space of directories and send email if it has reached threshold limit Post 302406890 by jmathew99 on Wednesday 24th of March 2010 06:12:51 AM
Old 03-24-2010
Check space of directories and send email if it has reached threshold limit

Hi,

I need help in writing unix script for checking space of some directories on the system and also send an email when it reaches the threshold limit.

I have written the followng code;

Code:
 
#!/bin/ksh
ADMIN="me@somewhere.com"
# set alert level 80% is default
THRESHOLD=80
df | grep -E "Filesystem|tmpfs|cdrom" | awk '{ print $5 " " $1 }' | while read output;
do
  #echo $output
  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
  partition=$(echo $output | awk '{ print $2 }' )
  if [ $usep -ge $THRESHOLD ]; then
    echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
     mail -s "Alert: Almost out of disk space $usep" $ADMIN
  fi
done

When I run the above code I get the following error;

dspace.ksh[15]: Iused: bad number
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Counting Files and send an email Notification if it exceeds a limit

Hi, I am trying to write a script to Count Files in a directory located on a remote server and send an email Notification if it exceeds a limit. The code given below doesnot check the condition and sends the mail everytime irrespective of the condition. I have put this script in the cron. Can... (10 Replies)
Discussion started by: amitsayshii
10 Replies

2. Shell Programming and Scripting

Script to check processes and send an email

I searched through the forum and couldn't quite find what I was looking for. I have a script that looks for a process "DW" to be running. If it is not it will email a notice to an account. I would like to add the functionality to have it also email a seperate notice if there is more that one of... (1 Reply)
Discussion started by: heprox
1 Replies

3. Shell Programming and Scripting

shell script to send email with usage of space in the directory as description :

shell script to send email with usage of space in the directory as description : Please any one help me in writing a script to send email with usage of space in the directory as description . (3 Replies)
Discussion started by: sakthifire
3 Replies

4. Shell Programming and Scripting

Check and compare disk space and email it

I am very new to Linux and learning to script. This is for one of my servers at work that I have to keep track off as far as disk space and how it is used. I have tried to go line by line but little things keep chewing me up. I would appreciate any and all help or advice, and Mutt is installed on... (3 Replies)
Discussion started by: sgtjkj
3 Replies

5. UNIX for Dummies Questions & Answers

stunnell log file has reached its limit

Please help! I am really new to Linux, and my colleague who usually deals with these things isnt here to help me out. We are running Scalix mail services on CentOS 6.0. Email users with IMAP folders are getting an error message stating the server cannot be reached, however POP3 mail users are... (13 Replies)
Discussion started by: beckyboo
13 Replies

6. UNIX for Dummies Questions & Answers

httpd count exceeded threshold limit

Hello Everyone, I am new to this forum and also unix/linux. Our application today threw an alert whcih read as "The users active count on host has crossed the threshold limit of 50 and is standing at 65." This was although cleared when I restarted tomcat. But I am not sure why this count... (0 Replies)
Discussion started by: ykhati
0 Replies

7. Shell Programming and Scripting

Help....script check status if see something then send email

autorep -m bogus Machine Name Max Load Current Load Factor O/S Status ___________ ________ ___________ ______ ________ ______ bogus --- --- 1.00 Sys Agent Online Status ______ Online Offline Missing Unqualified The "Status" always "Online". I like create a script execute run... (6 Replies)
Discussion started by: dotran
6 Replies

8. UNIX for Dummies Questions & Answers

How to confirm that I've reached the nproc limit?

Hi, I am getting the error su: cannot set user id: Resource temporarily unavailable. In limits.conf, it shows soft nproc 2047 for this user. ps H -u | wc -l shows 508 processes only. Linux flavour is Red Hat Enterprise Linux Server release 5.10 (Tikanga) Any advice will be much... (1 Reply)
Discussion started by: newbie_01
1 Replies

9. Shell Programming and Scripting

Send Disk Space Usage Status via email

Hi Guys, Is there any way I can write a script that sends DISK SPACE USAGE STATUS via email once a week? Thanks, (5 Replies)
Discussion started by: g4v1n
5 Replies

10. UNIX for Beginners Questions & Answers

Merge Text with space into once cell and send email out

Please help!! This code works perfect but the only problem I am having is that is treats eg SQL Developer as separate cell/column which makes the formatting bad. I want to put SQL Developer in one cell. I attached a sample of how the output looks like. report.txt USERNAME OSUSER ... (5 Replies)
Discussion started by: lpoolfc
5 Replies
Swatch::Threshold(3pm)					User Contributed Perl Documentation				    Swatch::Threshold(3pm)

NAME
Swatch::Threshold - Perl extension for thresholding in swatch(1) SYNOPSIS
use Swatch::Threshold; &Swatch::threshold( SWID => <int>, TYPE => <limit|threshold|both>, TRACK_BY => <key>, # like an IP addr COUNT => <int>, SECONDS => <int> ); SWATCH SYNTAX
threshold track_by=<key>, type=<limit|threshold|both>, count=<int>, seconds=<int> DESCRIPTION
SWID is swatch's internal ID number for the watchfor block TYPE can be limit, threshold, or both Limit - Alert on the 1st COUNT events during the time interval, then ignore events for the rest of the time interval. Threshold - Alert every COUNT times we see this event during the time interval. Both Alert once per time interval after seeing COUNT occurrences of the event, then ignore any additional events during the time interval. SECONDS is the time interval AUTHOR
E. Todd Atkins, todd.atkins@stanfordalumni.org SEE ALSO
perl(1), swatch(1). perl v5.10.0 2006-07-21 Swatch::Threshold(3pm)
All times are GMT -4. The time now is 01:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy