In order to get a report of traffic on a router interface you will need to know the name of the interface. This differs with routers so you may have to use snmpwalk to list the interfaces. That is what you see in the example below.
Here you can see that the interface is “Ethernet0”.
Once you have that information you will be able to use check_iftraffic.pl which is a plugin that you can get from nagiosexchange.org. Download the plugin and place it in the /usr/lib/nagios/plugins directory. Make sure that it is an executable file with:
chmod 755 check_iftraffic.pl
Now that you have that ready you can test from the Nagios server using the information about the interface that you have gained. If you get an error message that looks like this:
*ePN /usr/lib/nagios/plugins/check_iftraffic.pl: "Use of uninitialized value in scalar chomp at (eval 1) line 186, <FILE> line 1.
If you get the error listed above try changing the text on line 186 from chomp () to
chomp($row)
That worked for me.
When you run the command you should get a return.
./check_iftraffic.pl -H 192.168.5.79 -C public -i enet0 -b 10 -u m Total RX Bytes: 2.94 MB, Total TX Bytes: 2.01 MB<br>Average Traffic: 0.00 kB/s (0.0%) in, 0.00 kB/s (0.0%) out| inUsage=0.0,85,98 outUsage=0.0,85,98 inAbsolut=3012 outAbsolut=2059
The command is set to test a network interface that has the maximum capability of 10 Megabits.
-b 10 -u m
If your interface had the capability of 100 Megabits you would change the command to:
-b 100 -u m
The next step is to set up the command. Edit the commands.cfg and put this information in that file.
Now edit the routers.cfg to add the service. You may also place this in the service.cfg if you have your routers in that location. Note that your interface name may be different on your router.
There may be on problem that could develop since the plugin saves the timestamp and counter status to the /tmp directory so if you tried to test using a user other than nagios that file in the /tmp directory will be owned by the wrong user. Here is an example:
-rw-r--r-- 1 root root 21 Mar 29 09:50 traffic_if1_192.168.5.79
Here the root user was used to test so that must be removed before you activate the plugin.