Siprun commando om commando files door te sturen
This commit is contained in:
4
hoek-h10.sip
Normal file
4
hoek-h10.sip
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
LI USER,PASS
|
||||||
|
TI LMW
|
||||||
|
WN LMW,HOEK,H10,-01:00,12-02-2019,22:00,DATA
|
||||||
|
LO
|
46
siprun
46
siprun
@@ -1,8 +1,46 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import getopt
|
||||||
from lmwsip import LmwSip
|
from lmwsip import LmwSip
|
||||||
|
|
||||||
lmwsip = LmwSip("NAGIOS", "NAGIOS")
|
def usage():
|
||||||
print(lmwsip.ti())
|
print("siprun [-s] [-h <host>] [-p <port>] [<files>]")
|
||||||
print(lmwsip.value("WN", "HOEK", "H10"))
|
print("\t-s: SSL connection")
|
||||||
lmwsip.logout()
|
print("\t-h <host>: Connect to host")
|
||||||
|
print("\t-p <port>: Connect to port")
|
||||||
|
print("\t-<files>: LMW commando files")
|
||||||
|
|
||||||
|
def main():
|
||||||
|
try:
|
||||||
|
opts, args = getopt.getopt(sys.argv[1:], "sh:p:", ["help", "output="])
|
||||||
|
except getopt.GetoptError as err:
|
||||||
|
# print help information and exit:
|
||||||
|
print(err) # will print something like "option -a not recognized"
|
||||||
|
usage()
|
||||||
|
sys.exit(2)
|
||||||
|
ssl=False
|
||||||
|
host=None
|
||||||
|
port=None
|
||||||
|
for o, a in opts:
|
||||||
|
if o == "-s":
|
||||||
|
ssl=True
|
||||||
|
elif o == "-h":
|
||||||
|
host=a
|
||||||
|
elif o == "-p":
|
||||||
|
port=a
|
||||||
|
if (host==None or port==None):
|
||||||
|
print("Set host and port")
|
||||||
|
usage()
|
||||||
|
sys.exit(3)
|
||||||
|
lmwsip = LmwSip(ssl=ssl, host=host, port=port)
|
||||||
|
for cmdfile in args:
|
||||||
|
with open(cmdfile, "r") as f:
|
||||||
|
for cmd in f:
|
||||||
|
print("> [%s]" % (cmd.strip('\n')))
|
||||||
|
lmwsip.send(cmd)
|
||||||
|
print("< [%s]" % (lmwsip.recv().decode('utf-8').strip('\r')))
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
Reference in New Issue
Block a user