AVM Fritz!Box: WAN Network Interface not detected

Hello community,

I am using the agent_fritzbox to get some statistics from my AVM FRITZ!Box 7590. I already added the Fritzbox as a host and added a rule at Setup → Agents → Other Integrations → Fritz!Box Devices in order to enable the fritzbox agent. So far, everything is up and running:

However, I’m only getting the “Configuration” and “Connection” services while I’m mostly interested in the “fritz_wan_if” plugin to get some stats about the WAN interface.

Am I missing something to enable this check?
Thanks and kind regards
Johannes

This is a known “Bug” inside the discovery function and the translation of the data to a generic interface check.
If your box is connected to the WAN/LAN ports and not the DSL then this is normal.

I will attach the diff for the file ~/lib/check_mk/base/plugins/agent_based/fritz.py to detect also these interfaces.

--- /omd/sites/home/lib/check_mk/base/plugins/agent_based/fritz.py      2021-10-05 13:03:21.000000000 +0200
+++ /omd/sites/home/local/lib/check_mk/base/plugins/agent_based/fritz.py        2021-08-27 08:28:59.531453277 +0200
@@ -86,4 +86,7 @@
     link_stat = section.get('NewLinkStatus')
     if not link_stat:
+        link_stat = section.get('NewPhysicalLinkStatus')
+
+    if not link_stat:
         oper_status = '4'
     elif link_stat == 'Up':
1 Like

Hey @andreas-doehler
thanks a lot for this information. (I’ll suppose that this bug will be fixed with a new release of checkmk?)

I have edited my /omd/sites/testrechner/lib/check_mk/base/plugins/agent_based/fritz.py file but now the Check_MK Discovery crashes:

I already reverted my changes in the fritz.py, but the crash remains:

Any ideas? The connection tests are ok:

Thanks and kind regards
Johannes

Don’t edit this file - my diff was showing the right location →

I think you made some mistakes with editing this file as the parsed output is a list and should be a dictionary.
You need to replace the “fritz.py” file with a unmodified version from before.

Ok, thanks for the hints again. I just replaced the /omd/sites/testrechner/lib/check_mk/base/plugins/agent_based/fritz.py with a new one. (I did a “compare” in Notepad++ with NO DIFFERENCES. A sha512sum was different, though. For whatever reason.) My “Configuration” and “Connection” is now working again.

But: How can I do the changes you supposed with your diff? At /omd/sites/testrechner/local/lib/check_mk/base/plugins/agent_based/ are no files. I just copied the fritz.py into this folder and edited it. However, the only thing remaining is a “pycache” folder with a file “fritz.cpython-38.pyc”.

I feel like a total newbie :wink: Sorry for that…
Thanks
Johannes

Copy the fritz.py to the local location and then make the change.
Very important is the right indentation.
Your output from the error shows that your Fritzbox only has the “NewPhysicalLinkStatus” and not the old “NewLinkStatus”. My modification should work if applied correctly.

1 Like

Yeah, I finally got it running. For the sake of completeness, here is my procedure:

sudo cp /omd/sites/testrechner/lib/check_mk/base/plugins/agent_based/fritz.py ~/
sudo chown testrechner:testrechner fritz.py
sudo chmod +x fritz.py
sudo nano fritz.py
→ EXACT changes from your diff
sudo mv fritz.py /omd/sites/testrechner/local/lib/check_mk/base/plugins/agent_based/

Here we go:

Thanks a lot for your help! And sorry again for the inconvenience.

Hm, for some reason I encounter another problem. While the the “Interface 0” counters are still correct and refreshed every minute, I am seeing this errors since about 3 hours:

Any ideas again?

As the state is shown as “unknown” it should also show something else inside the agent output.
But it looks strange.

Hey Andreas. Thanks for your reply!

I just did the “copy, add-the-lines, move” trick again and now it’s working without errors again. Let’s see whether the same error appears tomorrow again.

The only thing I noticed was that the “fritz.py” file within the /omd/sites/nuc01/local/lib/check_mk/base/plugins/agent_based was gone in the meantime. Shouldn’t it remain in this folder?
Furthermore, note that I am using distributed monitoring, while this Fritzbox check is done at the remote site. Could this be correlated to the problems? Should I change the original fritz.py at the main checkmk site as well?

Yes - you need to copy and modify the file on the central site.
The central site pushes the complete content to the remote sites and removes every change there.

1 Like

Haha, there we go. :wink: DANKE!

Hello,

after a new Fritzbox (7590), my WAN interface is no longer displayed.
Since I use Check_MK version 2.1.0, the change listed above is no longer valid.

Could someone please post the line for version 2.1.0, or please add the change directly to the release.

Thanks

E

You can copy the fritz.py to the location mentioned above and change the following.

2.1.0 version - line 38 and following

def _section_to_interface(section: Section) -> interfaces.Section:
    if not _WAN_IF_KEYS & set(section):
        return []
    return [
        interfaces.Interface(
            index="0",
            descr="WAN",
            alias="WAN",
            type="6",
            speed=int(section.get("NewLayer1DownstreamMaxBitRate", 0)),
            oper_status=_LINK_STATUS_MAP.get(
                section.get("NewLinkStatus"),
                "2",
            ),
            in_octets=int(section.get("NewTotalBytesReceived", 0)),
            out_octets=int(section.get("NewTotalBytesSent", 0)),
        )
    ]

to the following

def _section_to_interface(section: Section) -> interfaces.Section:
    if not _WAN_IF_KEYS & set(section):
        return []
    link_status = section.get("NewLinkStatus")
    if not link_status:
        link_status = section.get('NewPhysicalLinkStatus')
    return [
        interfaces.Interface(
            index="0",
            descr="WAN",
            alias="WAN",
            type="6",
            speed=int(section.get("NewLayer1DownstreamMaxBitRate", 0)),
            oper_status=_LINK_STATUS_MAP.get(
                link_status,
                "2",
            ),
            in_octets=int(section.get("NewTotalBytesReceived", 0)),
            out_octets=int(section.get("NewTotalBytesSent", 0)),
        )
    ]

If your Fritzbox has no DSL connection (fiber or something else) you have only the “NewPhysicalLinkStatus”.

1 Like

I made a pull request on Github for this change and also proposed to use the new 64bit interface counter instead of the old 32bit ones.

2 Likes

Great. Thanks for that!!!

THANKS a lot for the quick answer - I changed the fritz.py and the connection status is working again.

Perfekt - Danke. :grinning:

Would be great, if this fix will go into the official release to.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.