Commit 0fb71d4b authored by Philipp Schafft's avatar Philipp Schafft 🦁

Update: Corrected dashboard generation, but still needs some more updates

parent ff34cd05
Pipeline #2189 failed with stage
......@@ -37,30 +37,28 @@
</div>
</section>
</xsl:for-each>
<xsl:for-each select="resource[@name='maintenance']">
<section class="box">
<h3 class="box_title">Maintenance</h3>
<xsl:choose>
<xsl:when test="value">
<ul class="maintenance-container">
<xsl:for-each select="value">
<li class="maintenance-level-{value[@member='type']/@value}">
<p><xsl:value-of select="text/text()" /></p>
<ul class="references">
<xsl:for-each select="reference">
<li><a href="{@href}"><xsl:value-of select="concat(translate(substring(@type, 1, 1), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), substring(@type, 2))" /></a></li>
</xsl:for-each>
</ul>
</li>
</xsl:for-each>
</ul>
</xsl:when>
<xsl:otherwise>
<p>Nothing to do.</p>
</xsl:otherwise>
</xsl:choose>
</section>
</xsl:for-each>
</xsl:for-each>
<section class="box">
<h3 class="box_title">Maintenance</h3>
<xsl:choose>
<xsl:when test="/report/incident/state/text">
<ul class="maintenance-container">
<xsl:for-each select="/report/incident">
<li class="maintenance-level-{resource[@name='maintenance']/value[@member='type']/@value}">
<p><xsl:value-of select="state/text/text()" /></p>
<ul class="references">
<xsl:for-each select="reference">
<li><a href="{@href}"><xsl:value-of select="concat(translate(substring(@type, 1, 1), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), substring(@type, 2))" /></a></li>
</xsl:for-each>
</ul>
</li>
</xsl:for-each>
</ul>
</xsl:when>
<xsl:otherwise>
<p>Nothing to do.</p>
</xsl:otherwise>
</xsl:choose>
</section>
</xsl:template>
</xsl:stylesheet>
......@@ -1349,26 +1349,35 @@ static void command_mark_log (client_t *client, source_t *source, adm
static void __reportxml_add_maintenance(reportxml_node_t *parent, const char *type, const char *text, const char *docs)
{
reportxml_node_t *maintenance = reportxml_node_new(REPORTXML_NODE_TYPE_VALUE, NULL, NULL, NULL);
reportxml_node_t *incident = reportxml_node_new(REPORTXML_NODE_TYPE_INCIDENT, NULL, NULL, NULL);
reportxml_node_t *state = reportxml_node_new(REPORTXML_NODE_TYPE_STATE, NULL, NULL, NULL);
reportxml_node_t *resource = reportxml_node_new(REPORTXML_NODE_TYPE_RESOURCE, NULL, NULL, NULL);
reportxml_node_set_attribute(maintenance, "type", "structure");
reportxml_node_add_child(parent, maintenance);
reportxml_node_add_child(parent, incident);
reportxml_node_add_child(incident, state);
reportxml_node_add_child(incident, resource);
reportxml_node_set_attribute(resource, "type", "result");
reportxml_node_set_attribute(resource, "name", "maintenance");
reportxml_helper_add_value_enum(maintenance, "type", type);
reportxml_helper_add_value_enum(resource, "type", type);
if (text)
reportxml_helper_add_text(maintenance, NULL, text);
reportxml_helper_add_text(state, NULL, text);
if (docs)
reportxml_helper_add_reference(maintenance, "documentation", docs);
reportxml_helper_add_reference(incident, "documentation", docs);
refobject_unref(maintenance);
refobject_unref(state);
refobject_unref(resource);
refobject_unref(incident);
}
static void command_dashboard (client_t *client, source_t *source, admin_format_t response)
{
ice_config_t *config = config_get_config();
reportxml_t *report = client_get_reportxml("0aa76ea1-bf42-49d1-887e-ca95fb307dc4", NULL, NULL);
reportxml_node_t *reportnode = reportxml_get_node_by_type(report, REPORTXML_NODE_TYPE_REPORT, 0);
reportxml_node_t *incident = reportxml_get_node_by_type(report, REPORTXML_NODE_TYPE_INCIDENT, 0);
reportxml_node_t *resource;
reportxml_node_t *node;
......@@ -1414,31 +1423,22 @@ static void command_dashboard (client_t *client, source_t *source, adm
reportxml_node_add_child(incident, resource);
refobject_unref(resource);
resource = reportxml_node_new(REPORTXML_NODE_TYPE_RESOURCE, NULL, NULL, NULL);
reportxml_node_set_attribute(resource, "type", "result");
reportxml_node_set_attribute(resource, "name", "maintenance");
if (config->config_problems & CONFIG_PROBLEM_HOSTNAME)
__reportxml_add_maintenance(resource, "warning", "Hostname is not set to anything useful in <hostname>.", NULL);
__reportxml_add_maintenance(reportnode, "warning", "Hostname is not set to anything useful in <hostname>.", NULL);
if (config->config_problems & CONFIG_PROBLEM_LOCATION)
__reportxml_add_maintenance(resource, "warning", "No useful location is given in <location>.", NULL);
__reportxml_add_maintenance(reportnode, "warning", "No useful location is given in <location>.", NULL);
if (config->config_problems & CONFIG_PROBLEM_ADMIN)
__reportxml_add_maintenance(resource, "warning", "No admin contact given in <admin>. YP directory support will is disabled.", NULL);
__reportxml_add_maintenance(reportnode, "warning", "No admin contact given in <admin>. YP directory support will is disabled.", NULL);
if (!has_sources)
__reportxml_add_maintenance(resource, "info", "Currently no sources are connected to this server.", NULL);
__reportxml_add_maintenance(reportnode, "info", "Currently no sources are connected to this server.", NULL);
if (has_too_many_clients) {
__reportxml_add_maintenance(resource, "warning", "More than 90% of the server's configured maximum clients are connected", NULL);
__reportxml_add_maintenance(reportnode, "warning", "More than 90% of the server's configured maximum clients are connected", NULL);
} else if (has_many_clients) {
__reportxml_add_maintenance(resource, "info", "More than 75% of the server's configured maximum clients are connected", NULL);
__reportxml_add_maintenance(reportnode, "info", "More than 75% of the server's configured maximum clients are connected", NULL);
}
reportxml_node_add_child(incident, resource);
refobject_unref(resource);
refobject_unref(incident);
config_release_config();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment