Sponsored Content
Full Discussion: Disk Capacity Shell Script
Homework and Emergencies Homework & Coursework Questions Disk Capacity Shell Script Post 302613111 by polyglot0727 on Monday 26th of March 2012 05:30:01 PM
Old 03-26-2012
Disk Capacity Shell Script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
I am pretty close I think, but stuck. I don't know how to send an email to the user specified on the command line, and I receive an error stating -ge expecting a unary value(lines 13 and 17), and ']' missing. The class is not on shell scripting, and I managed all of this from scratch myself so any help would be appreciated. I don't know why the variable and comparison isn't working.

1. The problem statement, all variables and given/known data:
Create a script sends an email message to the user specified on the command line if any of the filesystems at more than 70% of capacity. The script should not process special filesystems as /proc on the ce.uml.edu. It should only process filesystems which are either locally mounted or are mounted via NFS.
An individual email should be sent for each filesystem which is at the warning level. There should be a subject on the email with a message "Warning: Filesystem <put filesystem the>here is at <X>% of capacity" If the filesystem is at greater than 90% of capacity, the "Warning" should be changed to "Critical Warning".
You may use any scripting language including /bin/sh, ksh, bash, awk or perl. Work done in the C-Shell (csh) will not be accepted. This assignment may be done either on ce.uml.edu or on your own Linux/UNIX system.


2. Relevant commands, code, scripts, algorithms:



3. The attempts at a solution (include all code and scripts):
Code:
#!/bin/sh
# set -x # Uncomment to debug this script
# set -n # Uncomment to check syntax without any execution
# Shell script to monitor or watch the disk space
####Main Script####

df -H | grep -vE '^Filesystem | none' | awk '{ print $1 " " $5 }' | while read
do
 echo $output
 perc=$(echo $output | awk '{ print $1 }' | cut -d'%' –f1)
 part=$(echo $output | awk '{ print $2 }' )

 if [ $perc -ge 90 ]; then
 echo "Critical Warning: Filesystem \"$part\" at “$perc”% of capacity | 
 mail -s "Critical Warning: Filesystem \”$part\” at “$perc”% of capacity”

 elif [ $perc -ge 70 && $perc -lt 90 ]; then
 echo "Warning: Filesystem \"$part\" at “$perc”% of capacity | 
 mail -s "Warning: Filesystem \”$part\” at “$perc”% of capacity”

 fi
done

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
University of Mass, Lowell, Unix/Linux System Admin 90.321-061, Professor Michael Richards, Michael_Richards@uml.edu

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by DukeNuke2; 03-26-2012 at 07:00 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unix disk capacity at 100%

Is there any danger to keeping one of my disks at 100% capacity? (it's a disk just used for read-only files, not system files or anything like that). It's HP-UX if that matters. Thanks! (1 Reply)
Discussion started by: FredSmith
1 Replies

2. Solaris

Migrate VxVM boot disks to higher capacity disk

Hi, Im getting a downtime of 4 hrs to do porting of bootdisks. Currently, the system is running on Sf4800. 2 internal disk 36G connected to a SE3510 storage. We're getting 72G disks and we want to restore the OS from the current 36G to the 72G disk. System is under veritas volume manager ctrl.... (4 Replies)
Discussion started by: incredible
4 Replies

3. Shell Programming and Scripting

shell script to create disk load

friends , need a shell script to create a disk load. can any one pls guide me with how this can be implemented. Pls provide the concept. from there i will try to design my script. (3 Replies)
Discussion started by: achak01
3 Replies

4. Shell Programming and Scripting

File system capacity meter in shell

HI i need help to show the file system capacity in meter or like the progress bar . OS = Solaris 10 (8 Replies)
Discussion started by: bejo4ever
8 Replies

5. AIX

how to find out disk capacity

Hi, I would like to know how to find out disk capacity if it is assigned from the storage as a lun. as per below command , I am unable to find out disk capacity. $ bash bash-3.00$ lspv hdisk1 0001579a7fa3c086 None $ lscfg -vl hdisk1 hdisk1 ... (8 Replies)
Discussion started by: manoj.solaris
8 Replies

6. Shell Programming and Scripting

Shell script to find filesystem capacity on 50 servers

Hi all, I am new to Unix and I want to write a shell script in a jumpbox for finding the filesystem capacity on 50 unix servers ( by ssh ) and then email the result in HTML format with server name and capacity % to a specific outlook distribution list. any suggestion would be of great help. (17 Replies)
Discussion started by: amitbisht9
17 Replies

7. Shell Programming and Scripting

Help with Disk Space script in bash shell

Hi Guys, I'm a newb at shell scripting and successfully attempted a small disk space script (victory!!) but i'm wondering whether it actually takes into consideration KB,MB,GB. Please take a look at the script and advise. ##script to check if file sys has reached threshold. ... (3 Replies)
Discussion started by: Irishboy24
3 Replies

8. Shell Programming and Scripting

disk quotas shell script

Hello.. I wrote the following shell script to run disk quotas for assigning limits to users. I need to know the partition which the user has created and mount it. So i copied the partitions (which will be displayed after running fdisk -l) and separted the last line from it and cut the required... (0 Replies)
Discussion started by: kalyanilinux
0 Replies

9. UNIX for Dummies Questions & Answers

Tru 64 Disk Capacity Check

i have a query on checking Tru64 disk drives physical capacity. i used hwmgr view devices and saw this disk. 160: /dev/disk/dsk7c COMPAQ BF03688284 bus-3-targ-0-lun-0 checking the model on the internet shows it is a 36.4GB drive. i checked the disk details and saw the... (2 Replies)
Discussion started by: iamnotaguru
2 Replies

10. Shell Programming and Scripting

Help me with C-shell Script: Disk checking

Hi, i am new in shell script. i have given a task to make a C-shell script. I have list of ip address and device name respectively. For example; cal 1 : 100.21.25.10 cal 2 : 100.21.25.11 cal 3 : 100.21.25.12 cal 4 : 100.21.25.14 and so on... Right now, i have this. #! /bin/csh -f ... (0 Replies)
Discussion started by: lattey
0 Replies
SCRIPT-EMAIL(8) 					  System Administration Commands					   SCRIPT-EMAIL(8)

NAME
script-email - Amanda script to send email notifications DESCRIPTION
script-email is an Amanda script implementing the Script API. It should not be run by users directly. It sends a notification email to the addresses specified in the MAILTO property. PROPERTIES
This section lists the properties that control script-email's functionality. See amanda-scripts(7) for information on the Script API, script configuration. MAILTO List of email addresses that will receive an email on command execution. It is a multi-valued property: property "MAILTO" "amanda@domain.com" "sysadmin@domain.com" "amandauser@domain.com" EXAMPLE
In this example, script-email is scheduled to be run before the DLE, on the server. The unqualified email address amanda will be passed to the email system unchanged. The script is then attached to a dumptype, which can then be specified for any DLEs which require notification. define script-tool pre-email { comment "email me before this DLE is backed up" plugin "script-email" execute-on pre-dle-backup execute-where server property "mailto" "amanda" } define dumptype user-tar-email { user-tar script "pre-email" } SEE ALSO
amanda(8), amanda.conf(5), amanda-client.conf(5), amanda-scripts(7) The Amanda Wiki: : http://wiki.zmanda.com/ AUTHORS
Jean-Louis Martineau <martineau@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Dustin J. Mitchell <dustin@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Amanda 3.3.1 02/21/2012 SCRIPT-EMAIL(8)
All times are GMT -4. The time now is 08:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy