Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: support for private key protocol #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion check_synology.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,37 @@
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
port = args.port
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 = usmAesCfb128Protocol
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:
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)
Expand Down