Ad Widget

Collapse

Zabbix agent error for network interface discovery on OpenWRT

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • theLostBandana
    Junior Member
    • Jun 2024
    • 6

    #1

    Zabbix agent error for network interface discovery on OpenWRT

    I have a GL-Inet Cirrus AP running version 4.3.13 of their OpenWRT software and a Zabbix server hosted somewhere else. I can add the Cirrus router to the zabbix server as a active client, using the templates supplied by OpenWRT.

    When I add the Cirrus to the Zabbix server I get 13 graphs . It seems to be OS and WiFi stuff but no network interface info.

    I looked and the zabbix packages are installed on the system (zabbix-agentd, zabbix-extra-mac80211, zabbix-network, zabbix-wifi).
    The package version for the Zabbix agent is version 5.0.7-2.

    In the discovery section, next to "Network Interface Discovery" it has an error (or part of one):
    Code:
    Invalid discovery rule value: cannot parse as a valid JSON object: invalid object format, expected opening character '{' or '[' at: 'lua: (command line):1: attempt to concatenate field 'device' (a nil value) stack traceback: (command line):1: in main chunk [C]: ?...'
    I have tried deleting the host object on the Zabbix server for the cirrus and recreating it. I have tried to re-run discovery.

    Anything else folks can think that I can try?

    I'm looking for network interface traffic graphs and then I want to alert on interface state.

    I have a different GL-Inet/OpenWRT device that has a different openwrt and agent version 5.0.18-1 and I get the network inteface information for that system.

    There isn't an agent upgrade in the repo for the Cirrus and I've never tried cross compiling before.

    Looks like the non working device is running OpenWrt 21.02.2, r16495-bf0c965af0 armv7l

    Thanks in advance for any troubleshooting pointers or advice.
  • Answer selected by theLostBandana at 15-06-2024, 01:46.
    theLostBandana
    Junior Member
    • Jun 2024
    • 6

    Hmm after some searching I found some updated lua command
    Replacing the UserParameter line in /etc/zabbix_agentd.conf.d/network
    with the string from this page
    Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md - openwrt/packages


    Code:
    UserParameter=netowrt.discovery,lua -l ubus -e 'u=ubus.connect();list="{\"data\":[";dump=u:call("network.interface", "dump", {});for _, intf in ipairs(dump.interface) do list=list.."{\"{#IF}\":\""..(intf.device or intf.l3_device).."\", \"{#NET}\":\""..intf.interface.."\"},";end;list=string.gsub(list,",$","");print(list.."]}")'
    I restarted the Zabbix agent on the router. Then I deleted and re-added the router Zabbix. I had to enable and re-enable Network Interface discovery as well after that, but now I have traffic graphs.

    Comment

    • theLostBandana
      Junior Member
      • Jun 2024
      • 6

      #2
      Hmm after some searching I found some updated lua command
      Replacing the UserParameter line in /etc/zabbix_agentd.conf.d/network
      with the string from this page
      Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md - openwrt/packages


      Code:
      UserParameter=netowrt.discovery,lua -l ubus -e 'u=ubus.connect();list="{\"data\":[";dump=u:call("network.interface", "dump", {});for _, intf in ipairs(dump.interface) do list=list.."{\"{#IF}\":\""..(intf.device or intf.l3_device).."\", \"{#NET}\":\""..intf.interface.."\"},";end;list=string.gsub(list,",$","");print(list.."]}")'
      I restarted the Zabbix agent on the router. Then I deleted and re-added the router Zabbix. I had to enable and re-enable Network Interface discovery as well after that, but now I have traffic graphs.

      Comment

      • troffasky
        Senior Member
        • Jul 2008
        • 565

        #3
        What other packages do you have installed on the router? I am running 23.05 and I cannot get this netowrt.discovery lua command to run as either root or zabbix - I get a similar error that you did:

        Code:
        $ zabbix_get -k netowrt.discovery -s router
        lua: (command line):1: attempt to concatenate a nil value
        stack traceback:
                (command line):1: in main chunk
                [C]: ?

        Comment

        • theLostBandana
          Junior Member
          • Jun 2024
          • 6

          #4
          Did you update the line in the file?

          Comment

          • theLostBandana
            Junior Member
            • Jun 2024
            • 6

            #5
            Looks like I had to install coreutils-who for something
            I did find on a new system after changing everything it wouldn't do the discovery - I deleted the host entry on the server side and re-added it and ~it worked~
            Edit: it just took a while to fail again.

            Comment

            • theLostBandana
              Junior Member
              • Jun 2024
              • 6

              #6
              ChatGPT appears to have successfully fixed the lua script for me
              ` lua -l ubus -e 'u=ubus.connect();list="{"data":[";dump=u:call("network.interface","dump",{});f or _,intf in ipairs(dump.interface) do local ifname=(intf.device or intf.l3_device or "");list=list.."{"{#IF}":"" .. ifname .. "","{#NET}":"" .. (intf.interface or "") .. ""},";end;list=string.gsub(list,",$","");print(lis t.."]}")' `

              Comment

              Working...