Skip to content

Commit

Permalink
be more specific when logging ssh errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Massimiliano Pippi committed Jul 26, 2016
1 parent 53a66ea commit 64c1e6f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions checks.d/ssh_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 64c1e6f

Please sign in to comment.