[Tutor] System Monitoring
Steven D'Aprano
steve at pearwood.info
Wed Feb 9 20:42:16 CET 2011
Sean Carolan wrote:
>> Hi,
>> Im fairly new to programming in python, and have a question.
>> Im looking to build a program that monitor's certain things on my Linux
>> system. for instance disk space. What is the best way to monitor a Linux
>> server without using to much resources?
>> Should I execute shell commands and grab the output of them? Or should i use
>> SNMP. Or is there a better way?
>> Thanks in advance!
>> de Haan
>
> de Haan:
>
> I'm guessing from the text of your message that this is a single,
> stand-alone system. Nagios and cacti are complete overkill for system
> monitoring on a single machine. Here are some other options that you
> can try:
More options are good, but de Haan describes it as a Linux *server*, not
desktop. In any case, some people might disagree that nagios is overkill
-- it depends on what you want to monitor.
> * GUI monitoring - gkrellm is great for this. You can run it and see
> performance graphs and monitors right in a little app on your desktop.
I've used that. I can't say it excited me too much.
> Here's a quickie that I built for a client, it watches the 15 minute
> load average.
[...]
Your script appears to mix tabs and spaces for indentation. Either that
or Thunderbird is playing silly buggers. Specifically:
> for line in open('/proc/loadavg'):
> #If the load average is above threshhold, send alert
> loadav = float(line.split()[2])
> if loadav < threshhold:
> print '15 minute load average is '+str(loadav)+': OK!'
> else:
> print '15 minute load average is '+str(loadav)+': HIGH!'
> sendMail()
Note the inconsistent indent at the end.
--
Steven
More information about the Tutor
mailing list