Ad Widget

Collapse

Monitoring a connectivity to a remote IP from Zabbix Agent

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sabari
    Junior Member
    • Feb 2023
    • 3

    #1

    Monitoring a connectivity to a remote IP from Zabbix Agent

    Hi All

    I need to monitor if a remote IP is reachable from a set of hosts which are running zabbix agents. I followed the steps given below

    1, Created the below powershell script on the host running zabbix agent
    Code:
    param (
    [string]$ipAddress
    )
    
    function Test-Ping {
    param (
    [string]$target
    )
    $ping = New-Object System.Net.NetworkInformation.Ping
    $reply = $ping.Send($target)
    if ($reply.Status -eq 'Success') {
    return 0
    } else {
    return 1
    }
    }
    
    $result = Test-Ping $ipAddress
    Write-Output $result
    2. Created a user parameter in zabbix_agent2.conf
    Code:
    UserParameter=ping_monitor[*],powershell -NoProfile -ExecutionPolicy Bypass -File "path\to\ping_monitor.ps1" $1
    The code runs fine from the host if I pass the IP address as argument

    3. Created item in zabbix UI with the key ping_monitor[{IP_ADDRESS}]
    4. Zabbix started collecting data with 0s as value.
    5. To check failure, deleted the route to the remote IP from the host and was waiting for the value of 1 instead there was no update for the particular item. The powershell script if ran inside from the host, returns 1 without any issue
    6. Went to the item again and clicked the Test while the route was down and it instead of returning 1, it says ZBX_TCP_READ() timed out.
    7. Tried increasing the Timeout value to 15 in zabbix_agent2.conf

    Am I missing something here? It would be great if some one can assist me on this.

    Regards
    Sabari
  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    This may be interesting for you
    Zabbix v4.4 template for ICMP ping test from the Zabbix Windows agent without any external scripts or user parameters. - Semiadmin/zbx-win-agent-ping

    Comment

    • epizarro
      Junior Member
      • Sep 2020
      • 8

      #3
      use system.run[Test-Connection ....]

      The Test-Connection cmdlet sends Internet Control Message Protocol (ICMP) echo request packets, or pings, to one or more remote computers and returns the echo response replies. You can use this cmdlet to determine whether a particular computer can be contacted across an IP network. You can use the parameters of Test-Connection to specify both the sending and receiving computers, to run the command as a background job, to set a time-out and number of pings, and to configure the connection and authentication. Unlike the familiar ping command, Test-Connection returns a TestConnectionCommand+PingStatus object that you can investigate in PowerShell. The Quiet parameter returns a Boolean value in a System.Boolean object for each tested connection. If multiple connections are tested, an array of Boolean values is returned.

      Comment

      Working...