Mercurial > servermonitor
comparison 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 |
comparison
equal
deleted
inserted
replaced
7:8486ab7d2357 | 8:052aa62cb42a |
---|---|
30 protected override Task<CheckResult> ExecuteCheckAsync(CancellationToken token) | 30 protected override Task<CheckResult> ExecuteCheckAsync(CancellationToken token) |
31 { | 31 { |
32 try | 32 try |
33 { | 33 { |
34 if (!Server.SshClient.IsConnected) | 34 if (!Server.SshClient.IsConnected) |
35 { | |
36 if (Server.LoginType == LoginType.PrivateKey && Server.PrivateKeyFile == null) | |
37 return Task.FromResult(Fail(string.Format("Private key '{0}' is locked or not accessible", Server.KeyFile))); | |
35 Server.SshClient.Connect(); | 38 Server.SshClient.Connect(); |
39 } | |
36 } | 40 } |
37 catch (Exception e) | 41 catch (Exception e) |
38 { | 42 { |
39 return Task.FromResult(Fail(e)); | 43 return Task.FromResult(Fail(e)); |
40 } | 44 } |
55 catch (Exception e) | 59 catch (Exception e) |
56 { | 60 { |
57 return Fail(e); | 61 return Fail(e); |
58 } | 62 } |
59 }, token); | 63 }, token); |
60 //TaskCompletionSource<CheckResult> tcs = new TaskCompletionSource<CheckResult>(); | |
61 | |
62 ////TODO timeout | |
63 //if (!Server.SshClient.IsConnected) | |
64 // Server.SshClient.Connect(); | |
65 //using (SshCommand command = Server.SshClient.CreateCommand(Command)) | |
66 //{ | |
67 // token.Register(command.CancelAsync); | |
68 // command.BeginExecute(asyncResult => | |
69 // { | |
70 // string result = command.EndExecute(asyncResult); | |
71 // tcs.SetResult(new CheckResult(this, CheckStatus.Success, result)); | |
72 // }); | |
73 //} | |
74 | |
75 //return tcs.Task; | |
76 } | 64 } |
77 | 65 |
78 protected virtual List<CheckResult> ProcessCommandResult(string output, int exitCode) | 66 protected virtual List<CheckResult> ProcessCommandResult(string output, int exitCode) |
79 { | 67 { |
80 List<CheckResult> results = new List<CheckResult>(); | 68 List<CheckResult> results = new List<CheckResult>(); |