SourceFiles.org - Use the Source, Luke
Home | Register | News | Forums | Guide | MyLinks | Bookmark

Related Sites

Latest News
  General News
  Reviews
  Press Releases
  Software
  Hardware
  Security
  Tutorials
  Off Topic


Back to files

Loadmeter v1.20

This is a useful little system monitoring utility I've hacked up to keep track of various system stats. It monitors:

  • Load average
  • Uptime
  • Disk usage
  • Memory usage

In its normal state it displays a window with a coloured bar graph showing the load average for the past minute. This is also shown in digits at the top of the window. both are updated every second. A red 'notch' marks the maximum load since it was started, and can be reset by pressing button2 or hidden with button3. The blue notch shows the 5 minute load average.

By clicking with button1, a pop-up window appears showing the uptime, the capacity of each filesystem, and memory/swap usage. More detailed info on each filesystem is available by highlighting the corresponding one. The way this window pops down is intentional, just to make it interesting. :)
Any filesystems with higher usage than specified by the -warn option (default 90%) are shown with a (default)green background. The '-disk' option can also be used as an 'instant warn' feature.

Press Escape in the top level window to exit.

Loadmeter also has the ability to override window managers. Giving the option '-override' causes the top-level window to have the override_redirect bit set. This is useful for window managers that insist upon decorating standard clients (eg Enlightenment, at least up to DR0.9). If you've given this option, then you can still resize and move the window. During moving and resizing, the cursor displays the geometry.

Ctrl-button1 lowers the window.
Ctrl-button2 raises and moves the window. Ctrl-button3 raises and resizes the window. A SIGUSR1 sent to the process will also raise the top level window.

There is also a '-parent' switch, which can be used to specify another window (in decimal or hex form) to use as the parent for the toplevel one (default is the root). This is useful for banking several together inside another window for easy positioning, etc. The 'lower' function doesnt work if -parent is specified. Also note that you can't use both -override and -parent at the same time.

Command-line options:

-disp <display>         Specify which X server to connect to
-geom <+x+y>            Specify position on the screen
-sync                           Call sync() when checking disk usage
-numfont <font>         Use <font> for the load digits
-labelfont <font>       Use <font> for the hostname label
-popupfont <font>       Use <font> for the cursor and popup window
-popupbg <colour>       Use <colour> for the popup background
-popupfg <colour>       Use <colour> for the foreground of the popup
-warnbg <colour>        Use <colour> for the high disk usage warning colour
-meter <colour>         Use <colour> for the disk usage meter bar
-warn <pct>                     Min percent capacity reqd to highlight a filesystem
-label <label>          Bargraph label to use instead of the hostname
-name <name>            Name of the app to present to the WM
-bh <blockheight>       Height of individual bargraph blocks (in pixels)
-override                       Always override window manager
-parent <window>        Use <window> as the parent for the toplevel window
-noshrink                       Don't do fancy popup window shrinking
-disk                           Show a warning when disk usage exceeds '-warn' value
-nogeom                 Disables displaying the window geometry in the cursor
                        whilst moving/resizing the main window.

These features are also available using Xresources. Eg you can have:

loadmetersync: True
loadmeter
label: load

loaded into the server database.

Features
  • Easy to read coloured bargraph display.
  • Hostname displayed.
  • Maximum load indicator.
  • Uptime, memory and filesystem usage stats
  • Low memory usage (around half that of xload) as it uses raw Xlib.
  • Forks no child processes, but gathers stats directly from the system
  • Efficient, both X11 network-wise (except stats pop-down :) and memory wise.
  • Built-in resize and move functions.
  • Can display itself within another window
  • Takes advantage of the X resource database
  • Can be ported to other Unices fairly easily. Look at getinfo.tmpl for what's needed.

Bugs (other features? :)

  • If colours dont get allocated or files cant be opened, it'll probably crash. The reason for this is lack of checking, but this saves memory and should succeed almost always anyway (unless /proc isn't mounted :).
  • Memory info in Solaris isn't particularly correct. Patches for this would be appreciated...unfortunately I havent found much documentation on getting good memory stats yet...

Changes since version 1.17

  • I've ported to Solaris! Almost all differences are in getinfo.c so porting doesnt require major changes. Note that loadmeter must be run with root priveliges under Solaris in order to read the kernel symbols to get info. So far only GCC has been tested - it might not work with other compilers.
  • Added 'getinfo.tmpl', a template for porting to other Unices. Just fill the functions with code to grab the right values from the system and that should be it.
  • Added '-nogeom' option.
  • Formats large numbers with commas to improve readability.

Changes since version 1.15

  • install target added to Makefile
  • NFS usages bug fixed

Changes since version 1.1

  • Memory leaks fixed
  • problem where some filesystem dont show up is fixed
  • Displays used disk space

Changes since version 1.0

  • No longer crashes when too many filesystems are mounted
  • -disk, -parent, -noshrink options
  • Manpage

Having it display values from a pipe is something I hope to have in a later version, plus the ability to have the orientation either vertical or horizontal. Patches please!

Patches/contributions included so far from:

Patrik.Flykt@iki.fi
bob@acm.org
salnick@salnick.cac.washington.edu
dcrowley@san.rr.com

Check http://www.zip.com.au/~bb/linux/ for updates.

Hack by Ben Buxton (bb@zip.com.au)

17 Sept 98.


Other Sites

Discussion Groups
  Beginners
  Distributions
  Networking / Security
  Software
  PDAs

About | FAQ | Privacy | Awards | Contact
Comments to the webmaster are welcome.
Copyright 2006 Sourcefiles.org All rights reserved.