I recently set up MRTG to monitor various system statistics on my system. Since configuring MRTG's dizzying array of options for this sort of thing can be daunting, and information difficult to find on how to do this, I thought I'd put this up in the hope that it may be useful.
I installed MRTG using the excellent Fink package manager for Mac OS X, which is probably the easiest way to go about installing it.
Below are a few of the C programs I wrote to gather various system statistics in a simple fashion, without, for example, having to execute and parse the output of programs such as top or uptime.
Info gathering programs
Retrieves load averages and Mach factor values from the kernel and prints them out.
Retrieves and prints load average values (using getloadavg syscall).
Reads the temperature value returned by the onboard temperature sensor on PowerMac G4 (FW800) models from the IO Registry and converts it for display. Also reads the system fan speed table and outputs the current fan speed setting (0-15) based on the temperature value.
Retrieves the current CPU die temperatures from the kernel, if supported by that CPU model, and prints them in °C and °F.
Retrieves from the kernel and displays system memory usage numbers for wired, active, inactive, used, and free memory.
Retrieves the current uptime from the kernel, and prints system uptime as a decimal value in terms of days.
MRTG Configuration File
My current MRTG configuration file, set up to monitor the mach factor, load averages, system temperature, disk space, network traffic, tasks and threads, used and wired memory, active and inactive memory, and system uptime. This uses the above C programs, in addition to these shell scripts.
MRTG Startup Item
Place in /Library/StartupItems to start MRTG at system boot time. For use when mrtg is run in daemon mode (as it is configured for in the above MRTG configuration file).