LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-20-2014, 06:29 PM   #1
ccc
Member
 
Registered: Oct 2002
Posts: 100

Rep: Reputation: 0
send a mail if /var partition getting full


hi

I'm looking for a perl or bash script to send a mail if /var partition is 90% full.

Last edited by ccc; 04-20-2014 at 06:31 PM.
 
Old 04-21-2014, 01:39 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Can you send mail from the command line? If not, that will have to be set up before a bash script can work (perl scripts can include a SMTP server module so need not).

Once that is working it is relatively simple to write a bash script to detect when the file system containing /var is used more than 90% and, when it is, to send an email.
 
Old 04-21-2014, 04:41 AM   #3
ccc
Member
 
Registered: Oct 2002
Posts: 100

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
Can you send mail from the command line? If not, that will have to be set up before a bash script can work (perl scripts can include a SMTP server module so need not).

Once that is working it is relatively simple to write a bash script to detect when the file system containing /var is used more than 90% and, when it is, to send an email.
I have postfix installed and I can send a mail from the command line:
Code:
echo "Message" | mailx -s "test mail" address@mydomain.net
but I need a bash code for the rest.
 
Old 04-21-2014, 09:02 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
Nagios is a great open-source framework for doing all sorts of infrastructure monitoring tasks like this.
 
Old 04-21-2014, 11:21 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,633

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by ccc View Post
I have postfix installed and I can send a mail from the command line:
Code:
echo "Message" | mailx -s "test mail" address@mydomain.net
but I need a bash code for the rest.
If you need a script, you need to write one. We're not going to write your scripts for you, but will be happy to HELP when you're stuck. Since there are MANY thousands of examples you can easily find on Google, you've got a starting point there.
 
Old 04-22-2014, 05:46 PM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
And, once again ... nagios!

Basically, this requirement boils down to ... "infrastructure monitoring." Which is a big, broad class of problems that everyone faces. You will indeed find that this battle-tested tool does a lot of wonderful things.
 
Old 04-23-2014, 09:16 AM   #7
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Shell script to watch the disk space may help.
 
  


Reply

Tags
bash, full, partition, perl, script



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
var/spool/mail is full - how do I clear it? magicman Linux - Newbie 5 03-19-2011 03:39 PM
Trying to send mail from /var/mail to external mailbox senkyoshi Linux - Newbie 1 03-28-2008 07:15 AM
Up2date problem /var partition full hurlant Fedora - Installation 3 08-17-2005 12:37 PM
Question about full /var partition. Allen T Linux - General 1 04-18-2003 07:36 AM
2 gig /var partition already full after 3 weeks Nigel_Tufnel Linux - General 2 02-26-2003 08:12 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration