private ClusterNodeChecklistModel NodeStatus(ClusterNode node) { //ConsoleLogger.Log($"[hb] check node {node.Hostname} {node.MachineUid}"); var status = new ClusterNodeChecklistModel(); status.TargetNodeMachineUid = node.MachineUid; status.Hostname = node.Hostname; //controllo l'IP pubblico status.KnownPublicIpReach = PingStatus(node.PublicIp); if (status.KnownPublicIpReach == 1) { //ConsoleLogger.Warn($"[hb] {node.Hostname} is unreachable at its known public ip"); return(status); } //controllo antd var serviceStatus = ApiConsumer.Post(CommonString.Append(node.EntryPoint, serviceStatusPath)); if (serviceStatus == Nancy.HttpStatusCode.OK) { status.ServiceReach = 0; } //controllo se ho già salvato delle informazioni var storedNodeIps = Application.ClusterChecklist?.FirstOrDefault(_ => _.TargetNodeMachineUid == node.MachineUid)?.DiscoveredIpsReach?.Select(_ => _.IpAddress) ?? new string[0]; //controllo gli IP scoperti var nodeIps = ApiConsumer.Get <string[]>(CommonString.Append(node.EntryPoint, networkAddressPath)) ?? new string[0]; nodeIps = storedNodeIps.Union(nodeIps).Where(_ => _ != localIp).ToArray(); var ipStatusList = new ClusterNodeIpStatusModel[nodeIps.Length]; for (var n = 0; n < nodeIps.Length; n++) { var ipStatus = new ClusterNodeIpStatusModel(); ipStatus.IpAddress = nodeIps[n]; ipStatus.Status = PingStatus(nodeIps[n]); ipStatusList[n] = ipStatus; } status.DiscoveredIpsReach = ipStatusList; var uptime = ApiConsumer.GetString(CommonString.Append(node.EntryPoint, appUptimePath)); status.ApplicationUptime = uptime; //controllo stato nodo var nodeChecklist = ApiConsumer.Get <MachineStatusChecklistModel>(CommonString.Append(node.EntryPoint, machineChecklistPath)) ?? new MachineStatusChecklistModel(); status.InternetReach = nodeChecklist.InternetReach; status.InternetDnsReach = nodeChecklist.InternetDnsReach; //controllo servizio: virsh var virshStatus = ApiConsumer.Get <VirshModel>(CommonString.Append(node.EntryPoint, virshStatusPath)) ?? new VirshModel(); status.VirshService = virshStatus; return(status); }
public SshModule() : base("/ssh") { this.RequiresAuthentication(); Before += ctx => { Agent = ApiConsumer.GetString(CommonString.Append(Application.ServerUrl, "/agent")); return(null); }; Get["/authorizedkeys"] = x => { return(ApiConsumer.GetJson(CommonString.Append(Application.ServerUrl, Request.Path))); }; Get["/publickey"] = x => { return(ApiConsumer.GetJson(CommonString.Append(Application.ServerUrl, Request.Path))); }; Post["/save/authorizedkeys"] = x => { string data = Request.Form.Data; var dict = new Dictionary <string, string> { { "Data", data } }; return(ApiConsumer.Post(CommonString.Append(Application.ServerUrl, Request.Path), dict)); }; Post["/apply/authorizedkeys"] = x => { return(ApiConsumer.Post(CommonString.Append(Application.ServerUrl, Request.Path))); }; }
public static void DownloadRootServerHits() { var text = ApiConsumer.GetString("https://www.internic.net/domain/named.named"); const string namedHintsFile = "/etc/bind/named.named"; File.WriteAllText(namedHintsFile, text); RndcReload(); }
public static string Get() { try { var api = new ApiConsumer(); var ip = api.GetString("http://whatismyip.akamai.com/"); return(ip); } catch (Exception) { return(null); } }