From 361345762ee6c8d4d454596e38025e5ead7ae84e Mon Sep 17 00:00:00 2001 From: dommi22m Date: Tue, 22 Dec 2020 09:18:05 +0100 Subject: [PATCH 1/3] FIX: support for private key protocol --- check_synology.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/check_synology.py b/check_synology.py index 55c740d..c9365ca 100644 --- a/check_synology.py +++ b/check_synology.py @@ -11,6 +11,7 @@ parser.add_argument("hostname", help="the hostname", type=str) parser.add_argument("username", help="the snmp user name", type=str) parser.add_argument("authkey", help="the auth key", type=str) +parser.add_argument("privkeyProtocol", choices=["AES", "3DES"], help="the priv key protcol", type=str) parser.add_argument("privkey", help="the priv key", type=str) parser.add_argument("mode", help="the mode", type=str, choices=["load", "memory", "disk", "storage", "update", "status"]) parser.add_argument("-w", help="warning value for selected mode", type=int) @@ -23,16 +24,27 @@ user_name = args.username auth_key = args.authkey priv_key = args.privkey +priv_key_protocol = args.privkeyProtocol mode = args.mode warning = args.w critical = args.c state = 'OK' +privateProtocolParameter = None +if priv_key_protocol.lower() == "aes": + privateProtocolParameter = usmAesCfb128Protocol +elif priv_key_protocol.lower() == "3des": + privateProtocolParameter = usm3DESEDEPrivProtocol +else: + sys.exit(3) + + + def snmpget(oid): errorIndication, errorStatus, errorIndex, varBinds = next( getCmd(SnmpEngine(), - UsmUserData(user_name, auth_key, priv_key, authProtocol=usmHMACMD5AuthProtocol, privProtocol=usmAesCfb128Protocol), + UsmUserData(user_name, auth_key, priv_key, authProtocol=usmHMACMD5AuthProtocol, privProtocol=privateProtocolParameter), UdpTransportTarget((hostname, port)), ContextData(), ObjectType(ObjectIdentity(oid) From a1649f595890d9451616f372b783d1027ea4c368 Mon Sep 17 00:00:00 2001 From: wernerfred <20406381+wernerfred@users.noreply.github.com> Date: Tue, 16 Feb 2021 15:10:21 +0100 Subject: [PATCH 2/3] fix: add DES priv key protocol --- check_synology.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/check_synology.py b/check_synology.py index c9365ca..db910ea 100644 --- a/check_synology.py +++ b/check_synology.py @@ -11,7 +11,7 @@ parser.add_argument("hostname", help="the hostname", type=str) parser.add_argument("username", help="the snmp user name", type=str) parser.add_argument("authkey", help="the auth key", type=str) -parser.add_argument("privkeyProtocol", choices=["AES", "3DES"], help="the priv key protcol", type=str) +parser.add_argument("privkeyProtocol", choices=["AES", "DES", "3DES"], help="the priv key protcol", type=str) parser.add_argument("privkey", help="the priv key", type=str) parser.add_argument("mode", help="the mode", type=str, choices=["load", "memory", "disk", "storage", "update", "status"]) parser.add_argument("-w", help="warning value for selected mode", type=int) @@ -34,6 +34,8 @@ privateProtocolParameter = None if priv_key_protocol.lower() == "aes": privateProtocolParameter = usmAesCfb128Protocol +elif priv_key_protocol.lower() == "des": + privateProtocolParameter = usmDESPrivProtocol elif priv_key_protocol.lower() == "3des": privateProtocolParameter = usm3DESEDEPrivProtocol else: From 8c15bdf3ca388784172cfefd348f49f1627e530d Mon Sep 17 00:00:00 2001 From: wernerfred <20406381+wernerfred@users.noreply.github.com> Date: Tue, 16 Feb 2021 16:31:46 +0100 Subject: [PATCH 3/3] refactor: make optional and use default value AES --- check_synology.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_synology.py b/check_synology.py index db910ea..1d34e72 100644 --- a/check_synology.py +++ b/check_synology.py @@ -11,12 +11,12 @@ parser.add_argument("hostname", help="the hostname", type=str) parser.add_argument("username", help="the snmp user name", type=str) parser.add_argument("authkey", help="the auth key", type=str) -parser.add_argument("privkeyProtocol", choices=["AES", "DES", "3DES"], help="the priv key protcol", type=str) parser.add_argument("privkey", help="the priv key", type=str) parser.add_argument("mode", help="the mode", type=str, choices=["load", "memory", "disk", "storage", "update", "status"]) parser.add_argument("-w", help="warning value for selected mode", type=int) parser.add_argument("-c", help="critical value for selected mode", type=int) parser.add_argument("-p", help="the snmp port", type=int, dest="port", default=161) +parser.add_argument("-k", help="the priv key protocol", type=str, dest="privkeyProtocol", default="AES", choices=["AES", "DES", "3DES"]) args = parser.parse_args() hostname = args.hostname @@ -31,7 +31,7 @@ state = 'OK' -privateProtocolParameter = None +privateProtocolParameter = usmAesCfb128Protocol if priv_key_protocol.lower() == "aes": privateProtocolParameter = usmAesCfb128Protocol elif priv_key_protocol.lower() == "des":