You want to use MRTG to keep an eye on CPU performance. cfgmaker only sets up graphs for your network interfaces. Now what?
You'll need to edit mrtg.cfg
by hand.
Don't use cfgmaker
anymore because it will
overwrite your changes. This recipe monitors system, user, and nice
values, and adds them up to give a snapshot of CPU load.
Add this line to the Global Config Options section:
# Global Config Options LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txt
Then, add this section at the bottom of the file:
# monitor CPU load # Target[xena.cpu]: ssCpuRawUser.0&ssCpuRawUser.0:password@localhost + ssCpuRawSystem. 0&ssCpuRawSystem.0:password@localhost + ssCpuRawNice.0&ssCpuRawNice.0: password@localhost Title[xena.cpu]: Xena CPU Load RouterUptime[xena.cpu]: password@127.0.0.1 PageTop[xena.cpu]: <H1>CPU System, User and Nice stats for Xena</H1> MaxBytes[xena.cpu]: 100 ShortLegend[xena.cpu]: % YLegend[xena.cpu]: CPU Usage Legend1[xena.cpu]: Current CPU percentage load LegendI[xena.cpu]: Used LegendO[xena.cpu]: Options[xena.cpu]: growright,nopercent Unscaled[xena.cpu]: ymwd
While you're there, you might as well delete the entry for the loopback device, as you're not going to use it anyway. Now, run mrtg manually three times, or until it stops complaining, and mind your filepaths:
# env LANG=C mrtg /etc/mrtg.cfg
Then, generate a new index.html page:
# indexmaker --output=/var/www/mrtg/index.html /etc/mrtg.cfg
Now, you should see something like Figure 14-4 and Figure 14-5.
These aren't very exciting graphs because they're on a test system with little activity. But, they do show what the entries in mrtg.cfg make the graphs look like. Let's take a tour of the configuration:
LoadMIBs
You have to tell MRTG which MIB files from /usr/share/snmp/ to load. You'll see them cached in /var/www/mrtg/oid-mib-cache.txt. Using the LoadMIBs option means you'll be able to use the symbolic names of the OIDs, rather than having to use their numbers.
Target[xena.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:password@localhost…
The syntax for this line is
Keyword[graphname]: value
. The
Target
keyword defines what
you want monitored. The value
is a
list of OID pairs joined by the ampersand, &
. The graph
name
is anything you want, and it must be unique.
MRTG only knows how to measure pairs of values, so when you're
plotting a single value, just repeat the target definition.
Whitespace must surround each target definition. This example
contains three target definitions, connected with the plus sign.
The plus sign means "add these together."
Title
This is the title of the detailed HTML page.
RouterUptime
PageTop
The headline of the detail page.
MaxBytes
This is either a value in bytes, or it behaves as a percentage.
ShortLegend
The units string used for Max, Average, and Current. The default is b/s, bits per second.
YLegend
The Y-axis, or vertical axis, which is for the label of the graph. If you make it too long, it will be silently ignored.
Legend1
(and
2, 3,
and
4)
Strings for the color legends.
LegendI (and
O)
Input and output. Because the different values in this
graph are added up to a single sum, and each OID pair is the
same OID rather than two OIDs, we're only using LegendI
.
Options
growright
means expand
the graph to the right, and nopercent means don't print
percentage values. For our CPU graphs printing percentages would be redundant
because we already have percentage displays. Without the
nopercent option the graph legends it would display like this:
Used 65.0 % (65.0%) 35.0 % (35.0%) 6.0 %
(6.0%)
.
Unscaled
The default is scaled
,
which means MRTG will adjust the graph to make small data more
visible. The unscaled option creates a fixed-size graph.
ymwd
represents year, month,
week, day.
man 1 mrtg-reference
is your
primary configuration reference.
man 1
mrtg-reference
MRTG home page: http://oss.oetiker.ch/mrtg/