Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Chalenko <gregory.chalenko@zabbix.com>2020-07-28 16:26:19 +0300
committerGregory Chalenko <gregory.chalenko@zabbix.com>2020-07-28 16:26:19 +0300
commit402e72fb6df163a0df46686c80d4b3aa06406abf (patch)
treea884f5d904ef3e4e09426d03c140c2971b124b44 /ui/app/controllers/CControllerHost.php
parentb40564e9eb89c43bc81f4465eb862a6aabb6071f (diff)
..F....... [ZBXNEXT-710] tab result counters php code
Diffstat (limited to 'ui/app/controllers/CControllerHost.php')
-rw-r--r--ui/app/controllers/CControllerHost.php64
1 files changed, 62 insertions, 2 deletions
diff --git a/ui/app/controllers/CControllerHost.php b/ui/app/controllers/CControllerHost.php
index dc9f63df700..d51fd4dc42f 100644
--- a/ui/app/controllers/CControllerHost.php
+++ b/ui/app/controllers/CControllerHost.php
@@ -68,8 +68,68 @@ abstract class CControllerHost extends CController {
* @return int
*/
protected function getCount(array $filter) {
- // TODO
- return 1;
+ $child_groups = [];
+
+ if ($filter['groupids']) {
+ $filter_groups = API::HostGroup()->get([
+ 'output' => ['groupid', 'name'],
+ 'groupids' => $filter['groupids'],
+ 'preservekeys' => true
+ ]);
+
+ if ($filter_groups) {
+ foreach ($filter_groups as $group) {
+ $child_groups[] = $group['name'].'/';
+ }
+ }
+ else {
+ $filter['groupids'] = [];
+ }
+ }
+
+ $groupids = null;
+
+ if ($child_groups) {
+ $filter_groups += API::HostGroup()->get([
+ 'output' => ['groupid'],
+ 'search' => ['name' => $child_groups],
+ 'startSearch' => true,
+ 'searchByAny' => true,
+ 'preservekeys' => true
+ ]);
+
+ $groupids = array_keys($filter_groups);
+ }
+
+ $config = select_config();
+
+ $count = API::Host()->get([
+ 'output' => ['hostid', 'name', 'status'],
+ 'evaltype' => $filter['evaltype'],
+ 'tags' => $filter['tags'],
+ 'inheritedTags' => true,
+ 'groupids' => $groupids,
+ 'severities' => $filter['severities'] ? $filter['severities'] : null,
+ 'withProblemsSuppressed' => $filter['severities']
+ ? (($filter['show_suppressed'] == ZBX_PROBLEM_SUPPRESSED_TRUE) ? null : false)
+ : null,
+ 'search' => [
+ 'name' => ($filter['name'] === '') ? null : $filter['name'],
+ 'ip' => ($filter['ip'] === '') ? null : $filter['ip'],
+ 'dns' => ($filter['dns'] === '') ? null : $filter['dns']
+ ],
+ 'filter' => [
+ 'status' => ($filter['status'] == -1) ? null : $filter['status'],
+ 'port' => ($filter['port'] === '') ? null : $filter['port'],
+ 'maintenance_status' => ($filter['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON)
+ ? null
+ : HOST_MAINTENANCE_STATUS_OFF,
+ ],
+ 'limit' => $config['search_limit'] + 1,
+ 'countOutput' => true
+ ]);
+
+ return $count;
}
/**