Skip to content

Commit 99dab54

Browse files
committed
1 parent 296ec15 commit 99dab54

File tree

5 files changed

+235
-12
lines changed

5 files changed

+235
-12
lines changed

container/bin/dev.php

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44
$fritz_user = $_ENV["FRITZBOX_USER"];
55
$fritz_password = $_ENV["FRITZBOX_PASSWD"];
66

7+
function calcAvg($listNumbers) {
8+
$numbers = explode(',', $listNumbers);
9+
10+
$sum = 0;
11+
$countBlocks = count($numbers);
12+
13+
foreach ($numbers as $block) {
14+
$sum += array_sum(explode(' ', $block));
15+
}
16+
17+
if ($countBlocks > 0) {
18+
$avg = $sum / $countBlocks;
19+
return $avg;
20+
} else {
21+
return "Keine Zahlen vorhanden.";
22+
}
23+
}
24+
725
## traffic stats wam
826
$client = new SoapClient(
927
null,
@@ -28,14 +46,27 @@
2846
'location' => "http://".$fritzbox_ip.":49000/upnp/control/wancommonifconfig1",
2947
'uri' => "urn:dslforum-org:service:WANCommonInterfaceConfig:1",
3048
'noroot' => True,
31-
'login' => $fritz_user,
32-
'password' => $fritz_password
49+
'login' => $fritz_user,
50+
'password' => $fritz_password
3351
)
3452
);
3553
$commonLinkProperties = $client->GetCommonLinkProperties();
36-
print($hostname . " layer1DownstreamCurrentUtilization " . $commonLinkProperties["NewX_AVM-DE_DownstreamCurrentUtilization"] . "\n");
37-
print($hostname . " layer1UpstreamCurrentUtilization " . $commonLinkProperties["NewX_AVM-DE_UpstreamCurrentUtilization"] . "\n");
54+
print($hostname . " layer1DownstreamCurrentUtilization " . calcAvg($commonLinkProperties["NewX_AVM-DE_DownstreamCurrentUtilization"]) . "\n");
55+
print($hostname . " layer1UpstreamCurrentUtilization " . calcAvg($commonLinkProperties["NewX_AVM-DE_UpstreamCurrentUtilization"]) . "\n");
3856

57+
# Routers informations
58+
$client = new SoapClient(
59+
null,
60+
array(
61+
'location' => "http://".$fritzbox_ip.":49000/upnp/control/lanhostconfigmgm",
62+
'uri' => "urn:dslforum-org:service:LANHostConfigManagement:1",
63+
'noroot' => True,
64+
'login' => $fritz_user,
65+
'password' => $fritz_password
66+
)
67+
);
68+
$RoutersIPList = $client->GetInfo();
69+
print($hostname . " ipAddressFromRouter " . $RoutersIPList["NewIPRouters"] . "\n");
3970

4071
## wan status
4172
$client = new SoapClient(
@@ -49,6 +80,10 @@
4980
$status = $client->GetStatusInfo();
5081
$externalIPAddress = $client->GetExternalIPAddress();
5182

83+
if (empty($externalIPAddress)) {
84+
$externalIPAddress = "not configured (check ipAddressFromRouter value)";
85+
}
86+
5287
print($hostname . " connectionStatus " . $status["NewConnectionStatus"] . "\n");
5388
print($hostname . " uptime " . $status["NewUptime"] . "\n");
5489
print($hostname . " externalIPAddress " . $externalIPAddress . "\n");

container/bin/status.php

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
$fritz_user = $_ENV["FRITZBOX_USER"];
55
$fritz_password = $_ENV["FRITZBOX_PASSWD"];
66

7-
## traffic stats wam
7+
# ---------------------------------------------------------------------------------------------------------------------------------
8+
# - Traffic Stats from WAN
9+
# ---------------------------------------------------------------------------------------------------------------------------------
810
$client = new SoapClient(
911
null,
1012
array(
@@ -20,10 +22,26 @@
2022
print($hostname . " layer1UpstreamMaxBitRate " . $commonLinkProperties["NewLayer1UpstreamMaxBitRate"] . "\n");
2123
print($hostname . " layer1DownstreamMaxBitRate " . $commonLinkProperties["NewLayer1DownstreamMaxBitRate"] . "\n");
2224
print($hostname . " physicalLinkStatus " . $commonLinkProperties["NewPhysicalLinkStatus"] . "\n");
23-
# print($hostname . " layer1DownstreamCurrentUtilization " . $commonLinkProperties["NewLayer1DownstreamCurrentUtilization"] . "\n");
24-
# print($hostname . " layer1UpstreamCurrentUtilization " . $commonLinkProperties["NewLayer1UpstreamCurrentUtilization"] . "\n");
2525

26-
## wan status
26+
# ---------------------------------------------------------------------------------------------------------------------------------
27+
# - Routers Informations: Internal IP Address List
28+
# ---------------------------------------------------------------------------------------------------------------------------------
29+
$client = new SoapClient(
30+
null,
31+
array(
32+
'location' => "http://".$fritzbox_ip.":49000/upnp/control/lanhostconfigmgm",
33+
'uri' => "urn:dslforum-org:service:LANHostConfigManagement:1",
34+
'noroot' => True,
35+
'login' => $fritz_user,
36+
'password' => $fritz_password
37+
)
38+
);
39+
$RoutersIPList = $client->GetInfo();
40+
print($hostname . " ipAddressFromRouter " . $RoutersIPList["NewIPRouters"] . "\n");
41+
42+
# ---------------------------------------------------------------------------------------------------------------------------------
43+
# - WAN Status
44+
# ---------------------------------------------------------------------------------------------------------------------------------
2745
$client = new SoapClient(
2846
null,
2947
array(
@@ -35,12 +53,18 @@
3553
$status = $client->GetStatusInfo();
3654
$externalIPAddress = $client->GetExternalIPAddress();
3755

56+
if (empty($externalIPAddress)) {
57+
$externalIPAddress = "not configured (check ipAddressFromRouter value)";
58+
}
59+
3860
print($hostname . " connectionStatus " . $status["NewConnectionStatus"] . "\n");
3961
print($hostname . " uptime " . $status["NewUptime"] . "\n");
4062
print($hostname . " externalIPAddress " . $externalIPAddress . "\n");
4163

4264
!$fritz_password && exit(0);
43-
## software version
65+
# ---------------------------------------------------------------------------------------------------------------------------------
66+
# - Router Informations: Software Version
67+
# ---------------------------------------------------------------------------------------------------------------------------------
4468
$client = new SoapClient(
4569
null,
4670
array(
@@ -54,7 +78,9 @@
5478
$info = $client->GetInfo();
5579
print($hostname . " softwareVersion " . $info['NewSoftwareVersion'] . "\n");
5680

57-
## get some informations about connected wifi devices
81+
# ---------------------------------------------------------------------------------------------------------------------------------
82+
# - Informations about connected WiFi Network Devices
83+
# ---------------------------------------------------------------------------------------------------------------------------------
5884
$client = new SoapClient(
5985
null,
6086
array(
@@ -80,8 +106,11 @@
80106

81107
array_push($macs, ["{#MAC}" => $mac]);
82108
}
83-
#send discover wifi devices
109+
110+
# ---------------------------------------------------------------------------------------------------------------------------------
111+
# - Discoverd WiFi Devices
112+
# ---------------------------------------------------------------------------------------------------------------------------------
84113
print($hostname . " associatedDeviceDiscovery " . json_encode(["data" => $macs]) . "\n");
85-
#send wifi devices stats
86114
print($wifi_stats);
115+
87116
?>

templates/template_avm_fritzbox.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,29 @@
6161
}
6262
]
6363
},
64+
{
65+
"uuid": "5b5519767b204be5bae201b15d757dcc",
66+
"name": "ipAddressFromRouter",
67+
"type": "TRAP",
68+
"key": "ipAddressFromRouter",
69+
"delay": "0",
70+
"trends": "0",
71+
"value_type": "TEXT"
72+
},
73+
{
74+
"uuid": "261aae65c5704624968160dafe4597e8",
75+
"name": "layer1DownstreamCurrentUtilization",
76+
"type": "TRAP",
77+
"key": "layer1DownstreamCurrentUtilization",
78+
"delay": "0",
79+
"units": "Bit",
80+
"tags": [
81+
{
82+
"tag": "Application",
83+
"value": "status"
84+
}
85+
]
86+
},
6487
{
6588
"uuid": "61c7d8eea5694c90982f66e239c19d5c",
6689
"name": "layer1DownstreamMaxBitRate",
@@ -75,6 +98,20 @@
7598
}
7699
]
77100
},
101+
{
102+
"uuid": "9de8132c71a94ca2b07ca9439be12056",
103+
"name": "layer1UpstreamCurrentUtilization",
104+
"type": "TRAP",
105+
"key": "layer1UpstreamCurrentUtilization",
106+
"delay": "0",
107+
"units": "Bit",
108+
"tags": [
109+
{
110+
"tag": "Application",
111+
"value": "status"
112+
}
113+
]
114+
},
78115
{
79116
"uuid": "61374ee12c294ddebdc0a9dd532f1458",
80117
"name": "layer1UpstreamMaxBitRate",
@@ -315,6 +352,29 @@
315352
}
316353
}
317354
]
355+
},
356+
{
357+
"uuid": "fb30d5bbb5584287a8a3ce989e80818a",
358+
"name": "Traffic Graph Layer 1 Utilization",
359+
"graph_items": [
360+
{
361+
"color": "199C0D",
362+
"calc_fnc": "ALL",
363+
"item": {
364+
"host": "Template AVM FritzBox Router",
365+
"key": "layer1DownstreamCurrentUtilization"
366+
}
367+
},
368+
{
369+
"sortorder": "1",
370+
"color": "F63100",
371+
"calc_fnc": "ALL",
372+
"item": {
373+
"host": "Template AVM FritzBox Router",
374+
"key": "layer1UpstreamCurrentUtilization"
375+
}
376+
}
377+
]
318378
}
319379
]
320380
}

templates/template_avm_fritzbox.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,29 @@
6161
</tag>
6262
</tags>
6363
</item>
64+
<item>
65+
<uuid>5b5519767b204be5bae201b15d757dcc</uuid>
66+
<name>ipAddressFromRouter</name>
67+
<type>TRAP</type>
68+
<key>ipAddressFromRouter</key>
69+
<delay>0</delay>
70+
<trends>0</trends>
71+
<value_type>TEXT</value_type>
72+
</item>
73+
<item>
74+
<uuid>261aae65c5704624968160dafe4597e8</uuid>
75+
<name>layer1DownstreamCurrentUtilization</name>
76+
<type>TRAP</type>
77+
<key>layer1DownstreamCurrentUtilization</key>
78+
<delay>0</delay>
79+
<units>Bit</units>
80+
<tags>
81+
<tag>
82+
<tag>Application</tag>
83+
<value>status</value>
84+
</tag>
85+
</tags>
86+
</item>
6487
<item>
6588
<uuid>61c7d8eea5694c90982f66e239c19d5c</uuid>
6689
<name>layer1DownstreamMaxBitRate</name>
@@ -75,6 +98,20 @@
7598
</tag>
7699
</tags>
77100
</item>
101+
<item>
102+
<uuid>9de8132c71a94ca2b07ca9439be12056</uuid>
103+
<name>layer1UpstreamCurrentUtilization</name>
104+
<type>TRAP</type>
105+
<key>layer1UpstreamCurrentUtilization</key>
106+
<delay>0</delay>
107+
<units>Bit</units>
108+
<tags>
109+
<tag>
110+
<tag>Application</tag>
111+
<value>status</value>
112+
</tag>
113+
</tags>
114+
</item>
78115
<item>
79116
<uuid>61374ee12c294ddebdc0a9dd532f1458</uuid>
80117
<name>layer1UpstreamMaxBitRate</name>
@@ -316,5 +353,28 @@
316353
</graph_item>
317354
</graph_items>
318355
</graph>
356+
<graph>
357+
<uuid>fb30d5bbb5584287a8a3ce989e80818a</uuid>
358+
<name>Traffic Graph Layer 1 Utilization</name>
359+
<graph_items>
360+
<graph_item>
361+
<color>199C0D</color>
362+
<calc_fnc>ALL</calc_fnc>
363+
<item>
364+
<host>Template AVM FritzBox Router</host>
365+
<key>layer1DownstreamCurrentUtilization</key>
366+
</item>
367+
</graph_item>
368+
<graph_item>
369+
<sortorder>1</sortorder>
370+
<color>F63100</color>
371+
<calc_fnc>ALL</calc_fnc>
372+
<item>
373+
<host>Template AVM FritzBox Router</host>
374+
<key>layer1UpstreamCurrentUtilization</key>
375+
</item>
376+
</graph_item>
377+
</graph_items>
378+
</graph>
319379
</graphs>
320380
</zabbix_export>

templates/template_avm_fritzbox.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ zabbix_export:
4040
tags:
4141
- tag: Application
4242
value: status
43+
- uuid: 5b5519767b204be5bae201b15d757dcc
44+
name: ipAddressFromRouter
45+
type: TRAP
46+
key: ipAddressFromRouter
47+
delay: '0'
48+
trends: '0'
49+
value_type: TEXT
50+
- uuid: 261aae65c5704624968160dafe4597e8
51+
name: layer1DownstreamCurrentUtilization
52+
type: TRAP
53+
key: layer1DownstreamCurrentUtilization
54+
delay: '0'
55+
units: Bit
56+
tags:
57+
- tag: Application
58+
value: status
4359
- uuid: 61c7d8eea5694c90982f66e239c19d5c
4460
name: layer1DownstreamMaxBitRate
4561
type: TRAP
@@ -49,6 +65,15 @@ zabbix_export:
4965
tags:
5066
- tag: Application
5167
value: status
68+
- uuid: 9de8132c71a94ca2b07ca9439be12056
69+
name: layer1UpstreamCurrentUtilization
70+
type: TRAP
71+
key: layer1UpstreamCurrentUtilization
72+
delay: '0'
73+
units: Bit
74+
tags:
75+
- tag: Application
76+
value: status
5277
- uuid: 61374ee12c294ddebdc0a9dd532f1458
5378
name: layer1UpstreamMaxBitRate
5479
type: TRAP
@@ -205,3 +230,17 @@ zabbix_export:
205230
item:
206231
host: 'Template AVM FritzBox Router'
207232
key: totalBytesSentRate
233+
- uuid: fb30d5bbb5584287a8a3ce989e80818a
234+
name: 'Traffic Graph Layer 1 Utilization'
235+
graph_items:
236+
- color: 199C0D
237+
calc_fnc: ALL
238+
item:
239+
host: 'Template AVM FritzBox Router'
240+
key: layer1DownstreamCurrentUtilization
241+
- sortorder: '1'
242+
color: F63100
243+
calc_fnc: ALL
244+
item:
245+
host: 'Template AVM FritzBox Router'
246+
key: layer1UpstreamCurrentUtilization

0 commit comments

Comments
 (0)