opnsense-prom-exporter/tests/common.py

150 lines
5.5 KiB
Python
Raw Permalink Normal View History

2023-09-01 13:27:55 +02:00
import json
MAIN_HOST = "192.168.1.1"
BACKUP_HOST = "192.168.1.2"
LOGIN = "user"
PASSWORD = "pwd"
def generate_get_vip_status_paylaod(state_wan, state_lan, maintenance_mode):
return json.dumps(
{
"total": 2,
"rowCount": 2,
"current": 1,
"rows": [
{
"interface": "wan",
"vhid": "1",
"advbase": "1",
"advskew": "0",
"subnet": "176.149.171.241",
"status": state_wan,
"mode": "carp",
"status_txt": state_wan,
"vhid_txt": "1 (freq. 1/0)",
},
{
"interface": "lan",
"vhid": "3",
"advbase": "1",
"advskew": "0",
"subnet": "192.168.200.1",
"status": state_lan,
"mode": "carp",
"status_txt": state_lan,
"vhid_txt": "3 (freq. 1/0)",
},
],
"carp": {
"demotion": "0",
"allow": "1",
"maintenancemode": maintenance_mode,
"status_msg": "",
},
}
)
def generate_diagnostics_traffic_interface_paylaod():
return json.dumps(
{
"interfaces": {
"lan": {
"index": "2",
"flags": "8963",
"promiscuous listeners": "1",
"send queue length": "0",
"send queue max length": "50",
"send queue drops": "0",
"type": "Ethernet",
"address length": "6",
"header length": "18",
"link state": "2",
"vhid": "0",
"datalen": "152",
"mtu": "1500",
"metric": "0",
"line rate": "10000000000 bit/s",
"packets received": "3699327747",
"input errors": "0",
"packets transmitted": "8972963403",
"output errors": "0",
"collisions": "0",
"bytes received": "2474843996609",
"bytes transmitted": "11711737078752",
"multicasts received": "29274204",
"multicasts transmitted": "0",
"input queue drops": "0",
"packets for unknown protocol": "0",
"HW offload capabilities": "0x0",
"uptime at attach or stat reset": "1",
"name": "LAN",
},
"opt1": {
"index": "3",
"flags": "8863",
"promiscuous listeners": "0",
"send queue length": "0",
"send queue max length": "50",
"send queue drops": "0",
"type": "Ethernet",
"address length": "6",
"header length": "18",
"link state": "2",
"vhid": "0",
"datalen": "152",
"mtu": "1500",
"metric": "0",
"line rate": "10000000000 bit/s",
"packets received": "1120457",
"input errors": "0",
"packets transmitted": "178007891",
"output errors": "0",
"collisions": "0",
"bytes received": "221674964",
"bytes transmitted": "55808795987",
"multicasts received": "393767",
"multicasts transmitted": "0",
"input queue drops": "0",
"packets for unknown protocol": "0",
"HW offload capabilities": "0x0",
"uptime at attach or stat reset": "1",
"name": "LANOPNSYNC",
},
"wan": {
"index": "1",
"flags": "8963",
"promiscuous listeners": "1",
"send queue length": "0",
"send queue max length": "50",
"send queue drops": "0",
"type": "Ethernet",
"address length": "6",
"header length": "18",
"link state": "2",
"vhid": "0",
"datalen": "152",
"mtu": "1500",
"metric": "0",
"line rate": "10000000000 bit/s",
"packets received": "9008014155",
"input errors": "0",
"packets transmitted": "3724630846",
"output errors": "0",
"collisions": "0",
"bytes received": "11725192686820",
"bytes transmitted": "2489262014203",
"multicasts received": "2288794",
"multicasts transmitted": "0",
"input queue drops": "0",
"packets for unknown protocol": "0",
"HW offload capabilities": "0x0",
"uptime at attach or stat reset": "1",
"name": "WAN",
},
},
"time": 1693404742.796736,
}
)