From 0ac83b15107c13819c1c5c7f41d4754a6312741a Mon Sep 17 00:00:00 2001 From: nico Date: Sun, 21 Oct 2018 12:17:02 +0200 Subject: README / config updates * update README to state the correct plugin name * update plugin config and correct labeling --- README.md | 2 +- teamspeak-multi.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 40c57ee..a6334cf 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ To check if the plugin is working correctly it is necessary to first instruct th telnet localhost 4949 # localhost or IP the munin-node cap multigraph list -fetch nextcloud_multi +fetch teamspeak-munin.py ``` The `list` command will return a list of all plugins currently active. This list should feature the newly activated teamspeak plugin. diff --git a/teamspeak-multi.py b/teamspeak-multi.py index 07cf730..79865d0 100755 --- a/teamspeak-multi.py +++ b/teamspeak-multi.py @@ -38,7 +38,7 @@ class TeamspeakMulti: 'down.type DERIVE', 'down.graph no', 'down.min 0', - 'up.label sent', + 'up.label bps', 'up.info total amount of bytes sent in the last 5 minutes', 'up.type DERIVE', 'up.negative down', @@ -53,7 +53,7 @@ class TeamspeakMulti: 'graph_category voip', 'graph_info graph showing the Teamspeak3 File Bandwidth In and Out', - 'ftdown.label received', + 'ftdown.label bps', 'ftdown.info total amount of bytes received for file transfers in the last 5 minutes', 'ftdown.type DERIVE', 'ftdown.graph no', @@ -88,7 +88,7 @@ class TeamspeakMulti: 'graph_category voip', 'graph_info This graph shows the number of connected users on the Teamspeak3 server', - 'user.label last 5 minutes', + 'user.label users', 'user.info users connected in the last 5 minutes', 'user.min 0' ] -- cgit v1.2.3-54-g00ecf From d4cddb1edf301c03a9988d2ba4f282f82c96883b Mon Sep 17 00:00:00 2001 From: nico Date: Tue, 23 Oct 2018 19:58:02 +0200 Subject: Connection optimization * optimize telnet connection block * updated config to say bps instead of sent * replaced for loops with list comprehension to remove clutter --- teamspeak-multi.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/teamspeak-multi.py b/teamspeak-multi.py index 79865d0..cf717c8 100755 --- a/teamspeak-multi.py +++ b/teamspeak-multi.py @@ -53,12 +53,12 @@ class TeamspeakMulti: 'graph_category voip', 'graph_info graph showing the Teamspeak3 File Bandwidth In and Out', - 'ftdown.label bps', + 'ftdown.label received', 'ftdown.info total amount of bytes received for file transfers in the last 5 minutes', 'ftdown.type DERIVE', 'ftdown.graph no', 'ftdown.min 0', - 'ftup.label sent', + 'ftup.label bps', 'ftup.info total amount of bytes sent for file transfers in the last 5 minutes', 'ftup.type DERIVE', 'ftup.negative ftdown', @@ -132,27 +132,26 @@ class TeamspeakMulti: with ts3.query.TS3Connection(host, port) as ts3conn: # will raise a TS3QueryError if response code is not 0 try: - ts3conn.login( - client_login_name=os.environ['username'], - client_login_password=os.environ['password'], - ) - except ts3.query.TS3QueryError as err: - print("Login failed:", err.resp.error["msg"]) - exit(1) + ts3conn.login(client_login_name=os.environ['username'], + client_login_password=os.environ['password']) - hostinfo = ts3conn.hostinfo().parsed + hostinfo = ts3conn.hostinfo().parsed + result = self.get_data(hostinfo[0]) - result = self.get_data(hostinfo[0]) + # for key in results print every entry in dict + [print('\n'.join(result[key])) for key in result.keys()] - for key in result.keys(): - print('\n'.join(result[key])) + except (ts3.query.TS3QueryError,KeyError) as err: + print("Login failed:", err.resp.error["msg"]) + exit(1) def main(self): - # check if first argument is config or autoconf if not fetch data + # check if any argument is given if sys.argv.__len__() >= 2: + # check if first argument is config or autoconf if not fetch data if sys.argv[1] == "config": - for key in self.config().keys(): - print('\n'.join(self.config()[key])) + # for key in config().keys() print every entry in dict + [print('\n'.join(self.config()[key])) for key in self.config().keys()] if os.environ.get('MUNIN_CAP_DIRTYCONFIG') == '1': self.run() elif sys.argv[1] == 'autoconf': @@ -166,4 +165,3 @@ class TeamspeakMulti: if __name__ == "__main__": TeamspeakMulti().main() - exit(0) -- cgit v1.2.3-54-g00ecf