latency: Silence "no replies received" when no IPv6 connectivity
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 5 Sep 2016 11:40:20 +0000 (13:40 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 5 Sep 2016 11:40:20 +0000 (13:40 +0200)
This will just clutter the log files

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_collecty/_collectymodule.c
src/_collecty/_collectymodule.h
src/_collecty/ping.c
src/collecty/plugins/latency.py

index 25b1979..08462cb 100644 (file)
@@ -66,6 +66,10 @@ PyMODINIT_FUNC PyInit__collecty(void) {
        Py_INCREF(PyExc_PingAddHostError);
        PyModule_AddObject(m, "PingAddHostError", PyExc_PingAddHostError);
 
+       PyExc_PingNoReplyError = PyErr_NewException("_collecty.PingNoReplyError", NULL, NULL);
+       Py_INCREF(PyExc_PingNoReplyError);
+       PyModule_AddObject(m, "PingNoReplyError", PyExc_PingNoReplyError);
+
        Py_INCREF(&SensorType);
        PyModule_AddObject(m, "Sensor", (PyObject*)&SensorType);
 
index f34a314..56282f1 100644 (file)
@@ -59,6 +59,7 @@ PyObject* BlockDevice_get_temperature(PyObject* self);
 /* ping */
 PyObject* PyExc_PingError;
 PyObject* PyExc_PingAddHostError;
+PyObject* PyExc_PingNoReplyError;
 
 typedef struct {
        PyObject_HEAD
index 6ed5590..1d66e2f 100644 (file)
@@ -294,7 +294,7 @@ PyObject* Ping_ping(PingObject* self, PyObject* args, PyObject* kwds) {
        }
 
        if (self->stats.packets_rcvd == 0) {
-               PyErr_Format(PyExc_PingError, "No replies received from %s", self->host);
+               PyErr_Format(PyExc_PingNoReplyError, "No replies received from %s", self->host);
                return NULL;
        }
 
index a2c12ad..0ef70eb 100644 (file)
@@ -159,6 +159,11 @@ class LatencyObject(base.Object):
                                result += (None, None, None)
                                continue
 
+                       except collecty._collecty.PingNoReplyError:
+                               # Unknown but 100% loss
+                               result += (None, None, 1)
+                               continue
+
                        except collecty._collecty.PingError as e:
                                self.log.warning(_("Could not run latency check for %(host)s: %(msg)s") \
                                        % { "host" : self.hostname, "msg" : e })