LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 06-09-2009, 07:17 AM   #1
Poma
LQ Newbie
 
Registered: Feb 2009
Posts: 5

Rep: Reputation: 0
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.
 
Old 06-09-2009, 07:30 AM   #2
Marko Hyvärinen
LQ Newbie
 
Registered: May 2009
Posts: 24

Rep: Reputation: 15
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&auml;n&auml;&auml;n on $pvm, klo $aika<br>Sivu p&auml;ivittyy automaattisesti $pvvali sek. v&auml;lein."
echo "</code>"

echo "<p>"

echo "<p>"
df -h /lisatila|grep -i /|awk '{printf "Levyn k&auml;ytt&ouml;, 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>";
 
Old 06-09-2009, 08:33 AM   #3
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Rep: Reputation: 42
Check out nagios. It has built in support for a ton of server monitoring.
 
Old 06-09-2009, 10:22 AM   #4
Poma
LQ Newbie
 
Registered: Feb 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Nagios is too big and complicated for me. I have small private server for study.
 
Old 06-09-2009, 02:13 PM   #5
pliqui
Member
 
Registered: Feb 2007
Location: Caracas, Venezuela
Distribution: Debian x64
Posts: 156

Rep: Reputation: 17
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
 
Old 06-11-2009, 07:47 AM   #6
markseger
Member
 
Registered: Jul 2003
Posts: 241

Rep: Reputation: 25
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
 
Old 06-11-2009, 01:57 PM   #7
Poma
LQ Newbie
 
Registered: Feb 2009
Posts: 5

Original Poster
Rep: Reputation: 0
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?
 
Old 06-22-2009, 09:22 AM   #8
markseger
Member
 
Registered: Jul 2003
Posts: 241

Rep: Reputation: 25
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
 
Old 06-22-2009, 01:09 PM   #9
goossen
Member
 
Registered: May 2006
Location: Bayern, Germany
Distribution: Many
Posts: 224

Rep: Reputation: 41
What about MRTG ? You can monitor almost anything!
 
Old 06-25-2009, 06:13 AM   #10
markseger
Member
 
Registered: Jul 2003
Posts: 241

Rep: Reputation: 25
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
 
  


Reply

Tags
monitoring, performance, resources, script, system


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
system monitoring script nkd Linux - Software 3 10-30-2008 10:15 AM
Understanding System Performance Monitoring Tools Output SentiBlue Linux - Newbie 3 09-12-2008 04:35 PM
SNMP master & SNMP client Script for system monitoring ratul_11 Programming 1 12-24-2007 05:32 AM
Performance Monitoring Script 3ttt Linux - Newbie 4 05-26-2007 03:15 AM
Monitoring System Performance lapthorn Linux - General 3 04-22-2004 03:52 AM


All times are GMT -5. The time now is 08:44 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration