Back
Featured image of post Orange Livebox monitoring with Zabbix using Json

Orange Livebox monitoring with Zabbix using Json

Monitor a livebox using the API and Zabbix.

Livebox script

Create the script:

vim /usr/share/zabbix/externalscripts/livebox.sh

Paste the following script :

#!/bin/bash
router_ip=XXX.XXX.XXX.XXX
router_pw=XXXXXXXXXXXXXXX
# Authentication
auth=$(curl -s -X POST -c - -H 'Content-Type: application/x-sah-ws-4-call+json' -H 'Authorization: X-Sah-Login' -d "{\"service\":\"sah.Device.Information\",\"method\":\"createContext\",\"parameters\":{\"applicationName\":\"so_sdkut\",\"username\":\"admin\",\"password\":\"$router_pw\"}}" http://$router_ip/ws) 
#Context ID
contextID=$(echo "$auth" | grep -oP '"contextID":"\K[^"]+')
# Cookie
cookie=$(echo "$auth" | tail -n1)
# Data
MIBs=$(echo "${cookie}" | curl -s -b - -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H "X-Context: $contextID" -d "{\"service\":\"NeMo.Intf.data\",\"method\":\"getMIBs\",\"parameters\":{}}" http://$router_ip/ws)
DSLStats=$(echo "${cookie}" | curl -s -b - -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H "X-Context: $contextID" -d "{\"service\":\"NeMo.Intf.dsl0\",\"method\":\"getDSLStats\",\"parameters\":{}}" http://$router_ip/ws)
echo {\"MIBS\" : $MIBs, \"DSLStats\" : $DSLStats}
#echo $DSLStats
logout=$(echo "${cookie}" | curl -s -b - -X POST http://$router_ip/logout)

Make it executable :

chmod +x /usr/share/zabbix/externalscripts/livebox.sh

Here is the full output :

{
	"MIBS": {
		"status": {
			"base": {
				"data": {
					"Name": "data",
					"Enable": true,
					"Status": true,
					"Flags": "up nat-config enabled",
					"ULIntf": {},
					"LLIntf": {
						"primdata": {
							"Name": "primdata"
						}
					}
				},
				"primdata": {
					"ULIntf": {
						"data": {}
					},
					"LLIntf": {
						"dhcp_data": {}
					}
				},
				"dhcp_data": {
					"Name": "dhcp_data",
					"Enable": true,
					"Status": true,
					"Flags": "dhcp logical enabled up",
					"ULIntf": {
						"primdata": {
							"Name": "primdata"
						}
					},
					"LLIntf": {
						"atm_multi": {
							"Name": "atm_multi"
						}
					}
				},
				"atm_multi": {
					"Name": "atm_multi",
					"Enable": true,
					"Status": true,
					"Flags": "atm netdev ipv4 zap-iptv vod-iptv mcast-iptv nmc-ipv6 statmon nat-enabled enabled up netdev-bound netdev-up ipv4-up",
					"ULIntf": {
						"dhcp_data": {
							"Name": "dhcp_data"
						}
					},
					"LLIntf": {
						"dsl0": {
							"Name": "dsl0"
						}
					}
				},
				"dsl0": {
					"Name": "dsl0",
					"Enable": true,
					"Status": true,
					"Flags": "dsl dslline physical wan statmon enabled up",
					"ULIntf": {
						"ptm0": {
							"Name": "ptm0"
						},
						"atm_data": {
							"Name": "atm_data"
						},
						"atm_multi": {
							"Name": "atm_multi"
						},
						"atm_voip": {
							"Name": "atm_voip"
						},
						"atm_iptv1": {
							"Name": "atm_iptv1"
						},
						"atm_iptv2": {
							"Name": "atm_iptv2"
						},
						"atm_iptv3": {
							"Name": "atm_iptv3"
						},
						"atm_iptv4": {
							"Name": "atm_iptv4"
						}
					},
					"LLIntf": {}
				}
			},
			"6rd": {},
			"alias": {
				"data": {
					"Alias": "cpe-data"
				},
				"primdata": {},
				"dhcp_data": {
					"Alias": "cpe-dhcp_data"
				},
				"atm_multi": {
					"Alias": "cpe-atm_multi"
				},
				"dsl0": {
					"Alias": "cpe-dsl0"
				}
			},
			"atm": {
				"atm_multi": {
					"DSLPlugin": "",
					"XTMPlugin": "",
					"DSLIPC": "/var/run/dsl",
					"LastChangeTime": 86,
					"LastChange": 6078507,
					"LinkType": "EoA",
					"LinkStatus": "Up",
					"DestinationAddress": "8/32",
					"Encapsulation": "LLC",
					"FCSPreserved": false,
					"QoSClass": "UBR",
					"PeakCellRate": 7500,
					"MaximumBurstSize": 0,
					"SustainableCellRate": 0
				}
			},
			"bcmvlan": {},
			"bridge": {},
			"copy": {
				"data": {},
				"primdata": {},
				"dhcp_data": {},
				"atm_multi": {},
				"dsl0": {}
			},
			"dhcp-api": {
				"data": {},
				"primdata": {},
				"dhcp_data": {},
				"atm_multi": {},
				"dsl0": {}
			},
			"dhcp": {
				"dhcp_data": {
					"DHCPStatus": "Bound",
					"LastConnectionError": "None",
					"Renew": false,
					"IPAddress": "X.X.X.X",
					"SubnetMask": "255.255.252.0",
					"IPRouters": "X.X.X.X",
					"DNSServers": "X.X.X.X,X.X.X.X",
					"DHCPServer": "X.X.X.X",
					"LeaseTime": 259200,
					"LeaseTimeRemaining": 217351,
					"Uptime": 6078495,
					"DSCPMark": 48,
					"PriorityMark": 6,
					"Formal": false,
					"BroadcastFlag": 65535,
					"CheckAuthentication": true,
					"AuthenticationInformation": "dhcpliveboxfr250",
					"ResetOnPhysDownTimeout": 90,
					"RetransmissionStrategy": "4000 8000 16000 32000 64000 128000 -1 0",
					"RetransmissionRenewTimeout": -1,
					"SentOption": {
						"60": {
							"Enable": true,
							"Alias": "cpe-60",
							"Tag": 60,
							"Value": "736167656d"
						},
						"61": {
							"Enable": true,
							"Alias": "cpe-61",
							"Tag": 61,
							"Value": "0144A61E837456"
						},
						"77": {
							"Enable": true,
							"Alias": "cpe-77",
							"Tag": 77,
							"Value": "2b46535644534c5f6c697665626f782e496e7465726e65742e736f66746174686f6d652e4c697665626f7834"
						},
						"90": {
							"Enable": true,
							"Alias": "cpe-90",
							"Tag": 90,
							"Value": "00000000000000000000001a0900000558010341010d6674692f347a796b3237743c12377b35695f67417765334a4b3a44433b03134cb38bed4e81eb1ab2f82f17637aeb0be4"
						}
					},
					"ReqOption": {
						"1": {
							"Enable": true,
							"Alias": "cpe-1",
							"Tag": 1,
							"Value": "fffffc00"
						},
						"3": {
							"Enable": true,
							"Alias": "cpe-3",
							"Tag": 3,
							"Value": "5a686c01"
						},
						"6": {
							"Enable": true,
							"Alias": "cpe-6",
							"Tag": 6,
							"Value": "500af60151fd9509"
						},
						"15": {
							"Enable": true,
							"Alias": "cpe-15",
							"Tag": 15,
							"Value": "6f72616e67652e6672"
						},
						"28": {
							"Enable": true,
							"Alias": "cpe-28",
							"Tag": 28,
							"Value": "5a686fff"
						},
						"51": {
							"Enable": true,
							"Alias": "cpe-51",
							"Tag": 51,
							"Value": "0003f480"
						},
						"58": {
							"Enable": true,
							"Alias": "cpe-58",
							"Tag": 58,
							"Value": "00014a78"
						},
						"59": {
							"Enable": true,
							"Alias": "cpe-59",
							"Tag": 59,
							"Value": "00032a28"
						},
						"90": {
							"Enable": true,
							"Alias": "cpe-90",
							"Tag": 90,
							"Value": "0000000000000000000000646863706c697665626f786672323530"
						},
						"119": {
							"Enable": true,
							"Alias": "cpe-119",
							"Tag": 119,
							"Value": "034e414e06616363657373116f72616e67652d6d756c74696d65646961036e657400"
						},
						"120": {
							"Enable": true,
							"Alias": "cpe-120",
							"Tag": 120,
							"Value": "0006736263743367034e414e06616363657373116f72616e67652d6d756c74696d65646961036e657400"
						},
						"125": {
							"Enable": true,
							"Alias": "cpe-125",
							"Tag": 125,
							"Value": "000005580c010a0001000000ffffffffff"
						}
					}
				}
			},
			"dhcpv6": {},
			"dhcpv6impl": {},
			"dop-slave": {},
			"dsl": {
				"dsl0": {
					"DSLPlugin": "",
					"XTMPlugin": "",
					"DSLIPC": "/var/run/dsl",
					"LastChangeTime": 1675444,
					"LastChange": 4403149,
					"UpstreamCurrRate": 892,
					"DownstreamCurrRate": 4248,
					"LinkStatus": "Up",
					"UpstreamMaxRate": 874,
					"DownstreamMaxRate": 5139,
					"UpstreamAttenuation": 347,
					"DownstreamAttenuation": 634,
					"DownstreamLineAttenuation": 570,
					"UpstreamLineAttenuation": 347,
					"UpstreamNoiseMargin": 60,
					"DownstreamNoiseMargin": 95,
					"UpstreamPower": 123,
					"DownstreamPower": 191,
					"FirmwareVersion": "",
					"StandardsSupported": "G.992.1_Annex_A, G.992.1_Annex_B, G.992.1_Annex_C,T1.413, T1.413i2,ETSI_101_388, G.992.2,G.992.3_Annex_A, G.992.3_Annex_B, G.992.3_Annex_C, G.992.3_Annex_I, G.992.3_Annex_J,G.992.3_Annex_M, G.992.4,G.992.5_Annex_A, G.992.5_Annex_B, G.992.5_Annex_C, G.992.5_Annex_I, G.992.5_Annex_J, G.992.5_Annex_M, G.993.1,G.993.1_Annex_A, G.993.2_Annex_A, G.993.2_Annex_B",
					"StandardUsed": "G.992.5_Annex_A",
					"DataPath": "Interleaved",
					"InterleaveDepth": 0,
					"ModulationType": "ADSL",
					"ChannelEncapsulationType": "G.992.3_Annex_K_ATM",
					"ModulationHint": "ADSL",
					"AllowedProfiles": "8a, 8b, 8c, 8d, 12a, 12b, 17a, 17b, 30a",
					"CurrentProfile": "",
					"UPBOKLE": 966
				}
			},
			"dslbonding": {},
			"dslite": {},
			"dslline": {
				"dsl0": {
					"Line_LastChangeTime": 1675444,
					"Line_LastChange": 4403149,
					"LineStatus": "Up",
					"Line_UpstreamCurrRate": 892,
					"Line_DownstreamCurrRate": 4248,
					"Line_UpstreamMaxRate": 874,
					"Line_DownstreamMaxRate": 5139,
					"Line_UpstreamNoiseMargin": 60,
					"Line_DownstreamNoiseMargin": 95,
					"Line_UpstreamAttenuation": 347,
					"Line_DownstreamLineAttenuation": 570,
					"Line_UpstreamLineAttenuation": 347,
					"Line_DownstreamAttenuation": 634,
					"Line_UpstreamPower": 123,
					"Line_DownstreamPower": 191,
					"Line_DataPath": "Interleaved",
					"Line_InterleaveDepth": 0,
					"Line_ActualInterleavingDelay": 0,
					"Line_ACTINP": 860,
					"Line_INPREPORT": false,
					"Line_ModulationType": "ADSL",
					"Line_ModulationHint": "Auto",
					"Line_FirmwareVersion": "",
					"Line_StandardsSupported": "G.992.1_Annex_A, G.992.1_Annex_B, G.992.1_Annex_C,T1.413, T1.413i2,ETSI_101_388, G.992.2,G.992.3_Annex_A, G.992.3_Annex_B, G.992.3_Annex_C, G.992.3_Annex_I, G.992.3_Annex_J,G.992.3_Annex_M, G.992.4,G.992.5_Annex_A, G.992.5_Annex_B, G.992.5_Annex_C, G.992.5_Annex_I, G.992.5_Annex_J, G.992.5_Annex_M, G.993.1,G.993.1_Annex_A, G.993.2_Annex_A, G.993.2_Annex_B",
					"Line_StandardUsed": "G.992.5_Annex_A",
					"Line_AllowedProfiles": "8a, 8b, 8c, 8d, 12a, 12b, 17a, 17b, 30a",
					"Line_CurrentProfile": "",
					"Line_UPBOKLE": 966,
					"Line_TRELLISds": true,
					"Line_TRELLISus": true,
					"Line_ATN70": " 51.5",
					"Line_CO_Manufacturer": "BDCM",
					"Line_FsmVectoring": "DISABLED",
					"Line_VCE_MAC": "00:00:00:00:00:00",
					"Line_LATNpbds": "0,0,0,0",
					"Line_LATNpbus": "0,0,0,0,0",
					"Line_SATNpbds": "0,0,0,0",
					"Line_SATNpbus": "0,0,0,0,0",
					"Line_SNRMpbds": "0,0,0,0",
					"Line_SNRMpbus": "0,0,0,0,0",
					"Line_XTURVendor": "3d005341474d0000",
					"Line_XTUCVendor": "b5004244434da49e"
				}
			},
			"eth": {},
			"gre": {},
			"ipsec": {},
			"nat": {
				"atm_multi": {
					"NATEnabled": true
				}
			},
			"netdev-api": {
				"data": {},
				"primdata": {},
				"dhcp_data": {},
				"atm_multi": {},
				"dsl0": {}
			},
			"netdev": {
				"atm_multi": {
					"NetDevIndex": 43,
					"NetDevType": "ether",
					"NetDevFlags": "up broadcast allmulti multicast",
					"NetDevName": "atm_multi",
					"LLAddress": "44:A6:1E:83:74:56",
					"TxQueueLen": 1000,
					"MTU": 1500,
					"NetDevState": "unknown",
					"IPv4Forwarding": true,
					"IPv4ForceIGMPVersion": 2,
					"IPv4AcceptSourceRoute": true,
					"IPv4AcceptLocal": false,
					"IPv4AcceptRedirects": false,
					"IPv4ArpFilter": false,
					"IPv6AcceptRA": true,
					"IPv6ActAsRouter": false,
					"IPv6AutoConf": true,
					"IPv6MaxRtrSolicitations": 3,
					"IPv6RtrSolicitationInterval": 4000,
					"IPv6AcceptSourceRoute": false,
					"IPv6AcceptRedirects": true,
					"IPv6OptimisticDAD": false,
					"IPv6Disable": true,
					"IPv6HostPart": "",
					"RtTable": 0,
					"IPv6AddrDelegate": "bridge",
					"IPv4Addr": {
						"dyn6": {
							"Enable": true,
							"Status": "dynamic",
							"Address": "X.X.X.X",
							"Peer": "",
							"PrefixLen": 22,
							"Flags": "permanent",
							"Scope": "global",
							"NeMoFlags": "@gua"
						}
					},
					"IPv6Addr": {},
					"IPv4Route": {
						"route_0": {
							"Enable": true,
							"Status": "bound",
							"DstLen": 0,
							"Table": "main",
							"Scope": "global",
							"Protocol": "boot",
							"Type": "unicast",
							"Dst": "0.0.0.0",
							"Priority": 0,
							"Gateway": "X.X.X.X"
						},
						"dyn10": {
							"Enable": true,
							"Status": "dynamic",
							"DstLen": 22,
							"Table": "main",
							"Scope": "link",
							"Protocol": "kernel",
							"Type": "unicast",
							"Dst": "X.X.X.X",
							"Priority": 0,
							"Gateway": ""
						}
					},
					"IPv6Route": {}
				}
			},
			"penable": {},
			"ppp": {},
			"ptm": {},
			"ra-api": {
				"data": {},
				"primdata": {},
				"dhcp_data": {},
				"atm_multi": {},
				"dsl0": {}
			},
			"ra": {},
			"sfp": {},
			"statmon": {
				"atm_multi": {
					"StatMon": {
						"netdev-historical": {
							"Enable": true,
							"Interval": 30000,
							"Type": "netdev"
						}
					}
				},
				"dsl0": {
					"StatMon": {
						"netdev-historical": {
							"Enable": true,
							"Interval": 30000,
							"Type": "dslline"
						},
						"netdev-saturation": {
							"Enable": true,
							"Interval": 1000,
							"Type": "dslline"
						}
					}
				}
			},
			"switch": {},
			"tethering": {},
			"vlan": {},
			"wan": {
				"dsl0": {
					"PhysicalInterface": "ADSL VDSL"
				}
			},
			"wlanbcmep": {},
			"wlanbcmrad": {},
			"wlanbcmvap": {},
			"wlanconfig": {},
			"wlanendpoint": {},
			"wlanquanrad": {},
			"wlanradio": {},
			"wlanvap": {},
			"wwan": {}
		}
	},
	"DSLStats": {
		"status": {
			"ReceiveBlocks": 184568902,
			"TransmitBlocks": 98623950,
			"CellDelin": 0,
			"LinkRetrain": 2,
			"InitErrors": 0,
			"InitTimeouts": 0,
			"LossOfFraming": 0,
			"ErroredSecs": 330,
			"SeverelyErroredSecs": 159,
			"FECErrors": 3717424,
			"ATUCFECErrors": 281300,
			"HECErrors": 0,
			"ATUCHECErrors": 387,
			"CRCErrors": 841,
			"ATUCCRCErrors": 57
		}
	}
}

We use it in Zabbix with the following template :

zabbix_export:
  version: '5.2'
  date: '2021-04-21T11:44:46Z'
  groups:
    -
      name: 'Templates/Network devices'
  templates:
    -
      template: 'Template livebox'
      name: 'Template livebox'
      groups:
        -
          name: 'Templates/Network devices'
      items:
        -
          name: ReceiveBlocks
          type: DEPENDENT
          key: livebox.DSLStats.status.ReceiveBlocks
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.DSLStats.status.ReceiveBlocks
            -
              type: CHANGE_PER_SECOND
              parameters:
                - ''
          master_item:
            key: livebox.sh
        -
          name: TransmitBlocks
          type: DEPENDENT
          key: livebox.DSLStats.status.TransmitBlocks
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.DSLStats.status.TransmitBlocks
            -
              type: CHANGE_PER_SECOND
              parameters:
                - ''
          master_item:
            key: livebox.sh
        -
          name: DownstreamAttenuation
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.DownstreamAttenuation
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.DownstreamAttenuation
          master_item:
            key: livebox.sh
        -
          name: DownstreamCurrRate
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.DownstreamCurrRate
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.DownstreamCurrRate
          master_item:
            key: livebox.sh
        -
          name: DownstreamLineAttenuation
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.DownstreamLineAttenuation
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.DownstreamLineAttenuation
          master_item:
            key: livebox.sh
        -
          name: DownstreamMaxRate
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.DownstreamMaxRate
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.DownstreamMaxRate
          master_item:
            key: livebox.sh
        -
          name: DownstreamNoiseMargin
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.DownstreamNoiseMargin
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.DownstreamNoiseMargin
          master_item:
            key: livebox.sh
        -
          name: DownstreamPower
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.DownstreamPower
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.DownstreamPower
          master_item:
            key: livebox.sh
        -
          name: LinkStatus
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.LinkStatus
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.LinkStatus
            -
              type: STR_REPLACE
              parameters:
                - Up
                - '1'
            -
              type: STR_REPLACE
              parameters:
                - Down
                - '0'
          master_item:
            key: livebox.sh
        -
          name: UpstreamAttenuation
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.UpstreamAttenuation
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.UpstreamAttenuation
          master_item:
            key: livebox.sh
        -
          name: UpstreamCurrRate
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.UpstreamCurrRate
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.UpstreamCurrRate
          master_item:
            key: livebox.sh
        -
          name: UpstreamLineAttenuation
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.UpstreamLineAttenuation
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.UpstreamLineAttenuation
          master_item:
            key: livebox.sh
        -
          name: UpstreamMaxRate
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.UpstreamMaxRate
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.UpstreamMaxRate
          master_item:
            key: livebox.sh
        -
          name: UpstreamNoiseMargin
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.UpstreamNoiseMargin
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.UpstreamNoiseMargin
          master_item:
            key: livebox.sh
        -
          name: UpstreamPower
          type: DEPENDENT
          key: livebox.MIBS.status.dsl.dsl0.UpstreamPower
          delay: '0'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.MIBS.status.dsl.dsl0.UpstreamPower
          master_item:
            key: livebox.sh
        -
          name: Livebox
          type: EXTERNAL
          key: livebox.sh
          history: '0'
          trends: '0'
          value_type: TEXT

Built with Hugo
Theme Stack designed by Jimmy