Ad Widget

Collapse

Ubiquiti UniFi + zabbix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • miragecze
    Junior Member
    • May 2015
    • 6

    #16
    My environment:

    Zabbix_proxy 2.4 - Debian 7(site where is unifi)
    Zabbix_Server 2.4 Debian 7
    Unifi_Controller - Windows 7

    I am stuck, so what i have done:

    1) Copy actual (from your link) unifi_miner.pl to /usr/local/bin/zabbix
    2) Modify, location, username and password in unifi_miner.pl
    3) chmod 777 unifi_miner.pl
    4) copy content of unifi.conf to zabbix agentd.conf
    5) Attach template to host Zabbix_Proxy (where is unifi_miner.pl etc. but it is not Unifi_Controller)
    6) Restart Zabbix Agent and Zabbix proxy

    Zabbix Agent is working, latest data from Zabbix Agent is ok, but I not see Unifi. What I am doing wrong? Have I missed something?

    Comment

    • sadman
      Senior Member
      • Dec 2010
      • 1611

      #17
      An interesting configuration.

      So...

      1
      On Zabbix_proxy&Zabbix_agent host run
      ./unifi_miner.pl -o wlan (or just ./unifi_miner.pl)
      U must get output with JSON, which contain names/id's of all yours wlans.
      On error check settings of host/username/pass for unifi controller

      2
      On Zabbix_proxy&Zabbix_agent host
      zabbix_agentd -t unifi.discovery[wlan]
      U must get the same output, that u saw on step 1.
      If the attempt is unsuccessful - u need seek for error with zabbix_agentd pointing to script or wrong filesystem rights. There u may need to set debuglevel=4 on agent side, run key request and check the log file.

      3
      On Zabbix_server host
      zabbix_get -s <agentd_host> -k unifi.discovery[wlan]
      WLANS list again.

      4
      On Zabbix_server host
      zabbix_get -s <agentd_host> -k unifi.site.state[uap,items_num]
      Output is <number of UAPs on the 'default' site>.

      5
      Via Zabbix web-interface check state of item with unifi.site.state[uap,items_num key in Application "UniFi site" on host named as Zabbix_proxy.
      If its green "Enabled" - all worked OK. If this gray "Not supported" - point to [X] (on the right from state) and read error description.

      Comment

      • miragecze
        Junior Member
        • May 2015
        • 6

        #18
        Originally posted by sadman
        An interesting configuration.

        So...

        1
        On Zabbix_proxy&Zabbix_agent host run
        ./unifi_miner.pl -o wlan (or just ./unifi_miner.pl)
        U must get output with JSON, which contain names/id's of all yours wlans.
        On error check settings of host/username/pass for unifi controller

        2
        On Zabbix_proxy&Zabbix_agent host
        zabbix_agentd -t unifi.discovery[wlan]
        U must get the same output, that u saw on step 1.
        If the attempt is unsuccessful - u need seek for error with zabbix_agentd pointing to script or wrong filesystem rights. There u may need to set debuglevel=4 on agent side, run key request and check the log file.

        3
        On Zabbix_server host
        zabbix_get -s <agentd_host> -k unifi.discovery[wlan]
        WLANS list again.

        4
        On Zabbix_server host
        zabbix_get -s <agentd_host> -k unifi.site.state[uap,items_num]
        Output is <number of UAPs on the 'default' site>.

        5
        Via Zabbix web-interface check state of item with unifi.site.state[uap,items_num key in Application "UniFi site" on host named as Zabbix_proxy.
        If its green "Enabled" - all worked OK. If this gray "Not supported" - point to [X] (on the right from state) and read error description.
        Strange...

        1) Works
        2) Works
        3) (from proxy)
        zabbix_get -s 127.0.0.1 -k unifi.discovery[wlan]
        Login error:200 at /usr/local/bin/zabbix/unifi_miner.pl line 417.
        4) same result as 3)

        So why "zabbix_agentd -t unifi.discovery[wlan]" working and "zabbix_get -s 127.0.0.1 -k unifi.discovery[wlan]" not?

        Comment

        • sadman
          Senior Member
          • Dec 2010
          • 1611

          #19
          Hmm... is a sorcery.

          U can delete "-u $2 -p $3" in UserParameter=unifi.discovery[*] key.
          Then the miner script will definitely be used login/password which set inside him (they do not be overwritten by empty values. ...but why -t unifi.discovery[wlan] worked?).

          Restart agent and try do step 3) or zabbix_get -s 127.0.0.1 -k unifi.discovery[wlan].

          Comment

          • miragecze
            Junior Member
            • May 2015
            • 6

            #20
            WLAN is working! Thank you! Delete paramaters helped ... but...

            zabbix_get -s 127.0.0.1 -k unifi.discovery[uap] is not working correctly.

            2/3 AP is missing and there is this error:
            Use of uninitialized value in string eq at /usr/local/bin/zabbix/unifi_miner.pl line 336.
            Some APs is showing correctly.

            Thak you, that you are so helpful

            Comment

            • sadman
              Senior Member
              • Dec 2010
              • 1611

              #21
              OK, i have an guess.

              May be u don't have {$USERNAME}, {$PASSWORD} macro for your <zabbix_proxy&zabbix_agent> host or their values is wrong?

              In that case zabbix server send to agent empty/wrong auth data, zabbix agent substitutes it to script command line:
              unifi.discovery[wlan, {$USERNAME}, {$PASSWORD}] => unifi.discovery[*] => unifi.discovery[$1, $2, $3] => unifi.discovery[wlan, <wrong|empty>, <wrong|empty>] => .../unifi_miner.pl -o $1 -u $2 -p $3 => .../unifi_miner.pl -o wlan -u <wrong|empty> -p <wrong|empty> => login error.

              And then zabbix_agentd puzzle is solved:
              1. u run unifi_miner.pl -o wlan. Script detect that cache is expired, renew it.
              2. until cache is not expired u run zabbix_agentd, which execute .../unifi_miner.pl -o wlan -u <empty> -p <empty>. But no login process was called because cache data is good. Miner load data from cache file and send back correct answer to agent.
              3. when u run zabbix_get -s 127.0.0.1 ... cache had expired and script try to fetch new data from controller using login/pass. But agent call miner with empty values and login procedure was failed.

              So. If u call zabbix_get -s 127.0.0.1 -k unifi.discovery[wlan,user,pass] with original UserParameter, agent fill $2, $3 with correct data and got success.


              Now about UAPs: ./unifi_miner.pl -o uap show correct data? I suppose that script may have problem with some UAPs aliases (which contain noneglish letters, spaces)
              Last edited by sadman; 19-05-2015, 13:50.

              Comment

              • miragecze
                Junior Member
                • May 2015
                • 6

                #22
                Macros are there and has 100 percent correct vaules. Nevermind...


                AP example:
                "{#ALIAS}" : "AP-1 přeloženo z E" (non english character) and is there

                AP NAMED AB-1A(only english character) is missing

                strange...

                Comment

                • sadman
                  Senior Member
                  • Dec 2010
                  • 1611

                  #23
                  Originally posted by miragecze
                  AP example:
                  "{#ALIAS}" : "AP-1 přeloženo z E" (non english character) and is there
                  AP NAMED AB-1A(only english character) is missing
                  strange...
                  If u send to me output of https://<controller>/api/s/default/stat/device i will try to debug. No sensitive information like logins/passes contain into controller answer. Write to me PM, plz.

                  Comment

                  • corsino
                    Junior Member
                    • Mar 2013
                    • 22

                    #24
                    Originally posted by sadman
                    If u send to me output of https://<controller>/api/s/default/stat/device i will try to debug. No sensitive information like logins/passes contain into controller answer. Write to me PM, plz.
                    Is there any way to monitor all sites that we have on controller? My zabbix server is not on the same network as my controller. So I have "UAP UAPNAME is unavailable by ICMP" and "Firmware on UAP UAPNAME is not {$FW_UAP_LATEST_VER}" error messages. These items are SIMPLE CHECK TYPE.
                    is there any way to have these items working?

                    Best regards,

                    Fabio Corsino

                    Comment

                    • sadman
                      Senior Member
                      • Dec 2010
                      • 1611

                      #25
                      Originally posted by corsino
                      Is there any way to monitor all sites that we have on controller?
                      With LLD - no. I do not see way to fetch sites list with API. But u can use -s <sitename> option for unifi_miner.pl with UserParameter into zabbix agent's *.conf

                      Originally posted by corsino
                      My zabbix server is not on the same network as my controller. So I have "UAP UAPNAME is unavailable by ICMP"
                      Try ping <ip_of_uap> from zabbix box. I think it firewall/routing issue, because that item (icmpping) get data by directly pinging of UAP and it has nothing to do with zabbix agent on UniFi controller.

                      Originally posted by corsino
                      and "Firmware on UAP UAPNAME is not {$FW_UAP_LATEST_VER}" error messages. These items are SIMPLE CHECK TYPE.
                      "Firmware" key should not be "SIMPLE CHECK TYPE" type. It get data from unifi_miner.pl thru zabbix_agent and must have type "Zabbix agent".

                      But u can just disable that trigger. I collect that info for UAP's updating history and use it to assess the quality of the new firmware - using time of update as fixed point on timeline of complex screens with оther quality indicators, because use 4.x-beta branch.

                      Comment

                      • corsino
                        Junior Member
                        • Mar 2013
                        • 22

                        #26
                        First of all, thank you so much for your attention. I'll try to use -s <sitename> option today when I arrive at home. For the PING "problem", what I tried to explain, is that my controller has a public IP and the UAP's have private IP's like 192.168.0.10. For the firmware "problem", I wrote the bad information. They have "Zabbix agent" type. I don't know if makes any difference, but I forgot to tell you that I'm not running zabbix agent on Controller.


                        Best Regards,

                        Fabio Corsino

                        Comment

                        • sadman
                          Senior Member
                          • Dec 2010
                          • 1611

                          #27
                          Originally posted by corsino
                          my controller has a public IP and the UAP's have private IP's like 192.168.0.10.
                          Zabbix server should be able to ping UAP for correct work "icmpping" item. Or u can install zabbix_agent to any available to server connection box into private network and use it as proxy for ping routines (via UserParam and new Zabbix Items). Or something else.

                          Originally posted by corsino
                          For the firmware "problem", I wrote the bad information. They have "Zabbix agent" type. I don't know if makes any difference, but I forgot to tell you that I'm not running zabbix agent on Controller.
                          So, and problem is... ? If list of UAPs is fetched by discovery rule, then "firmware's" must be collected too.

                          Comment

                          • corsino
                            Junior Member
                            • Mar 2013
                            • 22

                            #28
                            The firmware versions are being collected. The problem is with the trigger "Firmware on UAP UAPNAME is not {$FW_UAP_LATEST_VER}", with expression "{Zabbix server:unifi.uap.state[54ee1fade4b02dd3c123287e, version].str("{$FW_UAP_LATEST_VER}")}=0 ". These triggers are always activated.


                            Kind regards,

                            Fabio Corsino

                            Comment

                            • sadman
                              Senior Member
                              • Dec 2010
                              • 1611

                              #29
                              Ough.
                              U need make {$FW_UAP_LATEST_VER} macro for controller host (into Zabbix) with value equal number of firmware, version that you consider the latest. No auto update FW ver from UBNT site exist ))
                              For example my config: {$FW_UAP_LATEST_VER} => 3.2.10.2886

                              Also u can just disable trigger in template or delete it.

                              Comment

                              • corsino
                                Junior Member
                                • Mar 2013
                                • 22

                                #30
                                Thank you so much Sadman. I thought that FW ver was auto updated. Eveything is working now. Thank you so much. You did a great job.


                                Regards,

                                Fabio Corsino

                                Comment

                                Working...