MRTG on a Nokia M1122

Update: Apparently the M1122 does support (slightly broken?) SNMP, at least in some revisions. It could pay to investigate this before following the instructions below.

The Nokia M1122 does not currently support SNMP, so getting it working with MRTG is a little more difficult. Here's how I did it:

I use Debian GNU/Linux, so I first installed the MRTG and expect packages. Expect is used to telnet on to the router and gather the data needed for MRTG.

Next I coded up a simple expect script, this is the first time I have used expect, so I just copied from an example.


#!/usr/bin/expect5.31 --

exp_version -exit 5.0

set timeout 60
spawn telnet 192.168.1.254
expect "login-id:"
send "user\r"
expect "password:"
send "user\r"
expect "M1122>"
send "sh atm\r"
expect "M1122>"
send "sh st\r"
expect "M1122>"
send "lo\r"
close

I saved this as /usr/local/bin/getm1122-raw, because another script does some more massaging before sending it to MRTG. Note that you may need to change the first line depending on your version and location of expect.

When this run it should produce the following output:

spawn telnet 192.168.1.254
Trying 192.168.1.254...
Connected to 192.168.1.254.
Escape character is '^]'.


Nokia Inc. (C) 1999-2000
Nokia Mrouter

rel-Gx1x2210.R09 built on Oct  9 2000 @ 13:49:41 by krol

login-id: user
password: ****
M1122>sh atm
## vcc1 (up)             vpi    vci       type      encap
                           0    100   DATA_PVC     PPP-VC
                                pkt        oct        dis        err
stat-tx-payload              860139  224061349          0          0
stat-rx-payload              979243  892956118          0          0

## mngt (up)             vpi    vci       type      encap
                           0    101   MNGT_PVC     IP-LLC
                                pkt        oct        dis        err
stat-tx-payload                   0          0          0          0
stat-rx-payload                   0          0          0          0
M1122>sh st
product-id               T66280.01  C
serial-num               61004613761
cpu-type                 XPC850SR / B
flash-type               2 M
sdram-type               8 M
phys-address-lan         00:40:43:03:cc:9c
phys-address-wan         00:40:43:03:cc:9d
short-desc               M1122
long-desc                NOKIA M1122 ADSL Router
boot-version             Bx1x2008.R01
appl-version             Gx1x2210.R09
log-severity             HIGH
start-uptime             03/15:40:28
M1122>

Next I wrote a bit of awk to massage the output into the format required by MRTG:


#!/bin/sh
/usr/local/bin/getm1122-raw |
awk '/payload/{print $3}/uptime/{print $2}/short-desc/{print $2}'|
awk -vRS="\n\n" '{printf("%s\n%s\n%s\n%s\n",$2,$1,$6,$5)}'

I saved this as /usr/local/bin/getm1122, and the output looks like:

567705125
32870330
03/15:46:18
M1122

Now I filled in a section in the mtrg.cfg file as follows:


Title[m1122]: JetStream DSL
PageTop[m1122]: <h1>Jetstream DSL via Nokia M1122</h1>

Target[m1122]: `/usr/local/bin/getm1122`
MaxBytes[m1122]: 1000000

Now everything was going - the debian package has a cron fragment that runs MRTG every 5 minutes, and puts the results in /var/www/mtrg/

I'd welcome feedback, corrections etc. to alex at king dot net dot nz