| Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-09-2009, 07:17 AM
|
#1
|
|
LQ Newbie
Registered: Feb 2009
Posts: 5
Rep:
|
Script for monitoring system performance
I want to make web interface to monitor my system resources. I've already made some long-term graphs using Collectd&Rrdtool but I also want to make some light-weight page with my current resources. What I want to do is to make shell(or perl) script that will collect system information and update web page every 10 seconds. Now I need some template script that collects all common performance data, such as CPU/memory/disk/network usage.
|
|
|
|
06-09-2009, 07:30 AM
|
#2
|
|
LQ Newbie
Registered: May 2009
Posts: 24
Rep:
|
change pvvali for interval time.
this show disk usage for our intranet server, insert free -th to show mem usage,
ifconfig|grep -i byte : show net statistics, and more:
who|awk -F. '{print $1"."$2}'
echo
netstat -an|grep -v -iE 'time_wait'|grep tcp|grep 19\.|awk '{print $5"\t"$4}'|grep -v \*
echo
#echo SMB-tiedostot
#smbstatus -L
echo "apache"
tail -n 5 /var/log/apache2/access_log
echo "ERRORLOG"
tail -n 5 /var/log/apache2/error_log
echo
echo
echo "vsftpd"
tail -n 5 /var/log/vsftpd.log
make your own, but i use this and many variants:
#!/bin/bash
pv=`date +%b" "%-d`
aika=`date +%T|tr ':' '.'`
pvm=$(date +" "%d.%m.%Y"")
pvvali=30
# The HTML output starts here
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Varmistus</title></head><body><pre>"
echo "<meta http-equiv="refresh" content="$pvvali">"
echo "<code>"
echo "Tänään on $pvm, klo $aika<br>Sivu päivittyy automaattisesti $pvvali sek. välein."
echo "</code>"
echo "<p>"
echo "<p>"
df -h /lisatila|grep -i /|awk '{printf "Levyn käyttö, lisatila: "$5}';echo " / 100% prosentista"
echo "<p>"
echo "<code>"
echo "<u>"
echo "<h1>Varmistus</h1>"
du -mhs /lisatila/varmistus/*
echo "<h1>Varmistusarkisto</h1>"
#du -mhs /lisatila/varmistusarkisto/*
ls -Ggah /lisatila/varmistusarkisto/*|awk '{print $3"\t"$4,$5"\t"$6"\t"$7}'|sort
#echo "<h1>Varmistusmedia USB-tikku</h1>"
#du -mhs /media/sda1/*
echo "<h1>Pitka-aikaisarkisto</h1>"
#du -mhs /lisatila/varmistusarkisto/*
ls -Ggah /lisatila/pitka-aikaisarkisto/*|awk '{print $3"\t"$4,$5"\t"$6"\t"$7}'|sort
echo "<h1>Varmistuslog</h1>"
tail -9 /lisatila/varmistuslog.txt
#cat /lisatila/varmistuslog.txt|grep -B 5 -i "$pv"
echo "</code>"
echo "</u"
echo "</body></html>";
|
|
|
|
06-09-2009, 08:33 AM
|
#3
|
|
Member
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770
Rep:
|
Check out nagios. It has built in support for a ton of server monitoring.
|
|
|
|
06-09-2009, 10:22 AM
|
#4
|
|
LQ Newbie
Registered: Feb 2009
Posts: 5
Original Poster
Rep:
|
Nagios is too big and complicated for me. I have small private server for study.
|
|
|
|
06-09-2009, 02:13 PM
|
#5
|
|
Member
Registered: Feb 2007
Location: Caracas, Venezuela
Distribution: Debian x64
Posts: 152
Rep:
|
Try munin
Check Munin, this is a very light weight and easy to install system monitor, is not so powerful like nagios, but do the trick. I monitor my apache, squid, mysql and the resources of the machine.
Try it its very easy to install (i'm using debian so is in repos)and let me know what you think
And here are some How to forge guides for how to setup munin, since i don't know wich Os you are using, you can see if there is any guide for your distro.
Cheers
Last edited by pliqui; 06-09-2009 at 02:18 PM.
Reason: added information
|
|
|
|
06-11-2009, 07:47 AM
|
#6
|
|
Member
Registered: Jul 2003
Posts: 215
Rep:
|
How about collectl? Very lighweight, uses <.1% cpu, has a socket interface to talk to other tools, saves history and can even write the current sample to a local file you could always read in a loop to extract the output. It's used on some of the largest clusters in the world - ever heard of the Top 500 list? It probably collects a lot more data than most tools. Check out this table I put together, keeping in mind it only shows a subset of what collectl can do: http://collectl.sourceforge.net/Matrix.html
By default it samples every 10 seconds but you can always make it more frequent if you prefer. I know of at least one 2500 node clusters where it's sampling each system every 5 seconds, storing the data in a local file and sending a subset upstream to a central monitoring station for display.
-mark
|
|
|
|
06-11-2009, 01:57 PM
|
#7
|
|
LQ Newbie
Registered: Feb 2009
Posts: 5
Original Poster
Rep:
|
I need only current information but munin designed to write statistics to rrd logs. Do you know how to make munin or collectd to output current statistics to stdout?
Also one guy told me that sysstat package is a good thing. How about this one? Will it do the trick?
|
|
|
|
06-22-2009, 09:22 AM
|
#8
|
|
Member
Registered: Jul 2003
Posts: 215
Rep:
|
Collectl can report stats to the terminal in real-time. It can also write to a file and let you play the data back, but if you really only want current stats reported on the terminal that's fine too.
You can certainly use sysstat tools, but be aware that they take many lines of data to report what's going on and that can be pretty hard to read in real-time. In brief mode collectl can let you watch many things at once, all on the same line which makes it pretty easy to spot anomalous data.
-mark
|
|
|
|
06-22-2009, 01:09 PM
|
#9
|
|
Member
Registered: May 2006
Location: Bayern, Germany
Distribution: Many
Posts: 224
Rep:
|
What about MRTG ? You can monitor almost anything!
|
|
|
|
06-25-2009, 06:13 AM
|
#10
|
|
Member
Registered: Jul 2003
Posts: 215
Rep:
|
Part of it also comes down to how accurate you want your graphs to be. I had tried collecting samples every 10 seconds with collectl and stuffing them into rrd. Much to my surprise the graphs were NOT accurate as rrd 'normalizes' your data in less data points. In other words if you have 8640 data samples (a day's worth of 10 second samples) and try to plot it on a graph that only has 100 columns, you only get one column for every 86 samples! The plots look pretty but are only approximations. That's why I use gnuplot - it plots everything even if the results aren't as good looking.
-mark
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:33 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|