LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-09-2010, 01:30 AM   #1
Image1
LQ Newbie
 
Registered: Aug 2010
Posts: 1

Rep: Reputation: 0
Disk Space Monitoring


I'm very new to Linux and scripting; been using Fedora 13 for about a month now and playing around with scripting for just about two weeks. But my problem is that I don't like to just install things without understanding them. I understand what the script does but not what the commands within the script tell it to do.

For the most part I haven't a clue about scripting and want to learn. I found this script online and I've been able to find a few of the commands online that explain a bit about what is going on in the script but for the most part I haven't the foggiest as to how the script works.

I'm hoping someone can help me understand what is actually happening in this script. I know that I can set the computer to warn me when my disk space is getting low but lets face it, where is the fun in that.

#!/bin/bash
# comment
ADMIN="myemail@itsme.com"
ALERT=90
df -H | grep -vE '^none' | 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 $ALERT ]; 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
 
Old 08-09-2010, 03:23 AM   #2
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 111Reputation: 111
Quote:
I understand what the script does but not what the commands within the script tell it to do.
Simplest way is run command on shell which are defined in script.

BTW there are some variables and logic is used.

Last edited by sem007; 08-09-2010 at 03:24 AM.
 
Old 08-09-2010, 04:39 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Good docs that cover shell programming:

http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
http://linux.die.net/man/
 
  


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
Monitoring disk space scottyp55 Red Hat 5 03-22-2010 11:32 AM
script for disk space monitoring jmmo1981 Red Hat 1 05-24-2008 12:25 PM
3Gb of disk space lost! Disk space problem or mother board conflicts with HDD Mistreated Linux - Hardware 4 12-06-2004 04:58 PM
Monitoring disk space on webserver!!! apache Linux - Software 2 07-27-2004 08:47 AM
monitoring disk space cuss Linux - General 26 02-25-2003 01:44 PM


All times are GMT -5. The time now is 06:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration