Help please online status

Good afternoon, I hope you can help me when I make a query to the api of the acs server, it returns several values, I wanted to know if in some of those values it shows the status of the equipment if it is connected and if it is disconnected, for this I attach the code of a equipment that is offline

[
    {
        "_id": "---------------------------------",
        "InternetGatewayDevice": {
            "Capabilities": {
                "_object": true,
                "_writable": false
            },
            "DeviceInfo": {
                "HardwareVersion": {
                    "_object": false,
                    "_timestamp": "2022-06-28T21:13:45.794Z",
                    "_type": "xsd:string",
                    "_value": "XN020-G3v v1 00000000"
                },
                "ProvisioningCode": {
                    "_object": false,
                    "_timestamp": "2022-06-28T21:13:45.794Z",
                    "_type": "xsd:string",
                    "_value": ""
                },
                "SoftwareVersion": {
                    "_object": false,
                    "_timestamp": "2022-06-28T21:13:45.794Z",
                    "_type": "xsd:string",
                    "_value": "1.1.0 0.8.0 v6037.0 Build 210525 Rel.29734n"
                },
                "SpecVersion": {
                    "_object": false,
                    "_timestamp": "2022-06-28T21:13:45.794Z",
                    "_type": "xsd:string",
                    "_value": "1.0"
                },
                "_object": true,
                "_writable": false
            },
            "DeviceSummary": {
                "_object": false,
                "_timestamp": "2022-06-28T21:13:45.794Z",
                "_type": "xsd:string",
                "_value": "InternetGatewayDevice:1.1[](Baseline:1, EthernetLAN:1)",
                "_writable": false
            },
            "DownloadDiagnostics": {
                "_object": true,
                "_writable": false
            },
            "IPPingDiagnostics": {
                "_object": true,
                "_writable": false
            },
            "LANDevice": {
                "1": {
                    "Hosts": {
                        "Host": {
                            "_object": true,
                            "_timestamp": "2022-06-28T21:13:38.750Z",
                            "_writable": true
                        },
                        "HostNumberOfEntries": {
                            "_object": false,
                            "_writable": false
                        },
                        "_object": true,
                        "_timestamp": "2022-06-28T21:13:38.750Z",
                        "_writable": false
                    },
                    "LANEthernetInterfaceConfig": {
                        "_object": true,
                        "_writable": false
                    },
                    "LANEthernetInterfaceNumberOfEntries": {
                        "_object": false,
                        "_writable": false
                    },
                    "LANHostConfigManagement": {
                        "_object": true,
                        "_writable": false
                    },
                    "LANUSBInterfaceNumberOfEntries": {
                        "_object": false,
                        "_writable": false
                    },
                    "LANWLANConfigurationNumberOfEntries": {
                        "_object": false,
                        "_writable": false
                    },
                    "WLANConfiguration": {
                        "1": {
                            "AutoChannelEnable": {
                                "_object": false,
                                "_writable": true
                            },
                            "BSSID": {
                                "_object": false,
                                "_writable": false
                            },
                            "BasicAuthenticationMode": {
                                "_object": false,
                                "_writable": true
                            },
                            "BasicDataTransmitRates": {
                                "_object": false,
                                "_writable": true
                            },
                            "BasicEncryptionModes": {
                                "_object": false,
                                "_writable": true
                            },
                            "BeaconType": {
                                "_object": false,
                                "_writable": true
                            },
                            "Channel": {
                                "_object": false,
                                "_writable": true
                            },
                            "Enable": {
                                "_object": false,
                                "_writable": true
                            },
                            "IEEE11iAuthenticationMode": {
                                "_object": false,
                                "_writable": true
                            },
                            "IEEE11iEncryptionModes": {
                                "_object": false,
                                "_writable": true
                            },
                            "MACAddressControlEnabled": {
                                "_object": false,
                                "_writable": true
                            },
                            "Name": {
                                "_object": false,
                                "_writable": false
                            },
                            "PossibleChannels": {
                                "_object": false,
                                "_writable": false
                            },
                            "SSID": {
                                "_object": false,
                                "_timestamp": "2022-06-28T21:13:38.764Z",
                                "_type": "xsd:string",
                                "_value": "---------------",
                                "_writable": true
                            },
                            "SSIDAdvertisementEnabled": {
                                "_object": false,
                                "_writable": true
                            },
                            "Standard": {
                                "_object": false,
                                "_writable": true
                            },
                            "Status": {
                                "_object": false,
                                "_writable": false
                            },
                            "TransmitPower": {
                                "_object": false,
                                "_writable": true
                            },
                            "TransmitPowerSupported": {
                                "_object": false,
                                "_writable": false
                            },
                            "WEPEncryptionLevel": {
                                "_object": false,
                                "_writable": false
                            },
                            "WEPKey": {
                                "_object": true,
                                "_writable": false
                            },
                            "WEPKeyIndex": {
                                "_object": false,
                                "_writable": true
                            },
                            "WMMEnable": {
                                "_object": false,
                                "_writable": true
                            },
                            "WPAAuthenticationMode": {
                                "_object": false,
                                "_writable": true
                            },
                            "WPAEncryptionModes": {
                                "_object": false,
                                "_writable": true
                            },
                            "WPS": {
                                "_object": true,
                                "_writable": false
                            },
                            "X_TP_BSSDescEntry": {
                                "_object": true,
                                "_writable": false
                            },
                            "X_TP_Band": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_Bandwidth": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_BeaconInterval": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_Configuration_Modified": {
                                "_object": false,
                                "_writable": false
                            },
                            "X_TP_DTIMFrequency": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_FragmentThreshold": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_GroupKeyUpdateInterval": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_IsolateClients": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_MACAddressControlRule": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_MACTableEntry": {
                                "_object": true,
                                "_writable": true
                            },
                            "X_TP_MACTableSize": {
                                "_object": false,
                                "_writable": false
                            },
                            "X_TP_MultiSSID": {
                                "_object": true,
                                "_writable": false
                            },
                            "X_TP_NeighbourScanEnabled": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_PreSSID": {
                                "_object": false,
                                "_writable": false
                            },
                            "X_TP_PreSharedKey": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_RTSThreshold": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_RadiusServerIP": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_RadiusServerPassword": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_RadiusServerPort": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_ShortGIEnable": {
                                "_object": false,
                                "_writable": true
                            },
                            "X_TP_WDSBridge": {
                                "_object": true,
                                "_writable": false
                            },
                            "X_TP_WlBrName": {
                                "_object": true,
                                "_writable": false
                            },
                            "_object": true,
                            "_timestamp": "2022-06-28T21:13:38.750Z",
                            "_writable": false
                        },
                        "_object": true,
                        "_timestamp": "2022-06-28T21:13:38.750Z",
                        "_writable": false
                    },
                    "_object": true,
                    "_timestamp": "2022-06-28T21:13:38.750Z",
                    "_writable": false
                },
                "_object": true,
                "_timestamp": "2022-06-28T21:13:38.750Z",
                "_writable": false
            },
            "LANDeviceNumberOfEntries": {
                "_object": false,
                "_writable": false
            },
            "Layer2Bridging": {
                "_object": true,
                "_writable": false
            },
            "Layer3Forwarding": {
                "_object": true,
                "_writable": false
            },
            "ManagementServer": {
                "ConnectionRequestPassword": {
                    "_object": false,
                    "_timestamp": "2022-06-28T21:13:38.773Z",
                    "_type": "xsd:string",
                    "_value": "-------------",
                    "_writable": true
                },
                "ConnectionRequestURL": {
                    "_object": false,
                    "_timestamp": "2022-06-28T21:13:45.794Z",
                    "_type": "xsd:string",
                    "_value": "http://----------------:-------/tr069",
                    "_writable": false
                },
                "ConnectionRequestUsername": {
                    "_object": false,
                    "_timestamp": "2022-06-28T21:13:38.773Z",
                    "_type": "xsd:string",
                    "_value": "-----------------------------",
                    "_writable": true
                },
                "EnableCWMP": {
                    "_object": false,
                    "_writable": true
                },
                "KickURL": {
                    "_object": false,
                    "_writable": false
                },
                "ParameterKey": {
                    "_object": false,
                    "_timestamp": "2022-06-28T21:13:45.794Z",
                    "_type": "xsd:string",
                    "_value": "",
                    "_writable": false
                },
                "Password": {
                    "_object": false,
                    "_writable": true
                },
                "PeriodicInformEnable": {
                    "_object": false,
                    "_timestamp": "2022-06-28T21:13:38.772Z",
                    "_type": "xsd:boolean",
                    "_value": true,
                    "_writable": true
                },
                "PeriodicInformInterval": {
                    "_object": false,
                    "_timestamp": "2022-06-28T21:13:38.772Z",
                    "_type": "xsd:unsignedInt",
                    "_value": 300,
                    "_writable": true
                },
                "PeriodicInformTime": {
                    "_object": false,
                    "_timestamp": "2022-06-28T21:13:38.773Z",
                    "_type": "xsd:dateTime",
                    "_value": "1970-01-01T12:39:04.000Z",
                    "_writable": true
                },
                "URL": {
                    "_object": false,
                    "_writable": true
                },
                "UpgradesManaged": {
                    "_object": false,
                    "_writable": true
                },
                "Username": {
                    "_object": false,
                    "_writable": true
                },
                "_object": true,
                "_timestamp": "2022-06-28T21:13:38.750Z",
                "_writable": false
            },
            "Services": {
                "_object": true,
                "_writable": false
            },
            "Time": {
                "_object": true,
                "_writable": false
            },
            "TraceRouteDiagnostics": {
                "_object": true,
                "_writable": false
            },
            "UDPEchoConfig": {
                "_object": true,
                "_writable": false
            },
            "UploadDiagnostics": {
                "_object": true,
                "_writable": false
            },
            "WANDevice": {
                "1": {
                    "WANConnectionDevice": {
                        "1": {
                            "WANEthernetLinkConfig": {
                                "_object": true,
                                "_writable": false
                            },
                            "WANIPConnection": {
                                "_object": true,
                                "_timestamp": "2022-06-28T21:13:38.750Z",
                                "_writable": true
                            },
                            "WANIPConnectionNumberOfEntries": {
                                "_object": false,
                                "_writable": false
                            },
                            "WANPPPConnection": {
                                "1": {
                                    "ConnectionStatus": {
                                        "_object": false,
                                        "_writable": false
                                    },
                                    "ConnectionTrigger": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "ConnectionType": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "CurrentMRUSize": {
                                        "_object": false,
                                        "_writable": false
                                    },
                                    "DNSEnabled": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "DNSOverrideAllowed": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "DNSServers": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "DefaultGateway": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "Enable": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "ExternalIPAddress": {
                                        "_object": false,
                                        "_timestamp": "2022-06-28T21:13:45.794Z",
                                        "_type": "xsd:string",
                                        "_value": "20.20.1.3",
                                        "_writable": true
                                    },
                                    "IdleDisconnectTime": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "LastConnectionError": {
                                        "_object": false,
                                        "_writable": false
                                    },
                                    "MACAddress": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "MACAddressOverride": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "MaxMRUSize": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "NATEnabled": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "Name": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "PPPAuthenticationProtocol": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "PPPLCPEcho": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "PPPLCPEchoRetry": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "PPPoEACName": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "PPPoEServiceName": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "Password": {
                                        "_object": false,
                                        "_timestamp": "2022-06-28T21:13:45.797Z",
                                        "_type": "xsd:string",
                                        "_value": "",
                                        "_writable": true
                                    },
                                    "PortMapping": {
                                        "_object": true,
                                        "_writable": true
                                    },
                                    "PortMappingNumberOfEntries": {
                                        "_object": false,
                                        "_writable": false
                                    },
                                    "PossibleConnectionTypes": {
                                        "_object": false,
                                        "_writable": false
                                    },
                                    "RSIPAvailable": {
                                        "_object": false,
                                        "_writable": false
                                    },
                                    "RemoteIPAddress": {
                                        "_object": false,
                                        "_writable": false
                                    },
                                    "RouteProtocolRx": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "Stats": {
                                        "_object": true,
                                        "_writable": false
                                    },
                                    "TransportType": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "Uptime": {
                                        "_object": false,
                                        "_writable": false
                                    },
                                    "Username": {
                                        "_object": false,
                                        "_timestamp": "2022-06-28T21:13:45.797Z",
                                        "_type": "xsd:string",
                                        "_value": "-------------",
                                        "_writable": true
                                    },
                                    "X_TP_BcastAddr": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "X_TP_ClonedMACAddress": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "X_TP_ConnectionId": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "X_TP_FirewallEnabled": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "X_TP_FullconeNATEnabled": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "X_TP_IGMPProxyEnabled": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "X_TP_IfName": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "X_TP_L2IfName": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "X_TP_LanInterface": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "X_TP_PortTriggering": {
                                        "_object": true,
                                        "_writable": false
                                    },
                                    "X_TP_UseStaticIP": {
                                        "_object": false,
                                        "_writable": true
                                    },
                                    "_object": true,
                                    "_timestamp": "2022-06-28T21:13:38.750Z",
                                    "_writable": true
                                },
                                "_object": true,
                                "_timestamp": "2022-06-28T21:13:38.750Z",
                                "_writable": true
                            },
                            "WANPPPConnectionNumberOfEntries": {
                                "_object": false,
                                "_writable": false
                            },
                            "X_TP_WANPonLinkConfig": {
                                "_object": true,
                                "_writable": false
                            },
                            "_object": true,
                            "_timestamp": "2022-06-28T21:13:38.750Z",
                            "_writable": true
                        },
                        "_object": true,
                        "_timestamp": "2022-06-28T21:13:38.750Z"
                    },
                    "_object": true,
                    "_writable": false
                },
                "_object": true,
                "_timestamp": "2022-06-28T21:13:38.750Z",
                "_writable": false
            },
            "WANDeviceNumberOfEntries": {
                "_object": false,
                "_writable": false
            },
            "X_TP_CustomCfg": {
                "_object": true,
                "_writable": false
            },
            "X_TP_EWAN": {
                "_object": true,
                "_writable": false
            },
            "X_TP_GponMacInfo": {
                "_object": true,
                "_writable": false
            },
            "X_TP_GponUserInfo": {
                "_object": true,
                "_writable": false
            },
            "X_TP_Local": {
                "_object": true,
                "_writable": false
            },
            "X_TP_QoS": {
                "_object": true,
                "_writable": false
            },
            "_object": true,
            "_timestamp": "2022-06-28T21:13:38.750Z",
            "_writable": false
        },
        "VirtualParameters": {
            "_object": true,
            "pppoe": {
                "_object": false,
                "_timestamp": "2022-06-28T21:13:45.801Z",
                "_type": "xsd:string",
                "_value": "tecnocable",
                "_writable": true
            },
            "pppoeclave": {
                "_object": false,
                "_timestamp": "2022-06-28T21:13:45.801Z",
                "_type": "xsd:string",
                "_value": "",
                "_writable": true
            }
        },
        "_deviceId": {
            "_Manufacturer": "TP-Link",
            "_OUI": "-----",
            "_ProductClass": "IGD",
            "_SerialNumber": "----------"
        },
        "_lastBoot": "2022-06-28T21:13:38.750Z",
        "_lastBootstrap": "2022-06-28T21:13:38.750Z",
        "_lastInform": "2022-06-28T21:13:45.793Z",
        "_registered": "2022-06-28T21:13:38.750Z",
        "_timestamp": "2022-06-28T21:13:38.750Z"
    }
]


You can infer the online status from the last inform. I use inform interval plus 2 minutes to determine if a CPE is online. Example, inform interval is 1 hour. If the CPE has informed within 1 hour and 2 minutes, you can presume its online. If greater than, then presume its offline.

some of my scripts rely on contacting the CPE directly, and the best way to find out if it’s online or not is to use the old linux ping from a bash script:

ping -w 1 -c 1 $ip >/dev/null

sends just 1 packet and wait 1 second for it.
$? will contain 0 if it succeded. If not, and unless your physical medium is unreliable like wireless, you will have to consider it offine.

of course you will have to extract the IP from the ACS Api first.

also I’m pretty use akcoder approach works. I just feel more confortable using linux tools and bash scripts.

LATE EDIT 2: one important fact about why I do this it’s because I have PeriodicInform disabled during normal operation. If I really need to provision a running CPE, I place a tag on it and let a bash script retrieve the list of CPEs under such tag and do a ConnectionRequest one by one. This was done to prevent massive CPE faults during blackouts (real culprit was our RESTAPI was too slow and had a hard limit of simultaneous 100 connections to MySQL, raising the value was not an option so it was replaced by text files under the same GenieACS server. Works like a charm).

1 Like