From e6726e9866f10f9c1b0bc1a719d04d06fd3e84f6 Mon Sep 17 00:00:00 2001
From: Simon Delamare <simon.delamare@ens-lyon.fr>
Date: Wed, 20 May 2020 19:18:30 +0200
Subject: [PATCH] [lib] kwollect - fix issue with retired nodes

---
 .../luxembourg/clusters/granduc/granduc.json  | 66 +++++++++++++++++++
 .../lyon/clusters/sagittaire/sagittaire.json  | 22 +++++++
 lib/refrepo/input_loader.rb                   |  2 +-
 3 files changed, 89 insertions(+), 1 deletion(-)

diff --git a/data/grid5000/sites/luxembourg/clusters/granduc/granduc.json b/data/grid5000/sites/luxembourg/clusters/granduc/granduc.json
index 3ea344c662..ab44dd56cb 100644
--- a/data/grid5000/sites/luxembourg/clusters/granduc/granduc.json
+++ b/data/grid5000/sites/luxembourg/clusters/granduc/granduc.json
@@ -218,6 +218,72 @@
         "id": 37,
         "protocol": "ipmisensor"
       }
+    },
+    {
+      "description": "Input byte counter for the network device port",
+      "labels": {
+        "interface": "eth0"
+      },
+      "name": "network_ifacein_bytes_total",
+      "period": 1000,
+      "source": {
+        "protocol": "network_equipment"
+      }
+    },
+    {
+      "description": "Output byte counter for the network device port",
+      "labels": {
+        "interface": "eth0"
+      },
+      "name": "network_ifaceout_bytes_total",
+      "period": 1000,
+      "source": {
+        "protocol": "network_equipment"
+      }
+    },
+    {
+      "description": "Input byte counter for the network device port",
+      "labels": {
+        "interface": "eth1"
+      },
+      "name": "network_ifacein_bytes_total",
+      "period": 1000,
+      "source": {
+        "protocol": "network_equipment"
+      }
+    },
+    {
+      "description": "Output byte counter for the network device port",
+      "labels": {
+        "interface": "eth1"
+      },
+      "name": "network_ifaceout_bytes_total",
+      "period": 1000,
+      "source": {
+        "protocol": "network_equipment"
+      }
+    },
+    {
+      "description": "Input byte counter for the network device port",
+      "labels": {
+        "interface": "eth2"
+      },
+      "name": "network_ifacein_bytes_total",
+      "period": 1000,
+      "source": {
+        "protocol": "network_equipment"
+      }
+    },
+    {
+      "description": "Output byte counter for the network device port",
+      "labels": {
+        "interface": "eth2"
+      },
+      "name": "network_ifaceout_bytes_total",
+      "period": 1000,
+      "source": {
+        "protocol": "network_equipment"
+      }
     }
   ],
   "model": "Dell PowerEdge 1950",
diff --git a/data/grid5000/sites/lyon/clusters/sagittaire/sagittaire.json b/data/grid5000/sites/lyon/clusters/sagittaire/sagittaire.json
index c8b68315d6..f7ab6d694f 100644
--- a/data/grid5000/sites/lyon/clusters/sagittaire/sagittaire.json
+++ b/data/grid5000/sites/lyon/clusters/sagittaire/sagittaire.json
@@ -10,6 +10,28 @@
       "source": {
         "protocol": "wattmetre"
       }
+    },
+    {
+      "description": "Input byte counter for the network device port",
+      "labels": {
+        "interface": "eth1"
+      },
+      "name": "network_ifacein_bytes_total",
+      "period": 1000,
+      "source": {
+        "protocol": "network_equipment"
+      }
+    },
+    {
+      "description": "Output byte counter for the network device port",
+      "labels": {
+        "interface": "eth1"
+      },
+      "name": "network_ifaceout_bytes_total",
+      "period": 1000,
+      "source": {
+        "protocol": "network_equipment"
+      }
     }
   ],
   "model": "Sun Fire V20z",
diff --git a/lib/refrepo/input_loader.rb b/lib/refrepo/input_loader.rb
index 891f13d4bb..c1c24c151f 100644
--- a/lib/refrepo/input_loader.rb
+++ b/lib/refrepo/input_loader.rb
@@ -235,7 +235,7 @@ def add_network_metrics(h)
       cluster['metrics'] = cluster.fetch('metrics', []).reject {|m| m['name'] =~ /network_.*_bytes_total/}
 
       # for each interface of a cluster's node
-      node_uid, node = cluster['nodes'].first
+      node_uid, node = cluster['nodes'].select { |k, v| v['status'] != 'retired' }.first
       node["network_adapters"].each do |iface_uid, iface|
 
         # get switch attached to interface
-- 
GitLab