diff --git a/py/__pycache__/prettytable.cpython-310.pyc b/py/__pycache__/prettytable.cpython-310.pyc deleted file mode 100644 index 3b1f96b..0000000 Binary files a/py/__pycache__/prettytable.cpython-310.pyc and /dev/null differ diff --git a/py/__pycache__/terminaltables.cpython-310.pyc b/py/__pycache__/terminaltables.cpython-310.pyc deleted file mode 100644 index 91f0ecd..0000000 Binary files a/py/__pycache__/terminaltables.cpython-310.pyc and /dev/null differ diff --git a/py/dates-test.py b/py/dates-test.py new file mode 100755 index 0000000..07e1648 --- /dev/null +++ b/py/dates-test.py @@ -0,0 +1,5 @@ +#!/usr/bin/python3 + +from datetime import datetime +# print (str(datetime.now().year) + "-" + str(datetime.now().month-1)) +print (datetime.now().replace(month=datetime.now().month-1).strftime('%Y-%m')) diff --git a/py/ldap-monitor.py b/py/ldap-monitor.py new file mode 100644 index 0000000..fe9e104 --- /dev/null +++ b/py/ldap-monitor.py @@ -0,0 +1,33 @@ +import json +import socket +import boto3 + +def lambda_handler(event, context): + hosts=['10.129.72.63', '10.135.72.66', '10.129.72.64', '10.135.72.67'] + port=636 + timeout_seconds=1 + test_results = 0 + for host in hosts: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(timeout_seconds) + result = sock.connect_ex((host,int(port))) + + if result == 0: + print("Host {}:{} - Up".format(host, port)) + test_results += 1 + else: + print("Host {}:{} - Down".format(host, port)) + sock.close() + + if test_results == 4: + return { + 'message' : 'Successfully connected to all LDAP servers' + } + else: + raise Exception('Not all LDAP servers can be connected!') + + return { + 'statusCode': 200, + 'body': json.dumps("Finished") + } + diff --git a/py/ldaps.py b/py/ldaps.py new file mode 100644 index 0000000..d5a1bb5 --- /dev/null +++ b/py/ldaps.py @@ -0,0 +1,13 @@ +import ldap + +LDAP_SERVER = 'ldap://192.168.86.87' +BASE_DN = 'dc=acme,dc=local' # base dn to search in +LDAP_LOGIN = 'Administrator' +LDAP_PASSWORD = 'qwerty-asdf-1234' +OBJECT_TO_SEARCH = 'userPrincipalName=Administrator@acme.local' +ATTRIBUTES_TO_SEARCH = ['memberOf'] + +connect = ldap.initialize(LDAP_SERVER) +connect.set_option(ldap.OPT_REFERRALS, 0) # to search the object and all its descendants +connect.simple_bind_s(LDAP_LOGIN, LDAP_PASSWORD) +result = connect.search_s(BASE_DN, ldap.SCOPE_SUBTREE, OBJECT_TO_SEARCH, ATTRIBUTES_TO_SEARCH) diff --git a/py/port-test.py b/py/port-test.py new file mode 100755 index 0000000..3c70800 --- /dev/null +++ b/py/port-test.py @@ -0,0 +1,15 @@ +#!/usr/bin/python3 +import socket + +hosts=['192.168.86.51', '192.168.86.53'] +port=22 +timeout_seconds=1 +for host in hosts: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(timeout_seconds) + result = sock.connect_ex((host,int(port))) + if result == 0: + print("Host {}:{} - Up".format(host, port)) + else: + print("Host {}:{} - Down".format(host, port)) + sock.close() diff --git a/test/test.txt b/test/test.txt deleted file mode 100644 index 1191247..0000000 --- a/test/test.txt +++ /dev/null @@ -1,2 +0,0 @@ -1 -2