What follows are several sample snippets of RRDTool "sensors" that I build as part of my home monitoring system. Each snippet includes the DS and RRA definitions to create an archive and a value capture for the variables involved.
Monitoring CPU Usage in Mac OS X with iostat
RRD=cpu.rrd CREATE="--step 150 DS:user:GAUGE:300:0:U DS:system:GAUGE:300:0:U DS:idle:GAUGE:300:0:U RRA:MAX:0.5:1:105120" VALUE="N:"`/usr/sbin/iostat -I -w 2 -c 2 disk0 | tail -1 | rev | awk '{ print substr($0,0,3),substr($0,3,3),substr($0,6,3)}' | rev | xargs | sed 's/ /:/g'`
iostat has thee annoying "features": you only get meaningful numbers if you let it run for a sampling interval or two, columns move about a bit, and it often gloms together CPU values.
Monitoring Disk Usage in Mac OS X with iostat
RRD=iostat1.rrd CREATE="--step 150 DS:kbpt:GAUGE:300:0:U DS:xfrs:COUNTER:300:0:U DS:mb:COUNTER:300:0:U RRA:MAX:0.5:1:105120" VALUE="N:"`/usr/sbin/iostat -I disk1 | tail -1 | awk '{ print $1,$2,int($3) }' | sed 's/ /:/g'`
This is a variation on the above for an external disk. Since iostat presents its values in columns (one disk alongside the other), in case of failure of one disk it is impossible to read stats for others (hence it's best to monitor all of them separately).
Monitoring RAM Usage in Mac OS X with vm_stat
RRD=vm_stat.rrd CREATE="--step 150 DS:free:GAUGE:300:0:U DS:active:GAUGE:300:0:U DS:inactive:GAUGE:300:0:U DS:wired:GAUGE:300:0:U RRA:MAX:0.5:1:105120" VALUE="N:"`vm_stat | cut -c 22-36 | head -5 | tail -4 | awk '{print $1*4}' | xargs | sed 's/ /:/g'`
vm_stat outputs counts of 4Kbyte pages, hence the "times four" above.
Monitoring overall traffic in Mac OS X with netstat
RRD=en0.rrd CREATE="--step 150 DS:rx:COUNTER:300:0:U DS:tx:COUNTER:300:0:U RRA:MAX:0.5:1:105120" VALUE="N:"`/usr/sbin/netstat -b -i | grep en0 | tail -1 | xargs | cut -d\ -f 7,10 | sed 's/ /:/g'`
In true BSD-like form, Mac OS X reports interface counters via netstat. Which, incidentally, also makes a point of listing every known address for each interface (hence the tail).