From a9ce70b061a9b5d02192331ddeb977ed5229e8ce Mon Sep 17 00:00:00 2001
From: Simon Marsh <simon@sesa.me.uk>
Date: Sat, 12 Jan 2019 12:45:44 +0000
Subject: [PATCH] Fix protocol summary view when 'timeformat protocol iso long'
 is configured. 'timeformat protocol iso long' is a requirement for using
 bird_exporter with prometheus.

---
 lg.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lg.py b/lg.py
index 3ab4d2a..70af2af 100644
--- a/lg.py
+++ b/lg.py
@@ -260,7 +260,16 @@ def summary(hosts, proto="ipv4"):
                     props["table"] = split[2]
                     props["state"] = split[3]
                     props["since"] = split[4]
-                    props["info"] = ' '.join(split[5:]) if len(split) > 5 else ""
+                    if len(split) > 5:
+			# if bird is configured for 'timeformat protocol iso long'
+                        # then the 5th column contains the time, rather than info
+			match =	re.match(r'\d\d:\d\d:\d\d', split[5])
+                        if match:
+                            props["info"] = ' '.join(split[6:]) if len(split) > 6 else ""
+                        else:
+                            props["info"] = ' '.join(split[5:])
+                    else:
+                        props["info"] = ""
                     data.append(props)
                 else:
                     app.logger.warning("couldn't parse: %s", line)