From 9931711b1c2e5a152c240017d4723a8771d840ca Mon Sep 17 00:00:00 2001
From: atoav <dh@atoav.com>
Date: Thu, 30 Apr 2020 15:44:35 +0200
Subject: [PATCH] Fix maybe w -s output?

---
 bbbmon/meetings.py | 13 ++++++++++---
 pyproject.toml     |  2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/bbbmon/meetings.py b/bbbmon/meetings.py
index 3da073a..aa50086 100644
--- a/bbbmon/meetings.py
+++ b/bbbmon/meetings.py
@@ -198,7 +198,6 @@ def meetings_twolines(config: Config, watch: int, fancy: bool):
     if watch is not None:
         click.clear()
 
-
     for i, endpoint in enumerate(config.endpoints):
         meeting = meetings[i]
 
@@ -231,8 +230,16 @@ def meetings_twolines(config: Config, watch: int, fancy: bool):
         if not fancy:
             if config.on_server:
                 # If on server get load
-                w = subprocess.run(["w | head -1  | awk '{print $10}' | sed -e 's/,$//'"], shell=True, stdout=subprocess.PIPE)
-                w = float(w.stdout.decode('utf-8').strip().replace(",", "."))
+                w = subprocess.run(["w | head -1"], shell=True, stdout=subprocess.PIPE)
+                w = w.stdout.decode('utf-8').split("load average:")
+                if len(w) != 2:
+                    w="-"
+                else:
+                    w = w[1].strip().split(" ")[0]
+                    try:
+                        w = float(w.replace(",", "."))
+                    except:
+                        w = "-"
                 lines = [
                     "{}    rec / ses    ppl    mod   vid   mic  ear  lod".format(endpoint.name[:3]),
                     "stats   {:>2} /  {:<2}    {:>3}    {:>3}   {:>3}   {:>3}  {:>3}  {:.1f}"\
diff --git a/pyproject.toml b/pyproject.toml
index 83d1f9a..646886a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "bbbmon"
-version = "0.1.19"
+version = "0.1.20"
 description = "A small CLI utility to monitor bbb usage"
 authors = ["David Huss <david.huss@hfbk-hamburg.de>"]
 maintainers = ["David Huss <david.huss@hfbk-hamburg.de>"]
-- 
GitLab