Forum Discussion

Joseph's avatar
Joseph
Comet
2 months ago

API get statut Topology

Hello Cato team,

I am looking for a solution to monitor certain statuses on your API.

The objective is to obtain the status and counter "Connected," "Degraded," or "Disconnected" present in the topology.

I am looking for the URL request that can provide this. For better understanding of the reason for this request, I use a ticketing tool that can make API requests. I use this to check the API statuses, and based on the results, open ITSM tickets.

Thank for you time

  • Hi Joseph,

    You can pull the "Connected" or "Disconnected" status directly with the API using the account snapshot query. 

    For example, the following query:
    query accountSnapshot($accountID: ID!) {
        accountSnapshot(accountID: $accountID) {
            sites {
                connectivityStatus
                info {
                    name
                }
            }
        }
    }

    Will return the following payload, with the site name and the status of the connection:

    {
      "data": {
        "accountSnapshot": {
          "sites": [
            {
              "connectivityStatus": "connected",
              "info": {
                "name": "Lab VM Socket"
              }
            },
            {
              "connectivityStatus": "disconnected",
              "info": {
                "name": "Lab Site A"
              }
            },
            {
              "connectivityStatus": "disconnected",
              "info": {
                "name": "Lab Site B"
              }
            }
          ]
        }
      }
    }


    However Degraded status cannot be directly pulled and requires a bit more work as you will need to calculate the status yourself based on the state of the interfaces and other information:

    For example, this query:
    query accountSnapshot($accountID: ID!) {
        accountSnapshot(accountID: $accountID) {
            sites {
                info {
                    name
                }
                devices {
                    interfaces {
                        connected
                        name
                    }
                    interfacesLinkState {
                        id
                        mediaIn
                        up
                    }
                }
            }
        }
    }

    Will return the state of the interfaces.

    Under "devices > interfacesLinkState" is the information regarding the physical connectivity of an interface and if it has link. 
    Under "devices > interfaces" is the information on if the interface has successfully been able to connect to the Cato cloud.  
    If either of these would fail on a configured interface it would trigger the degraded state. 

    {
      "data": {
        "accountSnapshot": {
          "sites": [
            {
              "info": {
                "name": "Lab VM Socket"
              },
              "devices": [
                {
                  "interfaces": [
                    {
                      "connected": true,
                      "name": "WAN 01"
                    },
                    {
                      "connected": false,
                      "name": "WAN 02"
                    }
                  ],
                  "interfacesLinkState": [
                    {
                      "id": "LAN1",
                      "mediaIn": true,
                      "up": true
                    },
                    {
                      "id": "LAN2",
                      "mediaIn": true,
                      "up": true
                    },
                    {
                      "id": "WAN1",
                      "mediaIn": true,
                      "up": true
                    },
                    {
                      "id": "WAN2",
                      "mediaIn": true,
                      "up": true
                    },
                    {
                      "id": "USB1",
                      "mediaIn": true,
                      "up": false
                    },
                    {
                      "id": "USB2",
                      "mediaIn": true,
                      "up": false
                    }
                  ]
                }
              ]
            }
          ]
        }
      }
    }

    There are also things other than interface connectivity which can trigger the degraded state, such as HA issues, but this information should be obtainable in the accountSnapshot query.

    Finn