1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-16 06:15:24 +00:00

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

This commit is contained in:
Philipp Schafft 2020-10-13 06:07:28 +00:00
parent ff34cd0522
commit 0fb71d4b98
2 changed files with 44 additions and 46 deletions

View File

@ -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>

View File

@ -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_helper_add_value_enum(maintenance, "type", type);
reportxml_node_set_attribute(resource, "type", "result");
reportxml_node_set_attribute(resource, "name", "maintenance");
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();