Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Need little script to send out email

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 1 Week Ago
jaapar jaapar is offline
Registered User
 
Join Date: Jul 2010
Last Activity: 23 June 2017, 5:32 AM EDT
Posts: 20
Thanks: 7
Thanked 0 Times in 0 Posts
Need little script to send out email

Hi Scripters, good day.

Code:
bash-4.2# df -g /apps/prd
Filesystem      GB  blocks Free  %Used    Iused  %Iused Mounted on
/dev/xxx     64.00         4.35    94%  1269284      8% /xxx
bash-4.2#

I was wondering if there is a script when the usage of the mountpoint above hit 98%, email would be sent to a specific mailbox? Thanks in advance.

Last edited by Chubler_XL; 1 Week Ago at 04:00 PM.. Reason: Added CODE tags
Sponsored Links
    #2  
Old Unix and Linux 1 Week Ago
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 27 June 2017, 3:14 AM EDT
Location: Aachen, Germany
Posts: 10,959
Thanks: 280
Thanked 3,368 Times in 3,101 Posts
Almost certainly, yes. Look into the links at the lower left of this page, under "More UNIX and Linux Forum Topics You Might Find Helpful", or search these fora for "almost full".
The Following User Says Thank You to RudiC For This Useful Post:
jaapar (1 Week Ago)
Sponsored Links
    #3  
Old Unix and Linux 1 Week Ago
lightman66 lightman66 is offline
Registered User
 
Join Date: Mar 2017
Last Activity: 22 June 2017, 11:14 PM EDT
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
Quote:
Originally Posted by jaapar View Post
Hi Scripters, good day.

Code:
bash-4.2# df -g /apps/prd
Filesystem      GB  blocks Free  %Used    Iused  %Iused Mounted on
/dev/xxx     64.00         4.35    94%  1269284      8% /xxx
bash-4.2#

I was wondering if there is a script when the usage of the mountpoint above hit 98%, email would be sent to a specific mailbox? Thanks in advance.
I think you can just set a cronjob to run at your preferred interval.

mine is running on solaris 10 hence command might varies.


Code:
20 * * * * df -h | tail +2 | awk '{if ((length($5) > 3) || ((length($5) > 2) && ($5 > 98))) print $0}' | mailx -s "Email Subject" <email address>

Moderator's Comments:
Need little script to send out email edit by bakunin: please use CODE-tags. Thank you.

Last edited by Don Cragun; 1 Week Ago at 02:38 AM.. Reason: Remove accidental edit.
The Following User Says Thank You to lightman66 For This Useful Post:
jaapar (1 Week Ago)
    #4  
Old Unix and Linux 1 Week Ago
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 26 June 2017, 8:37 PM EDT
Location: San Jose, CA, USA
Posts: 10,396
Thanks: 527
Thanked 3,627 Times in 3,093 Posts
Quote:
Originally Posted by lightman66 View Post
I think you can just set a cronjob to run at your preferred interval.

mine is running on solaris 10 hence command might varies.


Code:
20 * * * * df -h | tail +2 | awk '{if ((length($5) > 3) || ((length($5) > 2) && ($5 > 98))) print $0}' | mailx -s "Email Subject" <email address>

Moderator's Comments:
Need little script to send out email edit by bakunin: please use CODE-tags. Thank you.
You should be able to simplify that awk code a little bit to just:

Code:
20 * * * * df -h | tail +2 | awk '($5 + 0) > 98' | mailx -s "Email Subject" <email address>

but on a Solaris/SunOS system, that would be:

Code:
20 * * * * df -h | tail +2 | nawk '($5 + 0) > 98' | mailx -s "Email Subject" <email address>

Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script that will send an email if the cron job did not run. kenshinhimura Shell Programming and Scripting 4 03-23-2017 02:57 PM
Help with shell script to send email once d3xt3r Shell Programming and Scripting 5 08-08-2011 01:46 AM
Script to send email after comparing the folder permissions to a certain permission & send email nairshar Shell Programming and Scripting 2 12-07-2010 08:22 PM
How to send email through shell script nileshbhawsar Shell Programming and Scripting 3 11-01-2010 01:30 PM
script to send a file in email dr46014 Shell Programming and Scripting 2 12-10-2007 07:38 AM



All times are GMT -4. The time now is 06:33 AM.