From 6f6d6d7d8fc91534c8c23a42fa248557e7d26b04 Mon Sep 17 00:00:00 2001 From: Joe Mordica Date: Tue, 6 Feb 2018 10:53:44 -0600 Subject: [PATCH] small update to cope with larger call volume This is really to avoid the plugin returning a `Execution error: too many values to unpack` when call volume is high. --- nixstatsagent/plugins/asterisk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixstatsagent/plugins/asterisk.py b/nixstatsagent/plugins/asterisk.py index 4d95304..f4ce72f 100644 --- a/nixstatsagent/plugins/asterisk.py +++ b/nixstatsagent/plugins/asterisk.py @@ -3,13 +3,13 @@ import plugins import subprocess -### You need to add `nixstats ALL=(ALL) NOPASSWD: /usr/sbin/asterisk` to /etc/sudoers in order for this to work + class Plugin(plugins.BasePlugin): __name__ = 'asterisk' def run(self, *unused): p = subprocess.Popen("sudo asterisk -rx 'core show calls' | grep 'active' | cut -f1 -d ' '", stdout=subprocess.PIPE, shell=True) - p, err = p.communicate()[0].decode('utf-8') + p = p.communicate()[0].decode('utf-8').replace("\n", "") p = { "calls": p } return p