mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
CA-185019: HealthCheckService should retrieve the server capabilities
HealthCheckService retrieves system capabilities, filter them with the reports excluded in Health Check. Since Dundee, add verbosity for host status report request. Signed-off-by: Hui Zhang <hui.zhang@citrix.com>
This commit is contained in:
parent
103f6ec1c2
commit
6d2e617af7
@ -37,7 +37,9 @@ using XenAdmin.Core;
|
|||||||
using XenAPI;
|
using XenAPI;
|
||||||
using XenAdmin.Actions;
|
using XenAdmin.Actions;
|
||||||
using XenAdmin;
|
using XenAdmin;
|
||||||
|
using System.Linq;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace XenServerHealthCheck
|
namespace XenServerHealthCheck
|
||||||
{
|
{
|
||||||
@ -45,41 +47,24 @@ namespace XenServerHealthCheck
|
|||||||
{
|
{
|
||||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
// The logs which are needed by Health Check.
|
private static readonly List<string> reportExcluded =
|
||||||
private static readonly List<string> bugtoolParam =
|
new List<string>
|
||||||
new List<string>
|
|
||||||
{
|
{
|
||||||
"xen-info:2",
|
"blobs",
|
||||||
"filesystem_summarise:2",
|
"vncterm",
|
||||||
"xha-liveset:2",
|
"xapi-debug"
|
||||||
"high-availability:2",
|
};
|
||||||
"firstboot:2",
|
|
||||||
"xenserver-databases:2",
|
private static readonly Dictionary<string, int> reportWithVerbosity =
|
||||||
"multipath:2",
|
new Dictionary<string, int>
|
||||||
"disk-info:2",
|
{
|
||||||
"xenserver-logs:2",
|
{"host-crashdump-logs", 2},
|
||||||
"xenserver-install:2",
|
{"system-logs", 2},
|
||||||
"process-list:2",
|
{"tapdisk-logs", 2},
|
||||||
"xapi:2",
|
{"xapi", 2},
|
||||||
"host-crashdump-logs:2",
|
{"xcp-rrdd-plugins", 2},
|
||||||
"xapi-subprocess:2",
|
{"xenserver-install", 2},
|
||||||
"pam:2",
|
{"xenserver-logs", 2}
|
||||||
"tapdisk-logs:2",
|
|
||||||
"kernel-info:2",
|
|
||||||
"xenserver-config:2",
|
|
||||||
"xenserver-domains:2",
|
|
||||||
"device-model:2",
|
|
||||||
"hardware-info:2",
|
|
||||||
"xenopsd:2",
|
|
||||||
"loopback-devices:2",
|
|
||||||
"system-services:2",
|
|
||||||
"system-logs:2",
|
|
||||||
"network-status:2",
|
|
||||||
"CVSM:2",
|
|
||||||
"xcp-rrdd-plugins:2",
|
|
||||||
"yum:2",
|
|
||||||
"network-config:2",
|
|
||||||
"boot-loader:2"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public readonly string outputFile;
|
public readonly string outputFile;
|
||||||
@ -104,6 +89,65 @@ namespace XenServerHealthCheck
|
|||||||
if (connection == null || session == null)
|
if (connection == null || session == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Fetch the common capabilities of all hosts.
|
||||||
|
Dictionary<Host, List<string>> hostCapabilities = new Dictionary<Host, List<string>>();
|
||||||
|
foreach (Host host in connection.Cache.Hosts)
|
||||||
|
{
|
||||||
|
GetSystemStatusCapabilities action = new GetSystemStatusCapabilities(host);
|
||||||
|
action.RunExternal(session);
|
||||||
|
if (!action.Succeeded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<string> keys = new List<string>();
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
|
doc.LoadXml(action.Result);
|
||||||
|
foreach (XmlNode node in doc.GetElementsByTagName("capability"))
|
||||||
|
{
|
||||||
|
foreach (XmlAttribute a in node.Attributes)
|
||||||
|
{
|
||||||
|
if (a.Name == "key")
|
||||||
|
keys.Add(a.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hostCapabilities[host] = keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<string> combination = null;
|
||||||
|
foreach (List<string> capabilities in hostCapabilities.Values)
|
||||||
|
{
|
||||||
|
if (capabilities == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (combination == null)
|
||||||
|
{
|
||||||
|
combination = capabilities;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
combination = Helpers.ListsCommonItems<string>(combination, capabilities);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (combination == null || combination.Count <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// The list of the reports which are required in Health Check Report.
|
||||||
|
List<string> reportIncluded = combination.Except(reportExcluded).ToList();
|
||||||
|
|
||||||
|
// Verbosity works for xen-bugtool since Dundee.
|
||||||
|
if (Helpers.DundeeOrGreater(connection))
|
||||||
|
{
|
||||||
|
List<string> verbReport = new List<string>(reportWithVerbosity.Keys);
|
||||||
|
int idx = -1;
|
||||||
|
for (int x = 0; x < verbReport.Count; x++)
|
||||||
|
{
|
||||||
|
idx = reportIncluded.IndexOf(verbReport[x]);
|
||||||
|
if (idx >= 0)
|
||||||
|
{
|
||||||
|
reportIncluded[idx] = reportIncluded[idx] + ":" + reportWithVerbosity[verbReport[x]].ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure downloaded filenames are unique even for hosts with the same hostname: append a counter to the timestring
|
// Ensure downloaded filenames are unique even for hosts with the same hostname: append a counter to the timestring
|
||||||
string filepath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
|
string filepath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
|
||||||
if (Directory.Exists(filepath))
|
if (Directory.Exists(filepath))
|
||||||
@ -134,7 +178,7 @@ namespace XenServerHealthCheck
|
|||||||
}
|
}
|
||||||
|
|
||||||
HostWithStatus hostWithStatus = new HostWithStatus(host, 0);
|
HostWithStatus hostWithStatus = new HostWithStatus(host, 0);
|
||||||
SingleHostStatusAction statAction = new SingleHostStatusAction(hostWithStatus, bugtoolParam, filepath, timestring + "-" + ++i);
|
SingleHostStatusAction statAction = new SingleHostStatusAction(hostWithStatus, reportIncluded, filepath, timestring + "-" + ++i);
|
||||||
statAction.RunExternal(session);
|
statAction.RunExternal(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user