opnsense-prom-exporter/tests/common.py

471 lines
19 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():
2023-09-03 23:38:34 +02:00
# wan - rate_bits_in: 101026
# wan - rate_bits_out: 86020
# lan - rate_bits_in: 188490
# lan - rate_bits_out: 952
2023-09-01 13:27:55 +02:00
return json.dumps(
{
"wan": {
"records": [
{
"address": "0.1.2.3",
2023-09-03 23:38:34 +02:00
"rate_bits_in": 62300,
"rate_bits_out": 66100,
"rate_bits": 128400,
"cumulative_bytes_in": 15600,
"cumulative_bytes_out": 16500,
"cumulative_bytes": 32100,
"tags": [],
"details": [
{
"address": "0.1.2.3",
2023-09-03 23:38:34 +02:00
"rate": "62.3Kb",
"rate_bits": 62300,
"cumulative": "15.6KB",
"cumulative_bytes": 15600,
"tags": ["local"],
}
],
2023-09-03 23:38:34 +02:00
"rname": "fake rname value",
"rate_in": "62.3 kb",
"rate_out": "66.1 kb",
"rate": "128.4 kb",
"cumulative_in": "15.6 kb",
"cumulative_out": "16.5 kb",
"cumulative": "32.1 kb",
},
{
"address": "0.1.2.3",
2023-09-03 23:38:34 +02:00
"rate_bits_in": 36200,
"rate_bits_out": 16100,
"rate_bits": 52300,
"cumulative_bytes_in": 9060,
"cumulative_bytes_out": 4020,
"cumulative_bytes": 13080,
"tags": [],
"details": [
{
"address": "0.1.2.3",
2023-09-03 23:38:34 +02:00
"rate": "36.2Kb",
"rate_bits": 36200,
"cumulative": "9.06KB",
"cumulative_bytes": 9060,
"tags": ["local"],
}
],
2023-09-03 23:38:34 +02:00
"rname": "fake rname value",
"rate_in": "36.2 kb",
"rate_out": "16.1 kb",
"rate": "52.3 kb",
"cumulative_in": "9.06 kb",
"cumulative_out": "4.02 kb",
"cumulative": "13.08 kb",
},
{
"address": "0.1.2.3",
2023-09-03 23:38:34 +02:00
"rate_bits_in": 1790,
"rate_bits_out": 1520,
"rate_bits": 3310,
"cumulative_bytes_in": 459,
"cumulative_bytes_out": 389,
"cumulative_bytes": 848,
"tags": [],
"details": [
{
"address": "0.1.2.3",
2023-09-03 23:38:34 +02:00
"rate": "1.79Kb",
"rate_bits": 1790,
"cumulative": "459B",
"cumulative_bytes": 459,
"tags": ["local"],
}
],
2023-09-03 23:38:34 +02:00
"rname": "fake rname value",
"rate_in": "1.79 kb",
"rate_out": "1.52 kb",
"rate": "3.31 kb",
"cumulative_in": "459.0 b",
"cumulative_out": "389.0 b",
"cumulative": "848.0 b",
},
{
"address": "0.1.2.3",
2023-09-03 23:38:34 +02:00
"rate_bits_in": 512,
"rate_bits_out": 1580,
"rate_bits": 2092,
"cumulative_bytes_in": 128,
"cumulative_bytes_out": 405,
"cumulative_bytes": 533,
"tags": [],
"details": [
{
"address": "0.1.2.3",
2023-09-03 23:38:34 +02:00
"rate": "512b",
"rate_bits": 512,
"cumulative": "128B",
"cumulative_bytes": 128,
"tags": ["local"],
}
],
2023-09-03 23:38:34 +02:00
"rname": "fake rname value",
"rate_in": "512.0 b",
"rate_out": "1.58 kb",
"rate": "2.09 kb",
"cumulative_in": "128.0 b",
"cumulative_out": "405.0 b",
"cumulative": "533.0 b",
},
{
"address": "0.1.2.3",
"rate_bits_in": 0,
2023-09-03 23:38:34 +02:00
"rate_bits_out": 448,
"rate_bits": 448,
"cumulative_bytes_in": 0,
2023-09-03 23:38:34 +02:00
"cumulative_bytes_out": 112,
"cumulative_bytes": 112,
"tags": [],
"details": [
{
"address": "0.1.2.3",
"rate": "0b",
"rate_bits": 0,
"cumulative": "0B",
"cumulative_bytes": 0,
"tags": ["local"],
2023-09-03 23:38:34 +02:00
}
],
"rname": "fake rname value",
"rate_in": "0.0 b",
"rate_out": "448.0 b",
"rate": "448.0 b",
"cumulative_in": "0.0 b",
"cumulative_out": "112.0 b",
"cumulative": "112.0 b",
},
{
"address": "0.1.2.3",
"rate_bits_in": 0,
"rate_bits_out": 272,
"rate_bits": 272,
"cumulative_bytes_in": 0,
"cumulative_bytes_out": 68,
"cumulative_bytes": 68,
"tags": [],
"details": [
{
"address": "0.1.2.3",
"rate": "0b",
"rate_bits": 0,
"cumulative": "0B",
"cumulative_bytes": 0,
"tags": ["local"],
2023-09-03 23:38:34 +02:00
}
],
2023-09-03 23:38:34 +02:00
"rname": "fake rname value",
"rate_in": "0.0 b",
2023-09-03 23:38:34 +02:00
"rate_out": "272.0 b",
"rate": "272.0 b",
"cumulative_in": "0.0 b",
2023-09-03 23:38:34 +02:00
"cumulative_out": "68.0 b",
"cumulative": "68.0 b",
},
{
"address": "0.1.2.3",
"rate_bits_in": 224,
"rate_bits_out": 0,
"rate_bits": 224,
"cumulative_bytes_in": 56,
"cumulative_bytes_out": 0,
"cumulative_bytes": 56,
"tags": [],
"details": [
{
"address": "0.1.2.3",
"rate": "224b",
"rate_bits": 224,
"cumulative": "56B",
"cumulative_bytes": 56,
"tags": ["local"],
}
],
2023-09-03 23:38:34 +02:00
"rname": "fake rname value",
"rate_in": "224.0 b",
"rate_out": "0.0 b",
"rate": "224.0 b",
"cumulative_in": "56.0 b",
"cumulative_out": "0.0 b",
"cumulative": "56.0 b",
},
],
"status": "ok",
2023-09-03 23:38:34 +02:00
},
"lan": {
"records": [
{
"address": "0.1.2.3",
"rate_bits_in": 65200,
"rate_bits_out": 0,
"rate_bits": 65200,
"cumulative_bytes_in": 16270,
"cumulative_bytes_out": 0,
"cumulative_bytes": 16270,
"tags": [],
"details": [
{
"address": "0.1.2.3",
"rate": "45.3Kb",
"rate_bits": 45300,
"cumulative": "11.3KB",
"cumulative_bytes": 11300,
"tags": ["private"],
},
{
"address": "0.1.2.3",
"rate": "19.9Kb",
"rate_bits": 19900,
"cumulative": "4.97KB",
"cumulative_bytes": 4970,
"tags": ["private"],
},
],
"rname": "fake rname value",
"rate_in": "65.2 kb",
"rate_out": "0.0 b",
"rate": "65.2 kb",
"cumulative_in": "16.27 kb",
"cumulative_out": "0.0 b",
"cumulative": "16.27 kb",
},
{
"address": "0.1.2.3",
"rate_bits_in": 47900,
"rate_bits_out": 0,
"rate_bits": 47900,
"cumulative_bytes_in": 12000,
"cumulative_bytes_out": 0,
"cumulative_bytes": 12000,
"tags": ["private"],
"details": [
{
"address": "0.1.2.3",
"rate": "47.9Kb",
"rate_bits": 47900,
"cumulative": "12.0KB",
"cumulative_bytes": 12000,
"tags": [],
}
],
"rname": "fake rname value",
"rate_in": "47.9 kb",
"rate_out": "0.0 b",
"rate": "47.9 kb",
"cumulative_in": "12.0 kb",
"cumulative_out": "0.0 b",
"cumulative": "12.0 kb",
},
{
"address": "0.1.2.3",
"rate_bits_in": 36200,
"rate_bits_out": 0,
"rate_bits": 36200,
"cumulative_bytes_in": 9060,
"cumulative_bytes_out": 0,
"cumulative_bytes": 9060,
"tags": [],
"details": [
{
"address": "0.1.2.3",
"rate": "36.2Kb",
"rate_bits": 36200,
"cumulative": "9.06KB",
"cumulative_bytes": 9060,
"tags": ["private"],
}
],
"rname": "fake rname value",
"rate_in": "36.2 kb",
"rate_out": "0.0 b",
"rate": "36.2 kb",
"cumulative_in": "9.06 kb",
"cumulative_out": "0.0 b",
"cumulative": "9.06 kb",
},
{
"address": "0.1.2.3",
"rate_bits_in": 19200,
"rate_bits_out": 0,
"rate_bits": 19200,
"cumulative_bytes_in": 4814,
"cumulative_bytes_out": 0,
"cumulative_bytes": 4814,
"tags": ["private"],
"details": [
{
"address": "0.1.2.3",
"rate": "16.1Kb",
"rate_bits": 16100,
"cumulative": "4.02KB",
"cumulative_bytes": 4020,
"tags": [],
},
{
"address": "0.1.2.3",
"rate": "1.58Kb",
"rate_bits": 1580,
"cumulative": "405B",
"cumulative_bytes": 405,
"tags": [],
},
{
"address": "0.1.2.3",
"rate": "1.52Kb",
"rate_bits": 1520,
"cumulative": "389B",
"cumulative_bytes": 389,
"tags": [],
},
],
"rname": "fake rname value",
"rate_in": "19.2 kb",
"rate_out": "0.0 b",
"rate": "19.2 kb",
"cumulative_in": "4.81 kb",
"cumulative_out": "0.0 b",
"cumulative": "4.81 kb",
},
{
"address": "0.1.2.3",
"rate_bits_in": 18200,
"rate_bits_out": 0,
"rate_bits": 18200,
"cumulative_bytes_in": 4550,
"cumulative_bytes_out": 0,
"cumulative_bytes": 4550,
"tags": ["private"],
"details": [
{
"address": "0.1.2.3",
"rate": "18.2Kb",
"rate_bits": 18200,
"cumulative": "4.55KB",
"cumulative_bytes": 4550,
"tags": [],
}
],
"rname": "fake rname value",
"rate_in": "18.2 kb",
"rate_out": "0.0 b",
"rate": "18.2 kb",
"cumulative_in": "4.55 kb",
"cumulative_out": "0.0 b",
"cumulative": "4.55 kb",
},
{
"address": "0.1.2.3",
"rate_bits_in": 1790,
"rate_bits_out": 0,
"rate_bits": 1790,
"cumulative_bytes_in": 459,
"cumulative_bytes_out": 0,
"cumulative_bytes": 459,
"tags": [],
"details": [
{
"address": "0.1.2.3",
"rate": "1.79Kb",
"rate_bits": 1790,
"cumulative": "459B",
"cumulative_bytes": 459,
"tags": ["private"],
}
],
"rname": "fake rname value",
"rate_in": "1.79 kb",
"rate_out": "0.0 b",
"rate": "1.79 kb",
"cumulative_in": "459.0 b",
"cumulative_out": "0.0 b",
"cumulative": "459.0 b",
},
{
"address": "0.1.2.3",
"rate_bits_in": 0,
"rate_bits_out": 952,
"rate_bits": 952,
"cumulative_bytes_in": 0,
"cumulative_bytes_out": 238,
"cumulative_bytes": 238,
"tags": ["private"],
"details": [
{
"address": "0.1.2.3",
"rate": "0b",
"rate_bits": 0,
"cumulative": "0B",
"cumulative_bytes": 0,
"tags": ["private"],
}
],
"rname": "fake rname value",
"rate_in": "0.0 b",
"rate_out": "952.0 b",
"rate": "952.0 b",
"cumulative_in": "0.0 b",
"cumulative_out": "238.0 b",
"cumulative": "238.0 b",
},
],
"status": "ok",
},
2023-09-01 13:27:55 +02:00
}
)