FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 07-28-2008, 06:33 AM
"Mad Unix"
 
Default script

Hi ALL


#!/bin/sh
# Shell script to monitor or watch the disk space

# It will send an email to $ADMIN, if the (free avilable) percentage
# of space is >= 90%
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>

# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.

# ----------------------------------------------------------------------
# Linux shell script to watch disk space (should work on other UNIX oses )
# SEE URL: http://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html

# set admin email so that you can get email
ADMIN="me@somewher.com"
# set alert level 90% is default
ALERT=90
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | 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


Am trying to run the above script on my machine, it gave the following error
[root@linux8 script]# ./disk_monitor.sh

./disk_monitor.sh: line 23: [: /dev/mapper/VolGroup00-LogVol00: integer _expression_ expected
./disk_monitor.sh: line 23: [: /: integer _expression_ expected

Any help?

--
Your search - madunix - did not match any documents.



_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 07-28-2008, 06:43 AM
Mogens Kjaer
 
Default script

Mad Unix wrote:
...

df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' |


Try changing "df -H" into "df -H -P"

Mogens
--
Mogens Kjaer, Carlsberg A/S, Computer Department
Gamle Carlsberg Vej 10, DK-2500 Valby, Denmark
Phone: +45 33 27 53 25, Fax: +45 33 27 47 08
Email: mk@crc.dk Homepage: http://www.crc.dk
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 07-28-2008, 09:03 PM
Sergey Podushkin
 
Default script

Mad Unix wrote:

I suggest make it a little bit lighter:
inline corrections:

#!/bin/sh
# Shell script to monitor or watch the disk space
# It will send an email to $ADMIN, if the (free avilable) percentage
# of space is >= 90%
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ----------------------------------------------------------------------
# Linux shell script to watch disk space (should work on other UNIX oses )
# SEE URL:
http://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html

# set admin email so that you can get email
ADMIN="me@somewher.com <mailto:me@somewher.com>"
# set alert level 90% is default
ALERT=90

df -HP | grep -vE '^Filesystem|tmpfs|cdrom' |
while read partition size used free perc mnt ;
do
usep=$(echo $perc | tr -d '%' )
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


it works for me.

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 07-30-2008, 04:39 PM
"Marcelo Roccasalva"
 
Default script

On Mon, Jul 28, 2008 at 3:33 AM, Mad Unix <madunix@gmail.com> wrote:
>
>
> Hi ALL
>
>
> #!/bin/sh
> # Shell script to monitor or watch the disk space

I use this one-liner:

df -P| awk '$5+0>90{print $0|"mutt -s df-k@`hostname` user@domain.com"}'

Probably, you should add -t ext3 to avoid reporting nfs or other
special filesystems...

--
Marcelo

"¿No será acaso que ésta vida moderna está teniendo más de moderna que
de vida?" (Mafalda)
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 09-30-2008, 07:47 PM
"Mad Unix"
 
Default script

Dear ALL,

I need some help with bash scripting, a script that search the content
of multiple files and replace old string ip "10.5.1.10" with the new
string ip "127.128.1.10" it will search in specific folder and sub
folders

Thanks
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 09-30-2008, 08:09 PM
"Tharun Kumar Allu"
 
Default script

On Tue, Sep 30, 2008 at 3:47 PM, Mad Unix <madunix@gmail.com> wrote:

Dear ALL,



I need some help with bash scripting, a script that search the content

of multiple files and replace old string ip "10.5.1.10" with the new

string ip "127.128.1.10" it will search in specific folder and sub

folders



Thanks

_______________________________________________

CentOS mailing list

CentOS@centos.org

http://lists.centos.org/mailman/listinfo/centos


sed -i* 's/10.5.1.10/127.128.1.10/'

should help you
example
find /path/ <additional parameters to find the files> | xargs sed -i* 's/10.5.1.10/127.128.1.10/'

--
Tharun Kumar Allu
==============


_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 09-30-2008, 10:08 PM
Chris Geldenhuis
 
Default script

Mad Unix wrote:

Dear ALL,

I need some help with bash scripting, a script that search the content
of multiple files and replace old string ip "10.5.1.10" with the new
string ip "127.128.1.10" it will search in specific folder and sub
folders

Thanks
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos



How about:

find <startdir> -exec sed "s/10.5.1.10/127.128.1.10/" {} ;

ChrisG
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 09-30-2008, 11:06 PM
"Amos Shapira"
 
Default script

Except that you better quote the dots in the search string and put
word boundary match around it or you'll end up replacing too much. See
sed's -r switch for more.

On 10/1/08, Chris Geldenhuis <chris.gelden@iafrica.com> wrote:
> Mad Unix wrote:
>> Dear ALL,
>>
>> I need some help with bash scripting, a script that search the content
>> of multiple files and replace old string ip "10.5.1.10" with the new
>> string ip "127.128.1.10" it will search in specific folder and sub
>> folders
>>
>> Thanks
>> _______________________________________________
>> CentOS mailing list
>> CentOS@centos.org
>> http://lists.centos.org/mailman/listinfo/centos
>>
>>
> How about:
>
> find <startdir> -exec sed "s/10.5.1.10/127.128.1.10/" {} ;
>
> ChrisG
> _______________________________________________
> CentOS mailing list
> CentOS@centos.org
> http://lists.centos.org/mailman/listinfo/centos
>

--
Sent from Google Mail for mobile | mobile.google.com
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 09-30-2008, 11:07 PM
MHR
 
Default script

On Tue, Sep 30, 2008 at 3:08 PM, Chris Geldenhuis
<chris.gelden@iafrica.com> wrote:
>
> How about:
>
> find <startdir> -exec sed "s/10.5.1.10/127.128.1.10/" {} ;
>

First, the ' characters are unnecessary and confusing, except the
one that precedes the semi-colon.

Second, that won't work. Sed does not perform on files in place - its
output is sent to stdout unless it is redirected, and you can't
redirect it back to the original file. To do something this way,
you'd need a script that replaced the input file and used 'sed' to
generate the new one (and then the script would have to rename it).

mhr
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 09-30-2008, 11:12 PM
"Barry L. Kline"
 
Default script

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

MHR wrote:

> Second, that won't work. Sed does not perform on files in place - its
> output is sent to stdout unless it is redirected, and you can't
> redirect it back to the original file. To do something this way,
> you'd need a script that replaced the input file and used 'sed' to
> generate the new one (and then the script would have to rename it).

Au contraire:

- From the sed man page:

-i[SUFFIX], --in-place[=SUFFIX]

edit files in place (makes backup if extension supplied)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFI4rJJCFu3bIiwtTARArCgAJ9Ov/hR5rZJZxn3t2vqqJYwcCHztQCgldo+
aqaYmuuDKk/eWwTR/8f5qPg=
=IkKM
-----END PGP SIGNATURE-----
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 09:07 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org