Bladeren bron

Add support for fhem speedtest

erdoking 9 jaren geleden
bovenliggende
commit
90df064b4a

+ 2 - 2
local/share/check_mk/agents/mk_fhem

@@ -16,8 +16,8 @@ my $aref = $data->{Results};
 
 for my $device (@$aref) {
 
-        ## filter for physical devices (IODev is set) OR channel-devices
-        if (defined $device->{Attributes}{IODev} || ( defined $device->{Internals}{device} && defined $device->{Internals}{chanNo} ) ) {
+        ## filter for physical devices (IODev is set) OR channel-devices OR type speedtest
+        if (defined $device->{Attributes}{IODev} || ( defined $device->{Internals}{device} && defined $device->{Internals}{chanNo} ) || $device->{Internals}{TYPE} eq "speedtest" ) {
                 my $devicename;
 
                 ## check if device is a channel

+ 12 - 0
local/share/check_mk/checks/fhem

@@ -138,6 +138,15 @@ def check_fhem(item, params, info):
                 ('protocol',            'protocol',             '',                 '',                0,          0),
                 ('checkInterval',       'checkInterval',        's',                '',                0,          0),
                 ('sendInterval',        'sendInterval',         's',                '',                0,          0),
+                ## Speedtest
+                ('download',            'download',             'Mbit/s',           '',                1,          1),
+                ('ping',                'ping',                 'ms',               '',                1,          1),
+                ('state',               'state',                '',                 '',                0,          0),
+                ('upload',              'upload',               'Mbit/s',           '',                1,          1),
+#               ('path',                'path',                 '',                 '',                0,          0),
+
+
+
         ]:
           ## reset
           display_value = "" 
@@ -292,6 +301,9 @@ factory_settings["fhem_default_params"] = {
         "level_humidity_min"           : (50, 45),         # warn/crit for min. humidity
         "level_dewpoint_max"           : (3, 1),           # warn/crit for diff to temperatur (exp. 17°C (dewp) vs 20°C(temp))
         "level_batteryLevel_min"       : (2.1, 2.3),       # warn/crit for max. temperature
+        "level_download_min"           : (0, 0),           # warn/crit for min download (speedtest)
+        "level_upload_min"             : (0, 0),           # warn/crit for min upload (speedtest)
+        "level_ping"                   : (100, 150),       # warn/crit for ping (speedtest)
         "var_activity"                 : ("alive"),        # default for alive
         "var_contact"                  : ("ignore"),       # default for contact
         "var_dewpoint_override"        : ("true"),         # don't alert humidity if dewpoint given

+ 19 - 0
local/share/check_mk/pnp-templates/check_mk-fhem.php

@@ -125,6 +125,25 @@ if (isset($fhem_defines['ct']) ) {
         ;
 }
 
+# 7. Speedtest (down-/upload)
+if (isset($fhem_defines['download']) ) {
+   $ds_name[] = 'speedtest';
+   $opt[] = $defopt . "--title \"Speedtest\"";
+   $def[] = ""
+        . fhem_area("download",         "00ffc0", "Download",       "Mbit/s",  FALSE)
+        . fhem_area("upload",           "00c0ff", "Upload",         "Mbit/s",  FALSE)
+        ;
+}
+
+# 7. Speedtest (ping)
+if (isset($fhem_defines['ping']) ) {
+   $ds_name[] = 'speedtest_ping';
+   $opt[] = $defopt . "--title \"Speedtest Ping\"";
+   $def[] = ""
+        . fhem_area("ping",             "2b85c8", "Ping",           "ms",      FALSE)
+        ;
+}
+
 
 
 ?>

+ 48 - 0
local/share/check_mk/web/plugins/wato/fhem.py

@@ -75,6 +75,54 @@ register_check_parameters(
                           Percentage(title = _("Critical at"), unit = "V", default_value = 2.1),
                       ]
                 )),
+                ( "level_download_min",
+                  Tuple(
+                      title = _("Level for speedtest download "),
+                      help = _("You can adjust the levels before this service goes into warning/critical. Set to 0 to disable."),
+                      elements = [
+                          Percentage(title = _("Warning at"), unit = "Mbit/s", default_value = 10),
+                          Percentage(title = _("Critical at"), unit = "Mbit/s", default_value = 8),
+                      ]
+                )),
+                ( "level_upload_min",
+                  Tuple(
+                      title = _("Level for speedtest upload"),
+                      help = _("You can adjust the levels before this service goes into warning/critical. Set to 0 to disable."),
+                      elements = [
+                          Percentage(title = _("Warning at"), unit = "Mbit/s", default_value = 1.5),
+                          Percentage(title = _("Critical at"), unit = "Mbit/s", default_value = 1),
+                      ]
+                )),
+                ( "level_ping",
+                  Tuple(
+                      title = _("Level for speedtest ping"),
+                      help = _("You can adjust the levels before this service goes into warning/critical. Set to 0 to disable."),
+                      elements = [  
+                          Percentage(title = _("Warning at"), unit = "ms", default_value = 100),
+                          Percentage(title = _("Critical at"), unit = "ms", default_value = 150),
+                      ]
+                )), 
+               ("var_state",
+                 Alternative(
+                    title = _('state'),
+                    style = "dropdown",
+                    allow_empty = False,
+                    help = _("Check state of reading 'state' (default: ignore) "),
+                    elements = [
+                        FixedValue(
+                            'ok',
+                            totext = "ok",
+                            title = _("ok"),
+                        ),
+                        TextAscii(
+                            title = _("custom"),
+                            label = _("custom:"),
+                            size = 50,
+                        ),
+                   ]
+
+                )),
+
 
                 ("var_controlMode", 
                  Alternative(