Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Monitor 10.2.8 clients using MRTG and NET-SNMP UNIX
I recently wanted to get mrtg (MultiRouterTrafficGrapher) monitoring each of my OS X 10.2.8 Client boxes (e.g. gateway / router / firewall, mail / DNS, webserver, etc.). To do so requires having SNMP running on each of the boxes. As far as I know, SNMP support is built into OS X Server, but not OS X Client. I *thought* I'd heard it's supposed to be "in there," but I'll be darned if I could find it.

So, I decided to look to the open source net-snmp package to get up and running. There's lots of info for UNIX installs on the web -- as expected, virtually identical for OS X. Pre-requisites for an mrtg plus net-snmp install were fairly simple, with install order being:
  1. On each 'monitored' box:
    • net-snmp
  2. On webserver:
    • dlcompat
    • libpng
    • libgd
    • mrtg
For those interested, I've outlined the how-to steps in the remainder of this hint (it's a cut and paste from a more involved set of tasks, but I think I got rid of any irrelevant dependencies). It takes all of about 30 minutes (with a coffee break!). It ain't pretty, but should be self explanatory. FYI, this works nicely on a different boxes, including a PPC 8500 with Sonnet G3 333MHz CPU upgrade and Asante696 10/100 Ethernet running MacOSX 10.2.8; a Beige G3 with Sonnet G4 500MHz CPU upgrade and Asante696 10/100 Ethernet and MacOSX 10.2.8; and a TiBook G4 800MHz with onboard Ethernet and MacOSX 10.2.8. Oh, and latest Develepor Tools and gcc 3.3 compiler are required, of course ...

I think that's everything. as always, be forwarned, you're monkeying around with a non-standard system ... so, Caveat Emptor!

[robg adds: I have *not* tested this one, nor do I know if anything changes under Panther. I would clearly classify this as an advanced hint -- although detailed, the explanation assumes a certain level of Unix knowledge.]

Login as root @ shell; base of source tree: /usr/ports

Install net-snmp (5.0.9) on each machine you wish to monitor
Reference URL: Tutorials: Downloads, including a couple of patches:After downloading, do:

% gnutar zxf net-snmp-5.0.9.tar.gz
% cd /usr/ports/net-snmp-5.0.9
# apply patches:

% patch perl/SNMP/SNMP.xs ../net-snmp-5.0.9-p01-use-numeric.patch
% patch < ../net-snmp-5.0.9-p02-with-perl.patch

setenv CPPFLAGS "-no-cpp-precomp"

./configure \
--prefix=/usr/local \
--with-openssl \
--with-default-snmp-version=3 \
The output should look like:

            Net-SNMP configuration summary:

  Net-SNMP Version:           5.0.9
  Building for:               darwin6
  Network transport support:  Callback Unix TCP UDP
  SNMPv3 Security Modules:    usm
  Agent MIB code:             mibII ucd_snmp snmpv3mibs notification
                              target agent_mibs agentx agent_mibs utilities
  Authentication support:     MD5 SHA1
  Encryption support:         DES
If that worked, then do:

% make
% umask 022
% make install
% rehash
If you have a pre-existing /etc/snmpd.conf:

% mv /etc/snmpd.conf /etc/snmpd.confORIG
Create a simple /etc/snmpd.conf, you can mod it later as you wish. You can change local_ro_user to whatever you wish, but rememeber to make it consistent in the MRTG config, later. Using your favorite editor (vi /etc/snmpd.conf), insert this one line:

rocommunity local_ro_user
Now check your install with snmpd -v; the output should look like:
 NET-SNMP version:  5.0.9
Start the daemon with snmpd -c /etc/snmpd.conf, and then test it by typing:
% snmpwalk -v 1 -c local_ro_user localhost system
The output should look like this:
SNMPv2-MIB::sysORDescr.7 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.8 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.9 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (12) 0:00:00.12
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (12) 0:00:00.12
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (12) 0:00:00.12
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (164) 0:00:01.64
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (304) 0:00:03.04
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (430) 0:00:04.30
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (433) 0:00:04.33
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (433) 0:00:04.33
SNMPv2-MIB::sysORUpTime.9 = Timeticks: (433) 0:00:04.33
Now set up an OS X Startup items, and some start, stop, and restart tools ... First, the StartupItem item directory needs to be created:

% mkdir /System/Library/StartupItems/snmpd
Now create a few files in your favorite text editor (here, vi is used as an example...)


% vi /usr/local/bin/netsnmpd_restart
The contents of this file should be:


echo "Killing SNMPD"
killall snmpd


% vi /usr/local/bin/netsnmpd_start
The contents of this file should be:



% vi /usr/local/bin/netsnmpd_stop
The contents of this file should be:

echo "Killing Spamd"
killall snmpd

% vi /System/Library/StartupItems/snmpd/snmpd
The contents of this file should be:

. /etc/rc.common

if [ "${NETSNMPD:=-NO-}" = "-YES-" ]; then
  ConsoleMessage "Starting NetSNMPd daemon"
  /usr/local/sbin/snmpd -c /etc/snmpd.conf

% vi /System/Library/StartupItems/snmpd/StartupParameters.plist
The contents of this file should be:

{   Description     = "NetSNMPd"; 
  Provides        = ("NetSNMPd"); 
  Requires        = ("Network","Resolver","Disks"); 
  OrderPreference = "Late";
Clean-up permissions for the files ...

% chmod 754 /usr/local/bin/netsnmpd_stop
% chmod 754 /usr/local/bin/netsnmpd_start
% chmod 754 /usr/local/bin/netsnmpd_restart

% chown -R root:wheel /System/Library/StartupItems/snmpd
% chmod 755 /System/Library/StartupItems/snmpd
% chmod 755 /System/Library/StartupItems/snmpd/snmpd
% chmod 644 /System/Library/StartupItems/snmpd/StartupParameters.plist
Enable NETSNMPD launch at startup by adding the following line to your hostconfig. Open host config in your favorite editor (vi /etc/hostconfig), and add this line:

Reboot your machine, and then check to see if snmpd is active with:

% ps -ax | grep snmpd

reference URL: dlcompat page @ Fink

% cvs -d login
% > password: (RETURN)
% cvs -d co -d dlcompat proj/dlcompat
% cd /usr/ports/dlcompat
% autoconf
%./configure \
% make
% make install
reference URL: dlcompat page @ Fink Downloads: libpng-1.2.5.tar.gz

% gnutar zxf libpng-1.2.5.tar.gz
% cd /usr/ports/libpng-1.2.5
% cp /usr/ports/libpng-1.2.5/scripts/makefile.macosx /usr/ports/libpng-1.2.5/makefile
Once that's done, there's a bit of editing to do...

% vi /usr/ports/libpng-1.2.5/makefile
The following changes should be made:

+++   ZLIBLIB=/usr/lib 
+++        ZLIBINC=/usr/include 
+++    MANPATH=/usr/local/man

---       LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -current_version $(PNGVER)
+++    LDFLAGS=-dynamiclib -L. -L$(ZLIBLIB) -lpng -lz -current_version $(PNGVER)
Then just make and make install...

% make
% make install
Reference URL: GD library web page Downloads: gd-2.0.15.tar.gz

setenv CPPFLAGS "-no-cpp-precomp -I/usr/X11R6/include/freetype2/" ;\
setenv LDFLAGS "-lz -lpng"
% gnutar zxf gd-2.0.15.tar.gz
% cd /usr/ports/gd-2.0.15
% ranlib /usr/local/lib/libpng.a
% ./configure \
% make
% make install
NOTE: since you now have CPAN, you might as well make it usable in Perl's CPAN as well:

% cpan> install GD::Text GD::Graph GD::Graph3d HTML::Tagset HTML::Parser File::Spec
Reference URL: MRTG web page Downloads: mrtg-2.10.5.tar.gz

% gnutar zxvf mrtg-2.10.5.tar.gz
% cd /usr/ports/mrtg-2.10.5
% ./configure \
--prefix=/usr/local/mrtg-2 \
--with-gd-lib=/usr/local/gd/lib \
% make
% make install
Create a directory in your WebServer document tree for the MRTG-created html files e.g:

% mkdir /Library/WebServer/Documents/mrtg
Create a config directory for MRTG, e.g:

mkdir -p /Library/WebServer/mrtg/cfg
TEST and autocreate a cfg file. Notes:
  • Replace NAME_OF_SERVER & YOUR_DOMAIN, as appropriate
  • Community name here is: local_ro_user, same as in /etc/snmpd.conf, above
  • Setting default SNMP version to "3"
  • Refer to ethernet interfaces by description, e.g., "en0"

% /usr/local/mrtg-2/bin/cfgmaker \
--global 'WorkDir: /Library/WebServer/Documents/mrtg'  \
--global 'Options[_]: bits,growright' \
--output /Library/WebServer/mrtg/cfg/NAME_OF_SERVER.cfg \
--snmp-options=:::::3 \
--ifref=descr \ 
If everything's working, look for the last line of output:
 --base: Writing /Library/WebServer/mrtg/cfg/NAME_OF_SERVER.cfg
Now make a stats directory and copy some stuff into it:

% mkdir /Library/WebServer/Documents/mrtg/stats

% cp /usr/local/mrtg-2/share/doc/mrtg2/*.png /Library/WebServer/Documents/mrtg/stats/ ;\
cp /usr/local/mrtg-2/share/mrtg2/icons/*.png /Library/WebServer/Documents/mrtg/stats/
The autoconfig should do a fine job, but of course, you can always edit each /Library -> WebServer -> mrtg -> cfg -> NAME_OF_SERVER.cfg as desired. Set up cron jobs to refresh MRTG graphs, e.g., every five minutes by adding one line for each (NAME_OF_SERVER) server to /private/etc/crontab:

0-59/5 * * * * root /usr/local/mrtg-2/bin/mrtg /Library/WebServer/mrtg/cfg/NAME_OF_SERVER.cfg
Run MRTG three times for each server to INITIALIZE

% /usr/local/mrtg-2/bin/mrtg /Library/WebServer/mrtg/cfg/NAME_OF_SERVER.cfg ;\
/usr/local/mrtg-2/bin/mrtg /Library/WebServer/mrtg/cfg/NAME_OF_SERVER.cfg ;\
/usr/local/mrtg-2/bin/mrtg /Library/WebServer/mrtg/cfg/NAME_OF_SERVER.cfg
Make an index file in the MRTG website directory for all the servers ...

% /usr/local/mrtg-2/bin/indexmaker \
--output=/Library/WebServer/Documents/mrtg/index.html \
/Library/WebServer/mrtg/cfg/NAME_OF_SERVER_1.cfg \
View your MRTG results in your browser at URL:

Congrats! You're done!
  • Currently 2.75 / 5
  You rated: 1 / 5 (4 votes cast)

Monitor 10.2.8 clients using MRTG and NET-SNMP | 8 comments | Create New Account
Click here to return to the 'Monitor 10.2.8 clients using MRTG and NET-SNMP' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Monitor 10.2.8 clients using MRTG and NET-SNMP
Authored by: jpbjpbjpbjpb on Oct 28, '03 08:18:47PM

net-snmp is in fink also. It takes just as long to compile, but you end up with packages you can move to other machines.

[ Reply to This | # ]
Monitor 10.2.8 clients using MRTG and NET-SNMP
Authored by: LouieNet on Nov 02, '03 03:09:58AM

also in fink is mrtg

G4 cube, 1152M RAM, OS X Server 10.2.6

[ Reply to This | # ]
Monitor 10.2.8 clients using MRTG and NET-SNMP
Authored by: thornrag on Oct 29, '03 03:30:50AM

Getting network statistics is no problem with the cfgmaker script. But what about Mem usage, Disk usage, and CPU usage?

I'm having a difficult time finding the correct OIDs for Mem, Disk, and CPU. Any pointers on where this is documented? Do these OIDs even work in OS X?

[ Reply to This | # ]
Monitor 10.2.8 clients using MRTG and NET-SNMP
Authored by: alexc on Mar 08, '04 09:52:36PM

Awesome hint. Thank you very much :-)

Its really helped me out.

In the end I used Fink to install SNMP & MRTG.

and I used your guide to help me configure and get SNMP and MRTG going.

Cant thank you enough for writiing this. :-)

All I need to do now is figure out how to make MRTG do the reports I need...

thanks, Alex.

[ Reply to This | # ]
Monitor 10.2.8 clients using MRTG and NET-SNMP
Authored by: rofl on Mar 15, '04 07:13:24AM

I can't find MRTG anymore in fink, at the website it's there but using the FinkCommander or the fink command tool, there is no MRTG!

[ Reply to This | # ]
Monitor 10.2.8 clients using MRTG and NET-SNMP
Authored by: rofl on Mar 15, '04 08:20:14AM

ah just forgot to open myself to *unstable* now it runs fine...

[ Reply to This | # ]
A quick mod for libpng
Authored by: sketchy on Aug 17, '04 02:33:07PM
Having just gone through this process using a slightly different hint, a small change is required to the compilation of Libpng. 1.2.5 is no longer available (due to vulnerabilities) so use 1.2.6 instead.

Under 1.2.6 there is no makefile.macosx so use makefile.darwin instead.

Just my $0.02

[ Reply to This | # ]
Monitor 10.2.8 clients using MRTG and NET-SNMP
Authored by: weez on Dec 07, '04 04:10:00PM

This article is awesome, I could never have done this procedure on my own without this guide. I managed to find all the required parts using darwinports on OSX 10.3, and no problems thus far. Next step is to customize it for displaying icecast stats!

[ Reply to This | # ]