Nigel Brown (Customer) asked a question.

WUG Rest API to determine current live monitor state

Hello, I am creating a powershell script to determine what http monitors are currently down. I can get this by processing the API via

 

api/v1/device-groups/0/devices/reports/state-change?returnHierarchy=true&limit=50&pageId=1&range=lastNMinutes&rangeN=60"

 

But as I am only getting the last 60 mins of logs if the monitor is still down eventually the logs will clear and the api does not return that monitor. ie if its down longer than 60mins.

 

What I need to see is there an API call that will give the current live state of the monitor.

 

I have tried this but it does not return the current state.

 

https://docs.ipswitch.com/NM/WhatsUpGold2022_1/02_Guides/rest_api/index.html#tag/Error

 

thanks

Nigel


  • Mike Rockwell (Progress Software)

    You need to use ....?range=lastPolled which is the value of the monitor the last time it was polled. It may be up, next time down ...

     

  • Nigel Brown (Customer)

    thanks Mike for the reploy.

     

    is this on the GET /api/v1/monitors/{monitorId} "Return single monitor" request or which request ist called?

     

    http://localhost:9644/api/v1/monitors/193?range=LastPolled

     

    if so all I get back is.

     

        "data": {

            "errors": [],

            "activeMonitors": [

                {

                    "monitorTypeInfo": {

                        "classId": "7536f6bc-a6c1-4c67-af3e-4d10599e3d4d",

                        "baseType": "Active"

                    },

                    "monitorId": "193",

                    "name": "https://website.com/abcde",

                    "description": "HTTP Content Monitor",

                    "id": "193"

                }

            ]

        }

    }

  • Jason Alberino (Progress Software Company)

    Hello @Nigel Brown (Customer)​  you can use https://github.com/jayyx2/WhatsUpGoldPS/blob/main/functions/Get-WUGDevice.ps1 as a reference for how to achieve this. You have to use the 'card' view, and then you get information on which monitor(s) are down, too:

     

    Here is a sample output:

    PS C:\WINDOWS\system32> Get-WUGDevice -DeviceID 2166 -View card

     

     

    downActiveMonitors   : {@{state=Down; reason=Interface ''vethdea95e4b'' (SNMP index 16) is Down. SNMP Error: NoSuchInstance; 

                 lastChangeUtc=2024-07-16T09:12:26.5456919Z; monitorTypeName=Interface; comment=vethdea95e4b; enabled=True}, 

                 @{state=Down; reason=Interface ''veth82d9083b'' (SNMP index 11) is Down. SNMP Error: NoSuchInstance; 

                 lastChangeUtc=2024-07-16T09:11:25.5456919Z; monitorTypeName=Interface; comment=veth82d9083b; enabled=True}, 

                 @{state=Down; reason=Interface ''vethe24fa812'' (SNMP index 9) is Down. SNMP Error: NoSuchInstance; 

                 lastChangeUtc=2024-07-15T10:04:38.5456919Z; monitorTypeName=Interface; comment=vethe24fa812; enabled=True}, 

                 @{state=Down; reason=Interface ''veth78b0ed22'' (SNMP index 7) is Down. SNMP Error: NoSuchInstance; 

                 lastChangeUtc=2024-07-12T09:29:43.5456919Z; monitorTypeName=Interface; comment=veth78b0ed22; enabled=True}}

    totalActiveMonitors   : 16

    totalActiveMonitorsDown : 4

    notes          : This device was scanned by discovery on 4/28/2023 8:39:15 AM.

    hostName        : 192.168.1.206

    networkAddress     : 192.168.1.206

    role          : LoadMaster

    brand          : Progress Software

    os           : Linux

    bestState        : Up

    worstState       : Down

    name          : PCC

    description       : LoadMaster software appliance

    id           : 2166