LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-24-2003, 08:59 AM   #1
pralaydesai
LQ Newbie
 
Registered: Mar 2003
Location: india
Posts: 3

Rep: Reputation: 0
Thumbs up script for checking disk space


Hello All,

I want write a script that checks space of directories on linux server and if space is more the limit then send mail to perticular user.

Can any one help me in this regards?

Thanks in advance,

Regards,
Pralay
 
Old 03-24-2003, 10:06 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594
Sure we can help, but could you post any leads on what you've done so far, or are we supposed to write it from scratch ourselves?
 
Old 03-25-2003, 12:34 AM   #3
pralaydesai
LQ Newbie
 
Registered: Mar 2003
Location: india
Posts: 3

Original Poster
Rep: Reputation: 0
i done something like this

hello,

#!/bin/bash
DIR=/home/pralay
masg="you are occuping"
cd $DIR
du -s -h $DIR | sort -rn >spa
mail pralay -s "Your space Utilization" <spa

now i want that to append the whatever in masg variable has to append in massage body after space is coming from spa.

One more thing is that i also want it for all users.

Regards,
Pralay
 
Old 03-25-2003, 03:34 AM   #4
m0rl0ck
Member
 
Registered: Nov 2002
Distribution: A totally 133t distro :)
Posts: 358

Rep: Reputation: 31
Youll have to put in your own host name and $limit.


-------------------------------------------------------
#!/usr/bin/perl
#
#limit is space in bytes adjust it as necessary
$limit=2000000; # about 2 gigs

$howmuch=`cd /home;ls|xargs du -s`;

@lusers=split "\n",$howmuch;

foreach $luser (@lusers){
@luserspace=split " ",$luser;
if (@luserspace[0]>$limit){

system ("echo 'Get your space below $limit or your data is forfiet'|mail -s \"YOU A BIG FAT PIG\" @luserspace[1]\@yourhost.com");
}
}

----------------------------------------------


I am truly sorry about this. I get started and before I know whats happended I've commited an atrocity.

Last edited by m0rl0ck; 03-25-2003 at 03:39 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Best program for checking available disk space? TippyToes Linux - Software 5 11-16-2004 09:57 PM
Checking Disk Space thru console boyblitz Linux - Newbie 2 04-06-2004 11:39 AM
Disk space checking script? jimieee Linux - General 2 04-01-2004 02:57 AM
Checking disk space timberwolf Linux - General 9 12-04-2003 01:18 AM
Checking free disk space hackersapien Linux - Newbie 2 08-05-2003 01:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:40 PM.

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