Sponsored Content
Top Forums Shell Programming and Scripting Linux Mount Points usage check with shell script Post 302969500 by thiyagoo on Wednesday 23rd of March 2016 10:39:09 AM
Old 03-23-2016
RedHat Linux Mount Points usage check with shell script

Hi Everyone,

Just in need of your help again, I have managed to get a script to check the linux disk usage stuff. But wanted to tweak it little more to get the desired output.

Requirement:

Now its querying only one mount point, As its not saving in array instead calling it as variables. So i need each and every mount point to be check for its usage.
example mount points:
/
/dev/shm
/boot
/var

Code:
#!/bin/bash

LIMIT='80'

#Here we declare variable LIMIT with max of used space

DIR="( $(df -Ph | column -t | awk '{print $6}' | grep -v Mounted) )"   -------- here everything is saving as single variable as the output is a 5th column; but i need that to be processed line by line in the below for loop.

#Here we declare variable DIR with name of directory

MAILTO=' xyxz@abc.com'

#Here we declare variable MAILTO with email address

SUBJECT="$DIR disk usage"

#Here we declare variable SUBJECT with subject of email

MAILX='mailx'

#Here we declare variable MAILX with mailx command that will send email

which $MAILX > /dev/null 2>&1

#Here we check if mailx command exist

if ! [ $? -eq 0 ]

#We check exit status of previous command if exit status not 0 this mean that mailx is not installed on system

then

          echo "Please install $MAILX"

#Here we warn user that mailx not installed

          exit 1

#Here we will exit from script

fi

#To check real used size, we need to navigate to folder
for i in $DIR 
do
USED=$(df -Ph $i | awk '{print $5}' | sed -ne 2p | cut -d"%" -f1)
done

#This line will get used space of partition where we currently, this will use df command, and get used space in %, and after cut % from value.

if [ "$USED" -gt "$LIMIT" ]

#If used space is bigger than LIMIT

then

      sudo du -sh ${DIR}/* | $MAILX -s "$SUBJECT" "$MAILTO"

#This will print space usage by each directory inside directory $DIR, and after MAILX will send email with SUBJECT to MAILTO

fi

-
Thiyags.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

mount points

sometimes in Solaris 8 when I go to mount filesystems using either the mount command or by editing the /etc/vfstab, i get a nice little error message saying the the number of allowable mount points has been exceeded. I have read man pages until I am blue in the face and no where can I find what the... (3 Replies)
Discussion started by: manderson19
3 Replies

2. UNIX for Dummies Questions & Answers

Mount Points at reboot

How do I make a mount point reconnect at boot without editing /etc/fstab? Is there an option (or switch) to make this persistent when issuing the mount command from a client? (1 Reply)
Discussion started by: AIXdumb455
1 Replies

3. UNIX for Advanced & Expert Users

mount points

hi, I believe a mount point does not have to be a physical disk, but rather a logical one? Is this correct? if so, how can I find out if my mount points are on different physical disks? thanks (9 Replies)
Discussion started by: JamesByars
9 Replies

4. Shell Programming and Scripting

test a script about mount points

Hi there, I would like people to test a script on as many situations as possible so we can find out errors and lacks. I wrote the script to help me work around mount points, especially when doing batch job on files (like backup) and to avoid duplicate operations through mount points. For... (2 Replies)
Discussion started by: chebarbudo
2 Replies

5. Shell Programming and Scripting

Shell Script to see the mount points.

Hi all, First of all I dont even know the ABC of scripting .. But now I want a Script to see the mount points of the file systems Can any body help plsssssssss :o (1 Reply)
Discussion started by: priky
1 Replies

6. Shell Programming and Scripting

script to monitor mount points on linux box

Hi, the following shell script is not working on linux box sugeestions appreciated. FILE1=/tmp/check1.txt FILE2=/tmp/check2.txt df -k | awk '{if (NR != 1) print $5 $6}' > ${FILE1} awk -F"%" '{if ($1 > 90) print "Warning: Filesystem " $2 " over 90% threshold (" $1 "%)"}' ${FILE1} >... (7 Replies)
Discussion started by: prakash.gr
7 Replies

7. Shell Programming and Scripting

Shell script for Server Mount Point space check

Does anybody have anything I can use to help me out with this one? (4 Replies)
Discussion started by: lbone007
4 Replies

8. Red Hat

Mount Points? How?

Hi folks, I have been asked to performed the following: Add the following new moint points systemA:/avp and SystemB:/usr/sap/trans to be the new linux server ZZZ How can I add those mount points and how those mount points can become another linuz server?:wall::wall::wall: (2 Replies)
Discussion started by: 300zxmuro
2 Replies

9. Shell Programming and Scripting

Linux Shell Script to check for string inside a file?

This is what I have so far grep -lir "some text" * I need to check all files on the system for this text, if the text is found I need to change the file permissions so only ROOT has read and write access. How can this be done? (3 Replies)
Discussion started by: mapleleafs89
3 Replies

10. Shell Programming and Scripting

Shell script for logging cpu and memory usage of a Linux process

I am looking for a way to log and graphically display cpu and RAM usage of linux processes over time. Since I couldn't find a simple tool to so (I tried zabbix and munin but installation failed) I started writing a shell script to do so The script file parses the output of top command through... (2 Replies)
Discussion started by: andy_dufresne
2 Replies
GO-PATH(7)						 Miscellaneous Information Manual						GO-PATH(7)

NAME
go - tool for managing Go source code DESCRIPTION
The Go path is used to resolve import statements. It is implemented by and documented in the go/build package. The GOPATH environment variable lists places to look for Go code. On Unix, the value is a colon-separated string. On Windows, the value is a semicolon-separated string. On Plan 9, the value is a list. GOPATH must be set to build and install packages outside the standard Go tree. Each directory listed in GOPATH must have a prescribed structure: The src/ directory holds source code. The path below 'src' determines the import path or executable name. The pkg/ directory holds installed package objects. As in the Go tree, each target operating system and architecture pair has its own sub- directory of pkg (pkg/GOOS_GOARCH). If DIR is a directory listed in the GOPATH, a package with source in DIR/src/foo/bar can be imported as "foo/bar" and has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a". The bin/ directory holds compiled commands. Each command is named for its source directory, but only the final element, not the entire path. That is, the command with source in DIR/src/foo/quux is installed into DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped so that you can add DIR/bin to your PATH to get at the installed commands. If the GOBIN environment variable is set, commands are installed to the directory it names instead of DIR/bin. Here's an example directory layout: GOPATH=/home/user/gocode /home/user/gocode/ src/ foo/ bar/ (go code in package bar) x.go quux/ (go code in package main) y.go bin/ quux (installed command) pkg/ linux_amd64/ foo/ bar.a (installed package object) Go searches each directory listed in GOPATH to find source code, but new packages are always downloaded into the first directory in the list. AUTHOR
This manual page was written by Michael Stapelberg <stapelberg@debian.org>, for the Debian project (and may be used by others). 2012-05-13 GO-PATH(7)
All times are GMT -4. The time now is 08:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy