mirror of
https://github.com/FAUSheppy/monitoring-tools
synced 2025-12-06 03:21:35 +01:00
add teamspeak monitor
This commit is contained in:
committed by
root@atlantishq-michy-sheppy
parent
3ce74ad2ad
commit
430dc07116
35
teamspeak.py
Executable file
35
teamspeak.py
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/python3
|
||||
import ts3.query
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description='Monitor Source Server',
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser.add_argument('--host', '-H', default="127.0.0.1", help='Target Teamspeak 3 Server')
|
||||
parser.add_argument('--port', '-p', type=int, default=10011, help='Target Port')
|
||||
parser.add_argument('--user', '-u', help='User to connect as')
|
||||
parser.add_argument('--password', '-P', help='Password for user')
|
||||
parser.add_argument('--use-ssh', action='store_const', default="telnet", const="ssh",
|
||||
help='Use SSH instead of telnet')
|
||||
args = parser.parse_args()
|
||||
|
||||
userPassString = ""
|
||||
if args.user:
|
||||
if args.password:
|
||||
userPassString = "{}:{}@".format(args.user, args.password)
|
||||
else:
|
||||
userPassString = "{}@".format(args.user)
|
||||
|
||||
connectionString = "{protocol}://{userPassString}@{server}:{port}".format(protocol=args.use_ssh,
|
||||
userPassString=userPassString,
|
||||
server=args.host,
|
||||
port=args.port)
|
||||
print(connectionString)
|
||||
try:
|
||||
with ts3.query.TS3ServerConnection(connectionString) as ts3conn:
|
||||
ts3conn.exec_("use", sid=1)
|
||||
clients = ts3conn.query("clientlist", "away", "uid").all()
|
||||
except ts3.query.TS3QueryError:
|
||||
print("error id 2568: insufficient client permissions", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user