Mercurial > servermonitor
diff ServerMonitor/Objects/Checks/SshCheck.cs @ 8:052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
author | Brad Greco <brad@bgreco.net> |
---|---|
date | Sat, 09 Mar 2019 20:14:03 -0500 |
parents | b6fe203af9d5 |
children | a36cc5c123f4 |
line wrap: on
line diff
--- a/ServerMonitor/Objects/Checks/SshCheck.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Objects/Checks/SshCheck.cs Sat Mar 09 20:14:03 2019 -0500 @@ -32,7 +32,11 @@ try { if (!Server.SshClient.IsConnected) + { + if (Server.LoginType == LoginType.PrivateKey && Server.PrivateKeyFile == null) + return Task.FromResult(Fail(string.Format("Private key '{0}' is locked or not accessible", Server.KeyFile))); Server.SshClient.Connect(); + } } catch (Exception e) { @@ -57,22 +61,6 @@ return Fail(e); } }, token); - //TaskCompletionSource<CheckResult> tcs = new TaskCompletionSource<CheckResult>(); - - ////TODO timeout - //if (!Server.SshClient.IsConnected) - // Server.SshClient.Connect(); - //using (SshCommand command = Server.SshClient.CreateCommand(Command)) - //{ - // token.Register(command.CancelAsync); - // command.BeginExecute(asyncResult => - // { - // string result = command.EndExecute(asyncResult); - // tcs.SetResult(new CheckResult(this, CheckStatus.Success, result)); - // }); - //} - - //return tcs.Task; } protected virtual List<CheckResult> ProcessCommandResult(string output, int exitCode)