HowTo - Zabbix and SNMP for dd-wrt, kong build

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
PuzzleBrick
DD-WRT Novice


Joined: 14 Oct 2014
Posts: 1

PostPosted: Tue Oct 21, 2014 8:34    Post subject: HowTo - Zabbix and SNMP for dd-wrt, kong build Reply with quote
I wanted to try out Zabbix to see what kind of information I could pull out of my dd-wrt router.
Someone in the forum has stated that it is easy - and it is...... if you know how to do it.
I struggled a bit, but it is quite nice when it is up and running.

Zabbix is an open-source monitoring tool for networks, servers and applications.
Information around Zabbix can be found here:
www.zabbix.org
www.zabbix.com

To try it out you need a Zabbix Server. The server can not run on the router, so it has to be established elsewhere.
I used my Windows 8.1 laptop.


Here are the steps I went through:
1) staging the Zabbix Server
2) enabling SNMP on dd-wrt
3) enabling Zabbix Client on dd-wrt
4) configuring the Zabbix Server
5) show some graphs

Staging the Zabbix server

Zabbix runs on different Linux Distro's.
I used the Zabbix Appliance for VMware/VirtualBox (.vmdk). http://www.zabbix.com/download.php
Note that the Appliance is for evaluation and not intended for production.
I used version 2.2.2 it worked out of the box. I tried version 2.4 but I experienced some issues getting an IP address for the VM and I didn't put any time into debugging the issue. I would assume that it can be fixed easily.

The Appliance can be run in VMware Player. https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0
I installed VMware Player on my Win 8.1 laptop.
After unpacking the appliance it can be loaded.

When the appliance is up and running then logon to the console.
Username: root
Password: zabbix

The console will display the frontend web address. In my case http://192.168.1.111/zabbix
The IP address of the Zabbix Server is needed when configuring the Zabbix Client on the router.
The Zabbix Frontend credentials is:
Username: Admin
Password: zabbix
Note that the username is "Admin" not "admin" as stated some places in the Zabbix documentation.


Enabling SNMP on dd-wrt using the GUI/Web Interface
1) Go to the "Services" tab and the "Services" sub-tab
2) Enable "SNMP", new options should appear
3) Fill in information in the SNMP section. (Location, Contact, Name, RO Community, RW Community) Keep the RO Community = "public" for easy configuration
4) Save Changes

You can test the SNMP access from your PC with Paessler SNMP Tester http://www.paessler.com/tools/snmptester

Enabling Zabbix client on dd-wrt using the GUI/Web Interface
1) Go to the "Services" tab and the "Services" sub-tab
2) Enable "Zabbix Client"", new options should appear
3) Add the Zabbix Server IP address - in my case 192.168.1.111

Note: The Zabbix Client is included from kong's STD build 23075. Look in the changelog for more infp
Check if zabbix is running using the shell/cli:

~# ps| grep zabbix
1465 root 1876 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf
1466 root 1876 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf
1467 root 1884 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf
1468 root 1884 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf
1469 root 1884 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf
1470 root 1884 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf
1471 root 1884 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf

If that is okay, check if /tmp/zabbix.conf contains the correct IPs:

cat /tmp/zabbix.conf
Server=192.168.1.111
Hostname=RangeMaster
ListenIP=192.168.1.1
...

ListenIP = is you routers internal LAN IP
Server = is the IP of your Zabbix Server

Telnet from the Zabbix Server to the router on port 10050. It can be done from the console - in my case telnet from 192.168.1.111:

~> telnet 192.168.1.1 10050
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.

A bad response would be "Connection refused".

Another test would be to run the commend "zabbix_get -s 192.168.1.111 -k "agent.version".
You should get an output like this "2.0.9"


Configuring the Zabbix Server
Some templates are already available by default on the server, but one specific for DD-WRT is missing.
You have to upload this yourself.
It is located on the router under /etc/zabbix_template.xml from build 23310.

Logon the Zabbix server frontend and goto Configuration -> Templates. Import the zabbix_template.xml template. The button is located on the right side of the screen. You should have 38 before and 39 after.
When the template is imported, it is listed as Template_Linux_DDWRT.

Goto Configuration -> Hosts and press the Create host button.
Add the the dd-wrt router IP for Agent and SNMP interfaces, In my case 192.168.1.1
Press the Template tab and add Template_Linux_DDWRT and "Template SNMP Interface". Save the changes.

Get a beer and relax for an hour or so.


Show some graphs
Go to Monitoring -> Latest data. Select your router as host.
You can now select a graph for each of the polled values.

At this point you probably have a lot of questions about polling intervals, selected values, how to build graphs etc., but that has nothing to do with dd-wrt, so don't ask questions in this forum. Jump to zabbix.com and get your answers there.

Have fun!
Sponsor
HalfBit
DD-WRT Guru


Joined: 04 Sep 2009
Posts: 776
Location: AR, USA

PostPosted: Tue Oct 21, 2014 12:55    Post subject: Reply with quote
Awesome instructions, thank you! Now if only I could figure out how to compile zabbix and mySQL on my NAS with a Marvell CPU... Smile
_________________
R7000 Nighthawk - DD-WRT v3.0-r50308
R7000 Nighthawk - DD-WRT v3.0-r50308
~~~~~~~~~~Dismantled for learning opportunities~~~~~~~~~~
WRT54Gv2
WRT54Gv8.2
~~~~~~~~~~Other Settings~~~~~~~~~
https://nextdns.io/?from=2d3sq39x
https://pi-hole.net/
https://github.com/DNSCrypt/dnscrypt-proxy
athurdent
DD-WRT User


Joined: 22 Nov 2008
Posts: 88
Location: .de

PostPosted: Tue Oct 21, 2014 15:41    Post subject: Reply with quote
If you have virtual wireless interfaces and want to monitor the client count you can use something like this in the Zabbix custom config:

Code:
UserParameter=clients.wl0.1, /usr/sbin/wclients wl0.1
UserParameter=clients.wl1.1, /usr/sbin/wclients wl1.1


In Zabbix you can simply clone the
"Wireless clients WL0"
item and name it
"Wireless clients WL0.1"
with a key of
"clients.wl0.1"

and so on...

Also look into creating a custom map and enter something like this as the label of you router's map element:

Code:
{HOST.NAME}
{HOST.CONN}

Softirq: {rt-ac66u:system.cpu.util[,softirq,avg1].last(0)}%
In: {rt-ac66u:net.if.in[eth0].last(0)}
Out: {rt-ac66u:net.if.out[eth0].last(0)}

Normal/Guest 2.4GHz: {rt-ac66u:clients.wl0.last(0)} / {rt-ac66u:clients.wl0.1.last(0)}
Normal/Guest 5.0GHz: {rt-ac66u:clients.wl1.last(0)} / {rt-ac66u:clients.wl1.1.last(0)}



Will look really nice.



Screenshot_1.png
 Description:
 Filesize:  8.84 KB
 Viewed:  38760 Time(s)

Screenshot_1.png


meocene
DD-WRT User


Joined: 15 Jul 2010
Posts: 130

PostPosted: Sun Oct 26, 2014 1:54    Post subject: Reply with quote
This is probably a silly question, but despite a ton of googling I still can't figure out how to download the template from my router.
I've tried copying to permission-less local and nas samba shares using ssh and telnet putty sessions, but the copy fails reporting the destination folder is not writeable...?
athurdent
DD-WRT User


Joined: 22 Nov 2008
Posts: 88
Location: .de

PostPosted: Sun Oct 26, 2014 10:01    Post subject: Reply with quote
Grab it from the DD-WRT sources:
http://svn.dd-wrt.com/browser/src/router/zabbix/config/zbx_template.xml
sandman21
DD-WRT Novice


Joined: 13 Oct 2015
Posts: 4

PostPosted: Fri Oct 16, 2015 20:56    Post subject: Re: HowTo - Zabbix and SNMP for dd-wrt, kong build Reply with quote
PuzzleBrick wrote:
I wanted to try out Zabbix to see what kind of information I could pull out of my dd-wrt router.
Someone in the forum has stated that it is easy - and it is...... if you know how to do it.
I struggled a bit, but it is quite nice when it is up and running.

Zabbix is an open-source monitoring tool for networks, servers and applications.
Information around Zabbix can be found here:
www.zabbix.org
www.zabbix.com

To try it out you need a Zabbix Server. The server can not run on the router, so it has to be established elsewhere.
I used my Windows 8.1 laptop.


Here are the steps I went through:
1) staging the Zabbix Server
2) enabling SNMP on dd-wrt
3) enabling Zabbix Client on dd-wrt
4) configuring the Zabbix Server
5) show some graphs

Staging the Zabbix server

Zabbix runs on different Linux Distro's.
I used the Zabbix Appliance for VMware/VirtualBox (.vmdk). http://www.zabbix.com/download.php
Note that the Appliance is for evaluation and not intended for production.
I used version 2.2.2 it worked out of the box. I tried version 2.4 but I experienced some issues getting an IP address for the VM and I didn't put any time into debugging the issue. I would assume that it can be fixed easily.

The Appliance can be run in VMware Player. https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0
I installed VMware Player on my Win 8.1 laptop.
After unpacking the appliance it can be loaded.

When the appliance is up and running then logon to the console.
Username: root
Password: zabbix

The console will display the frontend web address. In my case http://192.168.1.111/zabbix
The IP address of the Zabbix Server is needed when configuring the Zabbix Client on the router.
The Zabbix Frontend credentials is:
Username: Admin
Password: zabbix
Note that the username is "Admin" not "admin" as stated some places in the Zabbix documentation.


Enabling SNMP on dd-wrt using the GUI/Web Interface
1) Go to the "Services" tab and the "Services" sub-tab
2) Enable "SNMP", new options should appear
3) Fill in information in the SNMP section. (Location, Contact, Name, RO Community, RW Community) Keep the RO Community = "public" for easy configuration
4) Save Changes

You can test the SNMP access from your PC with Paessler SNMP Tester http://www.paessler.com/tools/snmptester

Enabling Zabbix client on dd-wrt using the GUI/Web Interface
1) Go to the "Services" tab and the "Services" sub-tab
2) Enable "Zabbix Client"", new options should appear
3) Add the Zabbix Server IP address - in my case 192.168.1.111

Note: The Zabbix Client is included from kong's STD build 23075. Look in the changelog for more infp
Check if zabbix is running using the shell/cli:

~# ps| grep zabbix
1465 root 1876 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf
1466 root 1876 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf
1467 root 1884 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf
1468 root 1884 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf
1469 root 1884 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf
1470 root 1884 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf
1471 root 1884 S /usr/sbin/zabbix_agentd -c /tmp/zabbix.conf

If that is okay, check if /tmp/zabbix.conf contains the correct IPs:

cat /tmp/zabbix.conf
Server=192.168.1.111
Hostname=RangeMaster
ListenIP=192.168.1.1
...

ListenIP = is you routers internal LAN IP
Server = is the IP of your Zabbix Server

Telnet from the Zabbix Server to the router on port 10050. It can be done from the console - in my case telnet from 192.168.1.111:

~> telnet 192.168.1.1 10050
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.

A bad response would be "Connection refused".

Another test would be to run the commend "zabbix_get -s 192.168.1.111 -k "agent.version".
You should get an output like this "2.0.9"


Configuring the Zabbix Server
Some templates are already available by default on the server, but one specific for DD-WRT is missing.
You have to upload this yourself.
It is located on the router under /etc/zabbix_template.xml from build 23310.

Logon the Zabbix server frontend and goto Configuration -> Templates. Import the zabbix_template.xml template. The button is located on the right side of the screen. You should have 38 before and 39 after.
When the template is imported, it is listed as Template_Linux_DDWRT.

Goto Configuration -> Hosts and press the Create host button.
Add the the dd-wrt router IP for Agent and SNMP interfaces, In my case 192.168.1.1
Press the Template tab and add Template_Linux_DDWRT and "Template SNMP Interface". Save the changes.

Get a beer and relax for an hour or so.


Show some graphs
Go to Monitoring -> Latest data. Select your router as host.
You can now select a graph for each of the polled values.

At this point you probably have a lot of questions about polling intervals, selected values, how to build graphs etc., but that has nothing to do with dd-wrt, so don't ask questions in this forum. Jump to zabbix.com and get your answers there.

Have fun!


I am running Kong build r27858 on a TEW-818DRU, and trying to set this up to be monitored by Zabbix. Maybe I am just stupid, but I cannot find anywhere on the Services Tab > Services Sub-Tab > Enable Zabbix Client. I have activated and tested SNMP, rebooted, checked every screen, etc. and there is no option anywhere in the GUI to "enable Zabbix Client" I must be missing something simple, but after hours of research I cannot find it.

I was able to build a custom Ubuntu 14.04 box, install Zabbix Server, and monitor a router via generic SNMP before trying to do this Zabbix-Specific monitoring. I am now trying to use the built-in zabbix client, which requires *FINDING* it first.

Thanks
putzomatic
DD-WRT Novice


Joined: 26 Sep 2015
Posts: 4

PostPosted: Fri Oct 16, 2015 23:12    Post subject: Reply with quote
I already had a Zabbix server up and running and was surprised Zabbix was built into dd-wrt now(maybe its been there for a while?). I had an old linksys router i was using previously and never recalled seeing it before.

Its nice once you have it setup. I just used the template that is on the router. I had to change some of the interface references because they didnt match up. I setup a graph that monitors my downstream and upstream bandwidth. I setup some triggers to alert me when there is sustained download bandwidth usage averaging above a certain speed for X minutes.

I found a site that showed how to setup graphs to monitor the number of connections the firewall has open. It looked pretty slick. But it doesnt appear that the function they were using to check data in the file was an available option in zabbix by default. Any info to achieve this would be awesome.
sandman21
DD-WRT Novice


Joined: 13 Oct 2015
Posts: 4

PostPosted: Sat Oct 17, 2015 13:59    Post subject: Reply with quote
putzomatic wrote:
I already had a Zabbix server up and running and was surprised Zabbix was built into dd-wrt now(maybe its been there for a while?).


That's the issue. It doesn't seem to be "Built-In" to my version. I need it to be in there, as we are working on a Zabbix project and SNMP is OK but I want the full functionality of Zabbix if possible.
putzomatic
DD-WRT Novice


Joined: 26 Sep 2015
Posts: 4

PostPosted: Sat Oct 17, 2015 20:41    Post subject: Reply with quote
sandman21 wrote:

That's the issue. It doesn't seem to be "Built-In" to my version. I need it to be in there, as we are working on a Zabbix project and SNMP is OK but I want the full functionality of Zabbix if possible.


I could be wrong but it might depend on the version you are using. On my router I am using v3... standard and its there on under Services tab at the very bottom. I have an older WRT54GS and its running v3 mini and its not there.
sandman21
DD-WRT Novice


Joined: 13 Oct 2015
Posts: 4

PostPosted: Sat Oct 17, 2015 21:41    Post subject: Zabbix Missing Reply with quote
I am running Kong build r27858 on a TEW-818DRU. I tried the version from TrendNET's Site (V.24 Pre-SP2 23800), I tried K3-ARM-STD from 10/16/2015, and I tried Kong r27858. Not there on any of them. We also tried to find it on a Linksys E1550 running DD-WRT, and also on an E2500 and none of these devices with any build of DD-WRT have a Zabbix option. I'd be glad to upload a screenshot to show this. Does anyone know what the deal is with the missing Zabbix?
putzomatic
DD-WRT Novice


Joined: 26 Sep 2015
Posts: 4

PostPosted: Sat Oct 17, 2015 22:10    Post subject: Re: Zabbix Missing Reply with quote
sandman21 wrote:
I am running Kong build r27858 on a TEW-818DRU. I tried the version from TrendNET's Site (V.24 Pre-SP2 23800), I tried K3-ARM-STD from 10/16/2015, and I tried Kong r27858. Not there on any of them. We also tried to find it on a Linksys E1550 running DD-WRT, and also on an E2500 and none of these devices with any build of DD-WRT have a Zabbix option. I'd be glad to upload a screenshot to show this. Does anyone know what the deal is with the missing Zabbix?


Have you tried a recent non-Kong build? Im using the build from 9/11/2015. I think this one is for your router:

http://download1.dd-wrt.com/dd-wrtv2/downloads/betas/2015/09-11-2015-r27805/trendnet-818DRU/trendnet-818dru-webflash.bin
sandman21
DD-WRT Novice


Joined: 13 Oct 2015
Posts: 4

PostPosted: Wed Aug 31, 2016 20:58    Post subject: Trying another router for Zabbix Reply with quote
Well we gave up on the TEW-818DRU and are now thinking of trying this on DD-WRT NXT. Does anyone know if Zabbix Client will run on DD=WRT NXT? The routers in question are Buffalo Airstation Models WXR-1900DHPD and WSR-1166DD.
HalfBit
DD-WRT Guru


Joined: 04 Sep 2009
Posts: 776
Location: AR, USA

PostPosted: Tue Oct 27, 2020 20:13    Post subject: Reply with quote
For those that find this thread/topic, this one about updated Zabbix templates might be of interest as well in case Google wasn't helpful to find it:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324733&sid=744ceb6d193099a1536e49c73793c302

_________________
R7000 Nighthawk - DD-WRT v3.0-r50308
R7000 Nighthawk - DD-WRT v3.0-r50308
~~~~~~~~~~Dismantled for learning opportunities~~~~~~~~~~
WRT54Gv2
WRT54Gv8.2
~~~~~~~~~~Other Settings~~~~~~~~~
https://nextdns.io/?from=2d3sq39x
https://pi-hole.net/
https://github.com/DNSCrypt/dnscrypt-proxy
mlazzarotto
DD-WRT Novice


Joined: 04 Mar 2022
Posts: 2

PostPosted: Sun Apr 23, 2023 13:41    Post subject: Reply with quote
Guys, how do I change
Code:
ListenIP
parameter? Setting that in the
Code:
User Parameters
doesn't override the default.

*EDIT*: nevermind, I'm dumb. `service zabbix restart` did the trick. I though it was automatic when applying the config
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum