Commit 0403ad5d authored by Luiz Gustavo S. Costa's avatar Luiz Gustavo S. Costa Committed by sc979
Browse files

fix PSR-2 and code normalization (#13)

* fix PSR-2
* better comments
* missing comments update
* remove white space from the end of line
* fix html and xml files
* replace tab to space
parent 9d6a94de
<configs>
<title>Tactical Overview</title>
<author>Centreon</author>
<email>contact@centreon.com</email>
<website>http://www.centreon.com</website>
<description>This widget displays in a table the number of resources by status, also indicating the unhandled, acknowledged or downtime state. This widget is available for hosts or for services.</description>
<version>19.10.0</version>
<keywords>centreon, widget, host, monitoring, service</keywords>
<screenshot></screenshot>
<thumbnail>./widgets/tactical-overview/resources/centreon-logo.png</thumbnail>
<url>./widgets/tactical-overview/index.php</url>
<autoRefresh>10</autoRefresh>
<preferences>
<preference label="Object" name="object_type" type="list">
<option value="hosts" label="Hosts"/>
<option value="services" label="Services"/>
</preference>
<preference label="Auto Refresh" name="autoRefresh" defaultValue="30" type="integer"/>
</preferences>
<title>Tactical Overview</title>
<author>Centreon</author>
<email>contact@centreon.com</email>
<website>http://www.centreon.com</website>
<description>This widget displays in a table the number of resources by status, also indicating the unhandled, acknowledged or downtime state. This widget is available for hosts or for services.</description>
<version>19.10.0</version>
<keywords>centreon, widget, host, monitoring, service</keywords>
<screenshot></screenshot>
<thumbnail>./widgets/tactical-overview/resources/centreon-logo.png</thumbnail>
<url>./widgets/tactical-overview/index.php</url>
<autoRefresh>10</autoRefresh>
<preferences>
<preference label="Object" name="object_type" type="list">
<option value="hosts" label="Hosts"/>
<option value="services" label="Services"/>
</preference>
<preference label="Auto Refresh" name="autoRefresh" defaultValue="30" type="integer"/>
</preferences>
</configs>
<?php
/**
* Copyright 2005-2011 MERETHIS
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* Copyright 2005-2019 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
......@@ -78,8 +78,8 @@ $template = initSmartyTplForPopup($path, $template, "./", $centreon_path);
if (isset($preferences['object_type']) && $preferences['object_type'] === "hosts") {
require_once 'src/hosts_status.php';
}else if (isset($preferences['object_type']) && $preferences['object_type'] === "services") {
} elseif (isset($preferences['object_type']) && $preferences['object_type'] === "services") {
require_once 'src/services_status.php';
}else if (isset($preferences['object_type']) && $preferences['object_type'] == "") {
} elseif (isset($preferences['object_type']) && $preferences['object_type'] == "") {
require_once 'src/hosts_status.php';
}
var timeout;
jQuery(function() {
reloadWidget();
});
reloadWidget();
});
function reloadWidget() {
jQuery.ajax("./index.php", {
......
<html>
<head>
<title>tactical-overview</title>
<link href="../../Themes/Centreon-2/style.css" type="text/css"/>
<link href="../../Themes/Centreon-2/Color/blue_css.php" rel="stylesheet" text="text/css"/>
{literal}
<style type="text/css">
.ListTable {font-size:11px;border-color: #BFD0E2;}
</style>
<style>
@import url('../../Themes/Centreon-2/style.css');
</style>
{/literal}
<title>tactical-overview</title>
<link href="../../Themes/Centreon-2/style.css" type="text/css"/>
<link href="../../Themes/Centreon-2/Color/blue_css.php" rel="stylesheet" text="text/css"/>
{literal}
<style type="text/css">
.ListTable {font-size:11px;border-color: #BFD0E2;}
</style>
<style>
@import url('../../Themes/Centreon-2/style.css');
</style>
{/literal}
</head>
<body>
<div id="tactical-overview">
<table class='StyleTable ListTable'>
<tr class="listHeader">
<td class='ListColHeaderLeft'><a href="/centreon/main.php?p=20202&o=h_down&search=" target="_blank"><span class="badge host_down margin_right">{$dataDO[0].status}</span>Down</a></td>
<td class='ListColHeaderLeft'><a href="/centreon/main.php?p=20202&o=h_unreachable&search=" target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].status}</span>Unreachable</a></td>
<td class='ListColHeaderLeft'><a href="/centreon/main.php?p=20202&o=h_up&search=" target="_blank"><span class="badge host_up margin_right">{$dataUP[0].status}</span>Up</a></td>
<td class='ListColHeaderLeft'><a href="/centreon/main.php?p=20202&o=h_pending&search=" target="_blank"><span class="badge pending margin_right">{$dataPEND[0].status}</span>Pending</a></td>
</tr>
<tr class="line_ack">
<td class='ListColLeft'><a href="/centreon/main.php?p=20202&o=h_down&search=" target="_blank"><span class="badge host_down margin_right">{$dataDO[0].ack}</span>Acknowledge</a></td>
<td class='ListColLeft'><a href="/centreon/main.php?p=20202&o=h_unreachable&search=" target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].ack}</span>Acknowledge</a></td>
<td></td>
<td></td>
</tr>
<tr class ="line_downtime">
<td class='ListColLeft'><a href="/centreon/main.php?p=20202&o=h_down&search=" target="_blank"><span class="badge host_down margin_right">{$dataDO[0].down}</span>Downtimes</a></td>
<td class='ListColLeft'><a href="/centreon/main.php?p=20202&o=h_unreachable&search=" target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].down}</span>Downtimes</a></td>
<td></td>
<td></td>
</tr>
<tr class="list_two">
<td class='ListColLeft'><a href="/centreon/main.php?p=20202&o=h_unhandled&search=" target="_blank"><span class="badge host_down margin_right">{$dataDO[0].un}</span>Unhandled</a></td>
<td class='ListColLeft'><a href="/centreon/main.php?p=20202&o=h_unhandled&search=" target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].un}</span>Unhandled</a></td>
<td></td>
<td></td>
</tr>
</table>
</div>
<br></br>
<script>
var widgetId = "{$widgetId}";
var autoRefresh = "{$autoRefresh}";
</script>
<script type="text/javascript" src="../../include/common/javascript/jquery/jquery.js"></script>
<script type="text/javascript" src="../../include/common/javascript/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="../../include/common/javascript/widgetUtils.js"></script>
<script type="text/javascript" src="src/data_js.js"></script>
</script>
<div id="tactical-overview">
<table class='StyleTable ListTable'>
<tr class="listHeader">
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20202&o=h_down&search=" target="_blank"><span class="badge host_down margin_right">{$dataDO[0].status}</span>Down</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20202&o=h_unreachable&search=" target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].status}</span>Unreachable</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20202&o=h_up&search=" target="_blank"><span class="badge host_up margin_right">{$dataUP[0].status}</span>Up</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20202&o=h_pending&search=" target="_blank"><span class="badge pending margin_right">{$dataPEND[0].status}</span>Pending</a>
</td>
</tr>
<tr class="line_ack">
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=h_down&search=" target="_blank"><span class="badge host_down margin_right">{$dataDO[0].ack}</span>Acknowledge</a>
</td>
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=h_unreachable&search=" target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].ack}</span>Acknowledge</a>
</td>
<td></td>
<td></td>
</tr>
<tr class ="line_downtime">
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=h_down&search=" target="_blank"><span class="badge host_down margin_right">{$dataDO[0].down}</span>Downtimes</a>
</td>
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=h_unreachable&search=" target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].down}</span>Downtimes</a>
</td>
<td></td>
<td></td>
</tr>
<tr class="list_two">
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=h_unhandled&search=" target="_blank"><span class="badge host_down margin_right">{$dataDO[0].un}</span>Unhandled</a>
</td>
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=h_unhandled&search=" target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].un}</span>Unhandled</a>
</td>
<td></td>
<td></td>
</tr>
</table>
</div>
<br>
<script>
var widgetId = "{$widgetId}";
var autoRefresh = "{$autoRefresh}";
</script>
<script type="text/javascript" src="../../include/common/javascript/jquery/jquery.js"></script>
<script type="text/javascript" src="../../include/common/javascript/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="../../include/common/javascript/widgetUtils.js"></script>
<script type="text/javascript" src="src/data_js.js"></script>
</body>
</html>
<?php
/**
* Copyright 2005-2015 Centreon
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* Copyright 2005-2019 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
......@@ -40,51 +40,131 @@ $dataPEND = array();
$dataList = array();
$db = new CentreonDB("centstorage");
$queryDO = "SELECT SUM(CASE WHEN h.state = 1 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as status,
SUM(CASE WHEN h.acknowledged = 1 AND h.state = 1 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as ack,
SUM(CASE WHEN h.scheduled_downtime_depth = 1 AND h.state = 1 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as down
FROM hosts AS h "
.($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" .($grouplistStr != "" ? $grouplistStr : 0). ")
GROUP BY host_id) x ON x.host_id = h.host_id AND x.service_id IS NULL" : "") . ";";
$queryUN = "SELECT SUM(CASE WHEN h.state = 2 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as status,
SUM(CASE WHEN h.acknowledged = 1 AND h.state = 2 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as ack,
SUM(CASE WHEN h.state = 2 and h.enabled = 1 and h.name not like '%Module% 'and h.scheduled_downtime_depth = 1 THEN 1 ELSE 0 END) as down
FROM hosts AS h "
.($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" .($grouplistStr != "" ? $grouplistStr : 0). ")
GROUP BY host_id) x ON x.host_id = h.host_id AND x.service_id IS NULL" : "") . ";";
$queryUP = "SELECT SUM(CASE WHEN h.state = 0 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as status
FROM hosts AS h "
.($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" .($grouplistStr != "" ? $grouplistStr : 0). ")
GROUP BY host_id) x ON x.host_id = h.host_id AND x.service_id IS NULL" : "") . ";";
$queryPEND = "SELECT SUM(CASE WHEN h.state = 4 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as status
FROM hosts AS h "
.($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" .($grouplistStr != "" ? $grouplistStr : 0). ")
GROUP BY host_id) x ON x.host_id = h.host_id AND x.service_id IS NULL" : "") . ";";
$numLine = 1;
$res = $db->query($queryDO);
while ($row = $res->fetchRow()) {
$row['un'] = $row['status'] - ($row['ack'] + $row['down']);
$dataDO[] = $row;
// query for DOWN status
$res = $db->query(
"SELECT
SUM(
CASE WHEN h.state = 1
AND h.enabled = 1
AND h.name NOT LIKE '%Module%'
THEN 1 ELSE 0 END
) as status,
SUM(
CASE WHEN h.acknowledged = 1
AND h.state = 1
AND h.enabled = 1
AND h.name NOT LIKE '%Module%'
THEN 1 ELSE 0 END
) as ack,
SUM(
CASE WHEN h.scheduled_downtime_depth = 1
AND h.state = 1
AND h.enabled = 1
AND h.name NOT LIKE '%Module%'
THEN 1 ELSE 0 END
) as down
FROM hosts AS h " . (
$centreon->user->admin == 0
? "JOIN (
SELECT acl.host_id, acl.service_id
FROM centreon_acl AS acl
WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ")
GROUP BY host_id
) x ON x.host_id = h.host_id AND x.service_id IS NULL" : ""
) . ";"
);
while ($row = $res->fetch()) {
$row['un'] = $row['status'] - ($row['ack'] + $row['down']);
$dataDO[] = $row;
}
$res = $db->query($queryUN);
while ($row = $res->fetchRow()) {
$row['un'] = $row['status'] - ($row['ack'] + $row['down']);
$dataUN[] = $row;
// query for UNKNOWN status
$res = $db->query(
"SELECT
SUM(
CASE WHEN h.state = 2
AND h.enabled = 1
AND h.name NOT LIKE '%Module%'
THEN 1 ELSE 0 END
) as status,
SUM(
CASE WHEN h.acknowledged = 1
AND h.state = 2
AND h.enabled = 1
AND h.name NOT LIKE '%Module%'
THEN 1 ELSE 0 END
) as ack,
SUM(
CASE WHEN h.state = 2
AND h.enabled = 1
AND h.name NOT LIKE '%Module% '
AND h.scheduled_downtime_depth = 1
THEN 1 ELSE 0 END
) as down
FROM hosts AS h " . (
$centreon->user->admin == 0
? "JOIN (
SELECT acl.host_id, acl.service_id
FROM centreon_acl AS acl
WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ")
GROUP BY host_id
) x ON x.host_id = h.host_id AND x.service_id IS NULL" : ""
) . ";"
);
while ($row = $res->fetch()) {
$row['un'] = $row['status'] - ($row['ack'] + $row['down']);
$dataUN[] = $row;
}
$res = $db->query($queryUP);
while ($row = $res->fetchRow()) {
$dataUP[] = $row;
// query for UP status
$res = $db->query(
"SELECT
SUM(
CASE WHEN h.state = 0
AND h.enabled = 1
AND h.name NOT LIKE '%Module%'
THEN 1 ELSE 0 END
) as status
FROM hosts AS h " . (
$centreon->user->admin == 0
? "JOIN (
SELECT acl.host_id, acl.service_id
FROM centreon_acl AS acl
WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ")
GROUP BY host_id
) x ON x.host_id = h.host_id AND x.service_id IS NULL" : ""
) . ";"
);
while ($row = $res->fetch()) {
$dataUP[] = $row;
}
// query for PENDING status
$res = $db->query(
"SELECT
SUM(
CASE WHEN h.state = 4
AND h.enabled = 1
AND h.name NOT LIKE '%Module%'
THEN 1 ELSE 0 END
) as status
FROM hosts AS h " . (
$centreon->user->admin == 0
? "JOIN (
SELECT acl.host_id, acl.service_id
FROM centreon_acl AS acl
WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ")
GROUP BY host_id
) x ON x.host_id = h.host_id AND x.service_id IS NULL" : ""
) . ";"
);
$res = $db->query($queryPEND);
while ($row = $res->fetchRow()) {
$dataPEND[] = $row;
while ($row = $res->fetch()) {
$dataPEND[] = $row;
}
$numLine = 1;
$autoRefresh = $preferences['autoRefresh'];
$template->assign('preferences', $preferences);
......@@ -94,5 +174,4 @@ $template->assign('dataPEND', $dataPEND);
$template->assign('dataUP', $dataUP);
$template->assign('dataUN', $dataUN);
$template->assign('dataDO', $dataDO);
$template->display('hosts_status.ihtml');
<html>
<head>
<title>tactical-overview</title>
<link href="../../Themes/Centreon-2/style.css" type="text/css"/>
<link href="../../Themes/Centreon-2/Color/blue_css.php" rel="stylesheet" text="text/css"/>
{literal}
<style type="text/css">
.ListTable {font-size:11px;border-color: #BFD0E2;}
</style>
<style>
@import url('../../Themes/Centreon-2/style.css');
</style>
{/literal}
<title>tactical-overview</title>
<link href="../../Themes/Centreon-2/style.css" type="text/css"/>
<link href="../../Themes/Centreon-2/Color/blue_css.php" rel="stylesheet" text="text/css"/>
{literal}
<style type="text/css">
.ListTable {font-size:11px;border-color: #BFD0E2;}
</style>
<style>
@import url('../../Themes/Centreon-2/style.css');
</style>
{/literal}
</head>
<body>
<div id="tactical-overview"></div>
<div id="tactical-overview">
<table class='StyleTable ListTable'>
<tr class="ListHeader">
<td class='ListColHeaderLeft'><a href="/centreon/main.php?p=20201&o=svc_critical&search=" target="_blank"><span class="badge service_critical margin_right">{$dataCRI[0].status}</span>Critical</a></td>
<td class='ListColHeaderLeft'><a href="/centreon/main.php?p=20201&o=svc_warning&search=" target="_blank"><span class="badge service_warning margin_right">{$dataWA[0].status}</span>Warning</a></td>
<td class='ListColHeaderLeft'><a href="/centreon/main.php?p=20201&o=svc_unknown&search=" target="_blank"><span class="badge service_unknown margin_right">{$dataUNK[0].status}</span>Unknown</a></td>
<td class='ListColHeaderLeft'><a href="/centreon/main.php?p=20201&o=svc_ok&search=" target="_blank"><span class="badge service_ok margin_right">{$dataOK[0].status}</span>Ok</a></td>
<td class='ListColHeaderLeft'><a href="/centreon/main.php?p=20201&o=svc_pending&search=" target="_blank"><span class="badge pending margin_right">{$dataPEND[0].status}</span>Pending</a></td>
</tr>
<tr class="line_ack">
<td class='ListColLeft'><span class="badge service_critical margin_right">{$dataCRI[0].ack}</span>Acknowledge</td>
<td class='ListColLeft'><span class="badge service_warning margin_right">{$dataWA[0].ack}</span>Acknowledge</td>
<td class='ListColLeft'><span class="badge service_unknown margin_right">{$dataUNK[0].ack}</span>Acknowledge</td>
<td></td>
<td></td>
</tr>
<tr class ="line_downtime">
<td class='ListColLeft'><span class="badge service_critical margin_right">{$dataCRI[0].down}</span>Downtimes</td>
<td class='ListColLeft'><span class="badge service_warning margin_right">{$dataWA[0].down}</span>Downtimes</td>
<td class='ListColLeft'><span class="badge service_unknown margin_right">{$dataUNK[0].down}</span>Downtimes</td>
<td></td>
<td></td>
</tr>
<tr class="list_two">
<td class='ListColLeft'><a href="/centreon/main.php?p=20202&o=svc_unhandled&search=" target="_blank"><span class="badge service_critical margin_right">{$dataCRI[0].un}</span>Unhandled</a></td>
<td class='ListColLeft'><a href="/centreon/main.php?p=20202&o=svc_unhandled&search=" target="_blank"><span class="badge service_warning margin_right">{$dataWA[0].un}</span>Unhandled</a></td>
<td class='ListColLeft'><a href="/centreon/main.php?p=20202&o=svc_unhandled&search=" target="_blank"><span class="badge service_unknown margin_right">{$dataUNK[0].un}</span>Unhandled</a></td>
<td></td>
<td></td>
</tr>
<tr class="list_one">
<td class="ListColLeft"><span class="badge service_critical margin_right">{$dataCRI[0].pb}</span>Problem on host</td>
<td class="ListColLeft"><span class="badge service_warning margin_right">{$dataWA[0].pb}</span>Problem on host</td>
<td class="ListColLeft"><span class="badge service_unknown margin_right">{$dataUNK[0].pb}</span>Problem on host</td>
<td></td>
<td></td>
</tr>
<tr class="ListHeader">
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20201&o=svc_critical&search=" target="_blank"><span class="badge service_critical margin_right">{$dataCRI[0].status}</span>Critical</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20201&o=svc_warning&search=" target="_blank"><span class="badge service_warning margin_right">{$dataWA[0].status}</span>Warning</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20201&o=svc_unknown&search=" target="_blank"><span class="badge service_unknown margin_right">{$dataUNK[0].status}</span>Unknown</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20201&o=svc_ok&search=" target="_blank"><span class="badge service_ok margin_right">{$dataOK[0].status}</span>Ok</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20201&o=svc_pending&search=" target="_blank"><span class="badge pending margin_right">{$dataPEND[0].status}</span>Pending</a>
</td>
</tr>
<tr class="line_ack">
<td class='ListColLeft'><span class="badge service_critical margin_right">{$dataCRI[0].ack}</span>Acknowledge</td>
<td class='ListColLeft'><span class="badge service_warning margin_right">{$dataWA[0].ack}</span>Acknowledge</td>
<td class='ListColLeft'><span class="badge service_unknown margin_right">{$dataUNK[0].ack}</span>Acknowledge</td>
<td></td>
<td></td>
</tr>
<tr class ="line_downtime">
<td class='ListColLeft'><span class="badge service_critical margin_right">{$dataCRI[0].down}</span>Downtimes</td>
<td class='ListColLeft'><span class="badge service_warning margin_right">{$dataWA[0].down}</span>Downtimes</td>
<td class='ListColLeft'><span class="badge service_unknown margin_right">{$dataUNK[0].down}</span>Downtimes</td>
<td></td>
<td></td>
</tr>
<tr class="list_two">
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=svc_unhandled&search=" target="_blank"><span class="badge service_critical margin_right">{$dataCRI[0].un}</span>Unhandled</a>
</td>
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=svc_unhandled&search=" target="_blank"><span class="badge service_warning margin_right">{$dataWA[0].un}</span>Unhandled</a>
</td>
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=svc_unhandled&search=" target="_blank"><span class="badge service_unknown margin_right">{$dataUNK[0].un}</span>Unhandled</a>
</td>
<td></td>
<td></td>
</tr>
<tr class="list_one">
<td class="ListColLeft"><span class="badge service_critical margin_right">{$dataCRI[0].pb}</span>Problem on host</td>
<td class="ListColLeft"><span class="badge service_warning margin_right">{$dataWA[0].pb}</span>Problem on host</td>
<td class="ListColLeft"><span class="badge service_unknown margin_right">{$dataUNK[0].pb}</span>Problem on host</td>
<td></td>
<td></td>
</tr>
</table>
<script>
var widgetId = "{$widgetId}";
var autoRefresh = "{$autoRefresh}";
</script>
<script type="text/javascript" src="../../include/common/javascript/jquery/jquery.js"></script>
<script type="text/javascript" src="../../include/common/javascript/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="../../include/common/javascript/widgetUtils.js"></script>
<script type="text/javascript" src="src/data_js.js"></script>
</script>
</div>
<script>
var widgetId = "{$widgetId}";
var autoRefresh = "{$autoRefresh}";
</script>
<script type="text/javascript" src="../../include/common/javascript/jquery/jquery.js"></script>
<script type="text/javascript" src="../../include/common/javascript/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="../../include/common/javascript/widgetUtils.js"></script>
<script type="text/javascript" src="src/data_js.js"></script>
</body>
</html>
<?php
/**
* Copyright 2005-2015 Centreon
* Centreon is developped by : Julien Mathis AND Romain Le Merlus under
* Copyright 2005-2019 Centreon
* Centreon is developed by : Julien Mathis AND Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
......@@ -40,76 +40,236 @@ $dataUNK = array();
$dataPEND = array();
$db = new CentreonDB("centstorage");
$queryCRI = "SELECT SUM(CASE WHEN s.state = 2 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS status,
SUM(CASE WHEN s.acknowledged = 1 AND s.state = 2 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS ack,
SUM(CASE WHEN s.scheduled_downtime_depth = 1 AND s.state = 2 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS down,
SUM(CASE WHEN s.state = 2 AND (h.state = 1 or h.state = 4 or h.state = 2) AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' then 1 else 0 END) AS pb,
SUM(CASE WHEN s.state = 2 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' AND s.acknowledged = 0 AND s.scheduled_downtime_depth = 0 AND h.state = 0 THEN 1 ELSE 0 END) AS un
FROM services AS s
LEFT JOIN hosts AS h ON h.host_id = s.host_id "
.($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" .($grouplistStr != "" ? $grouplistStr : 0). ")
GROUP BY host_id,service_id) x ON x.host_id = h.host_id AND x.service_id = s.service_id" : "") . ";";
$queryWA = "SELECT SUM(CASE WHEN s.state = 1 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS status,
SUM(CASE WHEN s.acknowledged = 1 AND s.state = 1 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS ack,
SUM(CASE WHEN s.scheduled_downtime_depth > 0 AND s.state = 1 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS down,
SUM(CASE WHEN s.state = 1 AND (h.state = 1 or h.state = 4 or h.state = 2) AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' then 1 else 0 END) AS pb,
SUM(CASE WHEN s.state = 1 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' AND s.acknowledged = 0 AND s.scheduled_downtime_depth = 0 AND h.state = 0 THEN 1 ELSE 0 END) AS un
FROM services AS s
LEFT JOIN hosts AS h ON h.host_id = s.host_id "
.($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" .($grouplistStr != "" ? $grouplistStr : 0). ")
GROUP BY host_id,service_id) x ON x.host_id = h.host_id AND x.service_id = s.service_id" : "") . ";";
$queryOK = "SELECT SUM(CASE WHEN s.state = 0 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS status
FROM services AS s
LEFT JOIN hosts AS h ON h.host_id = s.host_id "
.($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" .($grouplistStr != "" ? $grouplistStr : 0). ")
GROUP BY host_id,service_id) x ON x.host_id = h.host_id AND x.service_id = s.service_id" : "") . ";";
$queryPEND = "SELECT SUM(CASE WHEN s.state = 4 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS status
FROM services AS s
LEFT JOIN hosts AS h ON h.host_id = s.host_id "
.($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" .($grouplistStr != "" ? $grouplistStr : 0). ")
GROUP BY host_id,service_id) x ON x.host_id = h.host_id AND x.service_id = s.service_id" : "") . ";";
$queryUNK = "SELECT SUM(CASE WHEN s.state = 3 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS status,
SUM(CASE WHEN s.acknowledged = 1 AND s.state = 3 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS ack,
SUM(CASE WHEN s.scheduled_downtime_depth > 0 AND s.state = 3 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS down,
SUM(CASE WHEN s.state = 3 AND (h.state = 1 or h.state = 4 or h.state = 2) AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' then 1 else 0 END) AS pb,
SUM(CASE WHEN s.state = 3 AND s.enabled = 1 AND h.enabled = 1 AND h.name not like '%Module%' AND s.acknowledged = 0 AND s.scheduled_downtime_depth = 0 AND h.state = 0 THEN 1 ELSE 0 END) AS un
FROM services AS s
LEFT JOIN hosts AS h ON h.host_id = s.host_id "
.($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" .($grouplistStr != "" ? $grouplistStr : 0).")
GROUP BY host_id,service_id) x ON x.host_id = h.host_id AND x.service_id = s.service_id" : "") . ";";
$numLine = 1;
$res = $db->query($queryCRI);
while ($row = $res->fetchRow()) {
$dataCRI[] = $row;
// query for CRITICAL state
$res = $db->query(
"SELECT
SUM(
CASE WHEN s.state = 2
AND s.enabled = 1
AND h.enabled = 1
AND h.name NOT LIKE '%Module%'
THEN 1 ELSE 0 END
) AS status,
SUM(
CASE WHEN s.acknowledged = 1
AND s.state = 2
AND s.enabled = 1
AND h.enabled = 1
AND h.name NOT LIKE '%Module%'
THEN 1 ELSE 0 END
) AS ack,