diff options
Diffstat (limited to 'teamspeak-multi.py')
-rwxr-xr-x | teamspeak-multi.py | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/teamspeak-multi.py b/teamspeak-multi.py index 07cf730..cf717c8 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', @@ -58,7 +58,7 @@ class TeamspeakMulti: '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', @@ -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' ] @@ -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) |