Need a Script

Taking care of your Linux box.

Need a Script

Postby telenor » Tue Mar 31, 2009 3:56 pm

Hi,

I need a script that calculate the size of following logs Plus Disk Usage size of "/" then mails all the calculating sizes to "xvz@abcdomain.com".


LOG FILES ARE:

* /var/log/cacti/cacti.log
* /var/log/maillog
telenor
Havaldaar
 
Posts: 104
Joined: Tue Mar 29, 2005 11:08 am

Re: Need a Script

Postby LinuxFreaK » Tue Apr 07, 2009 11:16 am

Dear telenor,
Hello,

telenor wrote:I need a script that calculate the size of following logs Plus Disk Usage size of "/" then mails all the calculating sizes to "xvz@abcdomain.com".

LOG FILES ARE:

* /var/log/cacti/cacti.log
* /var/log/maillog


Code: Select all

#!/bin/sh

MAILTO="xyz@abcdomain.com"

Log="/tmp/Log.tmp"

echo "Cacti Log Size :`du -sch /var/log/cacti/cacti.log` > $Log
echo "Mail Log Size :`du -sch /var/log/maillog` >> $Log
echo "This is an automated email generated by system" | mail -s "Log Size Notification" $MAILTO < /tmp/Log.tmp

rm -f $Log


# crontab -e

Code: Select all

0 0 * * * sh /root/log.sh > /dev/null 2>&1


Best Regards.
Farrukh Ahmed
LinuxFreaK
Site Admin
 
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
ICQ: 82075802
Website: http://www.linuxpakistan.net/wiki/index.php?pagename=LinuxFreak
WLM: f4fahmed@hotmail.com
Yahoo Messenger: f4fahmed@yahoo.com
AOL: linuxpakistan@aol.com
Location: Karachi

Postby x2oxen » Tue Apr 07, 2009 11:36 am

For calculating Disk Usage size of "/" please add a line in the script

Code: Select all

echo "Mail Log Size :`df -h ` >> $Log
Muhammad Usman
+92-321-6640501
Chemonics International
http://usmanpk.com
x2oxen
Major General
 
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Website: http://usmanpk.com
WLM: x2oxen@hotmail.com
Yahoo Messenger: x2oxen
Location: Faisalabad

Re:

Postby LinuxFreaK » Thu Apr 09, 2009 3:39 pm

Dear x2oxen,
Salam,

x2oxen wrote:For calculating Disk Usage size of "/" please add a line in the script

Code: Select all

echo "Mail Log Size :`df -h ` >> $Log


Are you sure ?

Output of your command.

Code: Select all

root@gws4s:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              32G   25G  5.9G  81% /
varrun                505M  216K  505M   1% /var/run
varlock               505M     0  505M   0% /var/lock
udev                  505M   52K  505M   1% /dev
devshm                505M     0  505M   0% /dev/shm
root@gws4s:~#


Best Regards.
Farrukh Ahmed
LinuxFreaK
Site Admin
 
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
ICQ: 82075802
Website: http://www.linuxpakistan.net/wiki/index.php?pagename=LinuxFreak
WLM: f4fahmed@hotmail.com
Yahoo Messenger: f4fahmed@yahoo.com
AOL: linuxpakistan@aol.com
Location: Karachi

Postby x2oxen » Tue Apr 14, 2009 4:07 pm

it will tell him that how much disk space is available on his mounted partitions. It there anything wrong with it??
Muhammad Usman

+92-321-6640501

Chemonics International

http://usmanpk.com
x2oxen
Major General
 
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Website: http://usmanpk.com
WLM: x2oxen@hotmail.com
Yahoo Messenger: x2oxen
Location: Faisalabad

Postby lambda » Tue Apr 14, 2009 5:28 pm

yes, it's not what the poster wanted. the poster wants just the disk usage for /, probably can't use the other info (or parse out what he needs from it).

also, "-h" is for humans, not for scripts. use "-k".
Watch out for the Manners Taliban!
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
lambda
Major General
 
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Website: http://www.hungry.com/~fn/
Location: Lahore

Postby x2oxen » Wed Apr 15, 2009 1:32 pm

Then he can go for just

Code: Select all

df /


or

Code: Select all

df -h /


or

Code: Select all

df -k /


or any other way he likes :lol:
Muhammad Usman

+92-321-6640501

Chemonics International

http://usmanpk.com
x2oxen
Major General
 
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Website: http://usmanpk.com
WLM: x2oxen@hotmail.com
Yahoo Messenger: x2oxen
Location: Faisalabad


Return to “%s” Administration

Who is online

Users browsing this forum: No registered users and 1 guest

cron