Ad Widget

Collapse

Ping external ip from zabbix agent

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • target
    Junior Member
    • Nov 2022
    • 21

    #1

    Ping external ip from zabbix agent

    Hello All,

    I am trying to ping a VPN IP Address from a Zabbix agent but unfortunately it doesn't work.
    I have placed the below into Zabbix agent configuration.

    UserParameter=CheckVPN,fping x.x.x.x | grep alive | wc -l

    And have created an item with type zabbix agent(active), key CheckVPN


    I have followed the instructions from this old post below:




    Can anyone help?


    Thanks.​
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    What exactly means "it doesn't work"? Very hard to suggest something, if you don't give us details.. Error messages for example? versions, just in case...

    Comment

    • target
      Junior Member
      • Nov 2022
      • 21

      #3
      Hi Cyber,

      Yes you are right. Finally I made it work. Get ping results from VPN via Zabbix Agent.


      Windows agent configuration
      UnsafeUserParameters=1
      UserParameter=local.ping[*],ping $1 -n 1 |find "TTL=">NUL && echo 1 || echo 0


      ITEM
      Zabbix agent
      KEY: local.ping[192.168.0.1]


      TRIGGER
      last(/VM22/local.ping[192.168.0.1])=0



      *(Change the IP Address to your VPN IP Address you want to monitor)


      Hope that helps someone else.

      Comment


      • Mohammed
        Mohammed commented
        Editing a comment
        Hi target
        hope you are doing well
        I'm new to Zabbix and am trying to ping to VPN and its worked actually and asking if you could make brief explanation about the userparameter that you mentioned in windows agent and how dose this configuration work?
    • Semiadmin
      Senior Member
      • Oct 2014
      • 1625

      #4
      For windows agent you may try this template. It works without any userparemeters.

      Comment

      • guille.rodriguez
        Senior Member
        • Jun 2022
        • 114

        #5
        Hi Mohammed , about the target post

        Originally posted by target
        Hi Cyber,

        Yes you are right. Finally I made it work. Get ping results from VPN via Zabbix Agent.


        Windows agent configuration
        UnsafeUserParameters=1
        UserParameter=local.ping[*],ping $1 -n 1 |find "TTL=">NUL && echo 1 || echo 0


        ITEM
        Zabbix agent
        KEY: local.ping[192.168.0.1]


        TRIGGER
        last(/VM22/local.ping[192.168.0.1])=0



        *(Change the IP Address to your VPN IP Address you want to monitor)


        Hope that helps someone else.
        UserParameter is a method to define custom "keys" (alias) for a command.

        If you want to run a ping from Windows, in cmd you write

        ping 8.8.8.8

        If you only want to test if device is alive or not running ping, you can use

        ping 8.8.8.8 -n 1 |find "TTL=">NUL && echo 1 || echo 0

        If device is alive, this command returns 1, if its dead returns 0. Try it.

        Now, let's create the alias (UserParameter), so in zabbix_agent.d/ you can create a conf (set the name u want, for example, windows.parameters.conf) and add this line

        UserParameter=local.ping[*],ping 8.8.8.8 -n 1 |find "TTL=">NUL && echo 1 || echo 0

        Now you want to ping this IP from agents, but tomorrow the IP change and you dont want to change the windows.parameters.conf on all machines... so its a better way to pass the IP as a parameter. Just change 8.8.8.8 to $1


        UserParameter=local.ping[*],ping $1 -n 1 |find "TTL=">NUL && echo 1 || echo 0

        Now restart the Zabbix Agent service on Windows client, and add the Item to template

        Type: Zabbix Agent (active or passive, what u prefer)
        Key: Alias given in the conf file local.ping[*] , but change * to the IP u want to check --> local.ping[8.8.8.8]


        If you want to check another IP, just add another item and just change IP to the other IP u want to check --> local.ping[8.8.4.4]



        You can create many user parameters as you need, you only need to reload / restart service to zabbix agent load the changes on files. Here is my windows.parameters.conf https://github.com/guillerg86/zabbix...arameters.conf
        Last edited by guille.rodriguez; 19-02-2023, 20:56.

        Comment

        Working...