Search:  

 
 
   All ForumsHot TopicsGallery






how-to block ads


 
Forums » Tech and Talk » OS and Software » All Things Unix » Mailserver Statistics Shell Script
Search Topic:
Uniqs:
128
Share Topic:
RSS topic:
toggle:
flat / full
normal / watch
Posting:
Post a:
Post a:
parreral port woes »
« netstat segmentation fault  
AuthorAll Replies


technick
Premium
join:2000-12-16
Loganville, GA

Mailserver Statistics Shell Script

I've gotta admit my script fu is very weak... Most of the time if I ever needed a program or app I would just look for something that someone has already made, etc. I've been doing some studying on script writing and well this is my first. Please be nice =).

This is designed to work on systems with Sendmail / ClamAV and depends on standard unix utils for the rest of the info. Here is the script if anyone else wants to use it or thinks they have a use for it. Very simple script...

Here is a sample output of it.


System Statistics v0.001a by Nicholas Winn
Mon Dec 12 20:31:23 EST 2005
xxx.xxxxxxxxxxxxxxxxx.org
inet addr:10.0.1.6 Bcast:10.0.1.255 Mask:255.255.255.0
inet addr:62.122.1.13 Bcast:62.122.1.65 Mask:255.255.255.240
================================================================================== ============
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free inact active si so bi bo in cs us sy id wa
1 0 696 8728 133668 306792 0 0 7 36 2 14 1 0 98 0
================================================================================== ============
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda2 11499944 1576984 9329360 15% /
/dev/hda1 544596 24044 492440 5% /boot
/dev/shm 253992 0 253992 0% /dev/shm
/dev/hda5 24789348 206072 23303704 1% /home
================================================================================== ============
Dec 12 20:29:40 mailserver pop3-login: Login: db [::ffff:10.0.1.135]
Dec 12 20:29:47 mailserver pop3-login: Login: vanessa [::ffff:10.0.1.12]
Dec 12 20:29:50 mailserver pop3-login: Login: vaxt [::ffff:10.0.1.66]
Dec 12 20:30:03 mailserver imap-login: Login: dgionfrio [::ffff:10.0.1.113]
Dec 12 20:30:03 mailserver imap-login: Login: dgionfrio [::ffff:10.0.1.113]
Dec 12 20:30:33 mailserver sendmail[15813]: jBD1UT5a015813: from=root, size=11083, class=0, nrcpts=1, relay=root@localhost
Dec 12 20:30:47 mailserver pop3-login: Login: vanessa [::ffff:10.0.1.12]
Dec 12 20:31:04 mailserver imap-login: Login: dgionfrio [::ffff:10.0.1.113]
Dec 12 20:31:04 mailserver imap-login: Login: dgionfrido [::ffff:10.0.1.113]
Dec 12 20:31:11 mailserver pop3-login: Login: fstock [::ffff:31.111.99.174]
================================================================================== ============
Dec 12 19:37:27 mailserver sendmail[9165]: jBD0bPJ9009165: Milter add: header: X-Virus-Status: Infected with Worm.Sober.U
[root@mailserver ~]#

Here is the full script

while true
do
clear
echo "System Statistics v0.001a by Nicholas Winn"
date
hostname
ifconfig eth0 | tail -9 | head -1
ifconfig eth1 | tail -9 | head -1
echo "================================================================================== ============"
vmstat -a
echo "================================================================================== ============"
df
echo "================================================================================== ============"
tail -10 /var/log/maillog
echo "================================================================================== ============"
cat /var/log/maillog | grep Infected | tail -1
sleep 1
done

--
"Our greatest glory consists not in never falling, but in rising everytime we fall." - Confucius
Bellsouth Free Since 10/05 - To Hell With Bellsouth

Advocatus Diaboli


BeesTea
Network Janitor
Premium,VIP
join:2003-03-08
00000

Nice work. A few things you could take advantage of.
ifconfig eth0 | tail -9 | head -1
could be
ifconfig eth0 | grep Bcast
and,
cat /var/log/maillog | grep Infected | tail -1
could be
grep Infected /var/log/maillog | tail -n1

Finally, every where you have tail, head, etc, you should use -n1 and not -1 etc, -(number) is deprecated.

You might also wrap the whole thing into a single cat.

while true
do
clear

cat << EOF
System Statistics v0.001a by Nicholas Winn
`/bin/date`
`/bin/hostname`
`/sbin/ifconfig -a | grep Bcast`
================================================================================== ============
`/usr/bin/vmstat -a`
================================================================================== ============
`/bin/df`
================================================================================== ============
`tail -n10 /var/log/maillog`
================================================================================== ============
`grep Infected /var/log/maillog | tail -n1`
EOF

sleep 1
done

--
Captain of the ATU Tux Racer Clan.
Forums » Tech and Talk » OS and Software » All Things Unixparreral port woes »
« netstat segmentation fault  


Saturday, 28-Nov 02:45:39 Terms of Use | Privacy Policy | Hosting by www.nac.net - DSL,Hosting & Co-lo | feedback | contact
over 10 years online! © 1999-2009 dslreports.com.
page compression OFF
Most commented news this week
· [121] Time Warner Cable Fires Broadside At Broadcasters
· [112] New AT&T Ad Campaign Hits Back At Verizon
· [96] Apple Joins AT&T Verizon Snark Fest
· [87] New Bill Takes Aim At Higher Verizon ETFs
· [71] TiVo Sees Record Customer Losses
· [69] In-Flight Internet Headed For Bumpy Landing?
· [66] Verizon CEO: Hulu Will Be Dead Soon
· [62] Thanksgiving Open Thread
· [50] Weekend Open Thread
· [40] EFF Wages War On Fine Print
Most people now reading
· 3.x Feral Druid - Bear Tanking Guide [World of Warcraft]
· Windows 7 boot manager editing questions [Microsoft Help]
· [ PVP] 3.2 DK PvP D/W Spec... [World of Warcraft]
· 5 hour energy for diabetic [General Questions]
· DIR-655 New Beta 1.32b09 [D-Link]
· HOW-TO: QoS and Tomato (fixes "choppy voice") [MagicJack]
· [Newsgroups] Newzleech down? [Filesharing Software]
· Verizon FIOS Digital Adapter Costs Options? $3.99 is Pricey [Verizon FIOS TV]
· TSI Usenet vs. Paid Usenet [TekSavvy]
· [Vista] Why is HD So Full? [Microsoft Help]