From 64c1e6fcc11e04cdc5e55d7af41741ccfca7a9b9 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Tue, 26 Jul 2016 14:15:30 +0200 Subject: [PATCH] be more specific when logging ssh errors --- checks.d/ssh_check.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/checks.d/ssh_check.py b/checks.d/ssh_check.py index 4455505b1a..cf64354fde 100644 --- a/checks.d/ssh_check.py +++ b/checks.d/ssh_check.py @@ -53,11 +53,15 @@ def check(self, instance): conf = self._load_conf(instance) tags = ["instance:{0}-{1}".format(conf.host, conf.port)] + private_key = None try: private_key = paramiko.RSAKey.from_private_key_file(conf.private_key_file) - except Exception: - self.warning("Private key could not be found") - private_key = None + except IOError: + self.warning("Unable to find private key file: {}".format(conf.private_key_file)) + except paramiko.ssh_exception.PasswordRequiredException: + self.warning("Private key file is encrypted but no password was given") + except paramiko.ssh_exception.SSHException: + self.warning("Private key file is invalid") client = paramiko.SSHClient() if conf.add_missing_keys: