예제 #1
1
 public function bodyToString()
 {
     $this->cleanItems();
     $total = 0;
     // fetch accessible host ids
     $hosts = API::Host()->get(array('nodeids' => get_current_nodeid(true), 'output' => array('hostid'), 'preservekeys' => true));
     $hostIds = array_keys($hosts);
     if (remove_nodes_from_id($this->groupid) > 0) {
         $cond_from = ',hosts_groups hg';
         $cond_where = ' AND hg.hostid=h.hostid AND hg.groupid=' . zbx_dbstr($this->groupid);
     } else {
         $cond_from = '';
         $cond_where = andDbNode('h.hostid', $this->nodeid);
     }
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_TRUE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $avail = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_FALSE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $notav = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_UNKNOWN . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $uncn = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $node = get_node_by_nodeid($this->nodeid);
     $header_str = _('Hosts info') . SPACE;
     if ($node > 0) {
         $header_str .= '(' . $node['name'] . ')' . SPACE;
     }
     if (remove_nodes_from_id($this->groupid) > 0) {
         $group = get_hostgroup_by_groupid($this->groupid);
         $header_str .= _('Group') . SPACE . '"' . $group['name'] . '"';
     } else {
         $header_str .= _('All groups');
     }
     $header = new CCol($header_str, 'header');
     if ($this->style == STYLE_HORISONTAL) {
         $header->setColspan(4);
     }
     $this->addRow($header);
     $avail = new CCol($avail . '  ' . _('Available'), 'avail');
     $notav = new CCol($notav . '  ' . _('Not available'), 'notav');
     $uncn = new CCol($uncn . '  ' . _('Unknown'), 'uncn');
     $total = new CCol($total . '  ' . _('Total'), 'total');
     if ($this->style == STYLE_HORISONTAL) {
         $this->addRow(array($avail, $notav, $uncn, $total));
     } else {
         $this->addRow($avail);
         $this->addRow($notav);
         $this->addRow($uncn);
         $this->addRow($total);
     }
     return parent::bodyToString();
 }
예제 #2
0
 public function bodyToString()
 {
     global $USER_DETAILS;
     $this->cleanItems();
     $total = 0;
     $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, get_current_nodeid(true));
     $cond_from = '';
     if (remove_nodes_from_id($this->groupid) > 0) {
         $cond_from = ', hosts_groups hg ';
         $cond_where = 'AND hg.hostid=h.hostid AND hg.groupid=' . $this->groupid;
     } else {
         $cond_where = ' AND ' . DBin_node('h.hostid', $this->nodeid);
     }
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_TRUE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $avail = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_FALSE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $notav = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_UNKNOWN . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $uncn = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $node = get_node_by_nodeid($this->nodeid);
     $header_str = S_HOSTS_INFO . SPACE;
     $header_str .= S_FOR_GROUP_SMALL . SPACE . '"';
     if ($node > 0) {
         $header_str .= '(' . $node['name'] . ')' . SPACE;
     }
     if (remove_nodes_from_id($this->groupid) > 0) {
         $group = get_hostgroup_by_groupid($this->groupid);
         $header_str .= $group['name'] . '"';
     } else {
         $header_str .= S_ALL_S . '"';
     }
     $header = new CCol($header_str, "header");
     if ($this->style == STYLE_HORISONTAL) {
         $header->SetColspan(4);
     }
     $this->addRow($header);
     $avail = new CCol($avail . '  ' . S_AVAILABLE, 'avail');
     $notav = new CCol($notav . '  ' . S_NOT_AVAILABLE, 'notav');
     $uncn = new CCol($uncn . '  ' . S_UNKNOWN, 'uncn');
     $total = new CCol($total . '  ' . S_TOTAL, 'total');
     if ($this->style == STYLE_HORISONTAL) {
         $this->addRow(array($avail, $notav, $uncn, $total));
     } else {
         $this->addRow($avail);
         $this->addRow($notav);
         $this->addRow($uncn);
         $this->addRow($total);
     }
     return parent::bodyToString();
 }
예제 #3
0
function delete_host_group($groupids)
{
    zbx_value2array($groupids);
    if (empty($groupids)) {
        return true;
    }
    $dlt_groupids = getDeletableHostGroups($groupids);
    if (count($groupids) != count($dlt_groupids)) {
        foreach ($groupids as $num => $groupid) {
            if (!isset($dlt_groupids[$groupid])) {
                $group = get_hostgroup_by_groupid($groupid);
                if ($group['internal'] == ZBX_INTERNAL_GROUP) {
                    error(S_GROUP . SPACE . '"' . $group['name'] . '"' . SPACE . S_INTERNAL_AND_CANNOT_DELETED_SMALL);
                } else {
                    error(S_GROUP . SPACE . '"' . $group['name'] . '"' . SPACE . S_CANNOT_DELETED_INNER_HOSTS_CANNOT_UNLINKED_SMALL);
                }
            }
        }
        return false;
    }
    // check if hostgroup used in scripts
    $error = false;
    $sql = 'SELECT s.name AS script_name, g.name AS group_name ' . ' FROM scripts s, groups g' . ' WHERE ' . ' g.groupid = s.groupid ' . ' AND ' . DBcondition('s.groupid', $groupids);
    $res = DBselect($sql);
    while ($group = DBfetch($res)) {
        $error = true;
        error(sprintf(S_HOSTGROUP_CANNOT_BE_DELETED_USED_IN_SCRIPT, $group['group_name'], $group['script_name']));
    }
    if ($error) {
        return false;
    }
    // delete screens items
    $resources = array(SCREEN_RESOURCE_HOSTGROUP_TRIGGERS, SCREEN_RESOURCE_HOSTS_INFO, SCREEN_RESOURCE_TRIGGERS_INFO, SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW);
    $sql = 'DELETE FROM screens_items ' . ' WHERE ' . DBcondition('resourceid', $groupids) . ' AND ' . DBcondition('resourcetype', $resources);
    DBexecute($sql);
    // delete sysmap element
    if (!delete_sysmaps_elements_with_groupid($groupids)) {
        return false;
    }
    // delete host from maintenances
    DBexecute('DELETE FROM maintenances_groups WHERE ' . DBcondition('groupid', $groupids));
    // disable actions
    $actionids = array();
    // conditions
    $sql = 'SELECT DISTINCT c.actionid ' . ' FROM conditions c ' . ' WHERE c.conditiontype=' . CONDITION_TYPE_HOST_GROUP . ' AND ' . DBcondition('c.value', $groupids, false, true);
    $db_actions = DBselect($sql);
    while ($db_action = DBfetch($db_actions)) {
        $actionids[$db_action['actionid']] = $db_action['actionid'];
    }
    // operations
    $sql = 'SELECT DISTINCT o.actionid ' . ' FROM operations o ' . ' WHERE o.operationtype IN (' . OPERATION_TYPE_GROUP_ADD . ',' . OPERATION_TYPE_GROUP_REMOVE . ') ' . ' AND ' . DBcondition('o.objectid', $groupids);
    $db_actions = DBselect($sql);
    while ($db_action = DBfetch($db_actions)) {
        $actionids[$db_action['actionid']] = $db_action['actionid'];
    }
    if (!empty($actionids)) {
        DBexecute('UPDATE actions ' . ' SET status=' . ACTION_STATUS_DISABLED . ' WHERE ' . DBcondition('actionid', $actionids));
    }
    // delete action conditions
    DBexecute('DELETE FROM conditions' . ' WHERE conditiontype=' . CONDITION_TYPE_HOST_GROUP . ' AND ' . DBcondition('value', $groupids, false, true));
    // delete action operations
    DBexecute('DELETE FROM operations ' . ' WHERE operationtype IN (' . OPERATION_TYPE_GROUP_ADD . ',' . OPERATION_TYPE_GROUP_REMOVE . ') ' . ' AND ' . DBcondition('objectid', $groupids));
    DBexecute('DELETE FROM hosts_groups WHERE ' . DBcondition('groupid', $groupids));
    foreach ($groupids as $id) {
        /* The section should be improved */
        $hostgroup_old = get_hostgroup_by_groupid($id);
        $result = DBexecute('DELETE FROM groups WHERE groupid=' . $id);
        if ($result) {
            add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_HOST_GROUP, $id, $hostgroup_old['name'], 'groups', NULL, NULL);
        } else {
            break;
        }
    }
    return $result;
}
예제 #4
0
/*** --->>> ACTIONS <<<--- ***/
$frmForm = new CForm();
$frmForm->setMethod('get');
if (!isset($_REQUEST['form'])) {
    $frmForm->addItem(new CButton('form', S_CREATE_GROUP));
}
show_table_header(S_CONFIGURATION_OF_GROUPS, $frmForm);
if (isset($_REQUEST['form'])) {
    echo SBR;
    global $USER_DETAILS;
    $groupid = get_request('groupid', 0);
    $hosts = get_request('hosts', array());
    SDII($hosts);
    $frm_title = S_HOST_GROUP;
    if ($groupid > 0) {
        $group = get_hostgroup_by_groupid($_REQUEST['groupid']);
        $name = $group['name'];
        $frm_title .= ' [' . $group['name'] . ']';
    } else {
        $name = '';
    }
    $frmHostG = new CFormTable($frm_title, 'hostgroups.php');
    $frmHostG->setName('hg_form');
    $frmHostG->addRow(S_GROUP_NAME, new CTextBox('gname', $name, 48));
    if ($groupid > 0) {
        $frmHostG->addVar('groupid', $_REQUEST['groupid']);
        // if first time select all hosts for group from db
        if (!isset($_REQUEST['form_refresh'])) {
            $params = array('groupids' => $groupid, 'editable' => 1, 'order' => 'host', 'templated_hosts' => 1);
            $db_hosts = CHost::get($params);
            foreach ($db_hosts as $hostid => $db_host) {
예제 #5
0
function get_operation_desc($type = SHORT_DESCRITION, $data)
{
    $result = null;
    switch ($type) {
        case SHORT_DESCRITION:
            switch ($data['operationtype']) {
                case OPERATION_TYPE_MESSAGE:
                    switch ($data['object']) {
                        case OPERATION_OBJECT_USER:
                            $obj_data = get_user_by_userid($data['objectid']);
                            $obj_data = S_USER . ' "' . $obj_data['alias'] . '"';
                            break;
                        case OPERATION_OBJECT_GROUP:
                            $obj_data = get_group_by_usrgrpid($data['objectid']);
                            $obj_data = S_GROUP . ' "' . $obj_data['name'] . '"';
                            break;
                    }
                    $result = S_SEND_MESSAGE_TO . ' ' . $obj_data;
                    break;
                case OPERATION_TYPE_COMMAND:
                    $result = S_RUN_REMOTE_COMMANDS;
                    break;
                case OPERATION_TYPE_HOST_ADD:
                    $result = S_ADD_HOST;
                    break;
                case OPERATION_TYPE_HOST_REMOVE:
                    $result = S_REMOVE_HOST;
                    break;
                case OPERATION_TYPE_GROUP_ADD:
                    $obj_data = get_hostgroup_by_groupid($data['objectid']);
                    $result = S_ADD_TO_GROUP . ' "' . $obj_data['name'] . '"';
                    break;
                case OPERATION_TYPE_GROUP_REMOVE:
                    $obj_data = get_hostgroup_by_groupid($data['objectid']);
                    $result = S_DELETE_FROM_GROUP . ' "' . $obj_data['name'] . '"';
                    break;
                case OPERATION_TYPE_TEMPLATE_ADD:
                    $obj_data = get_host_by_hostid($data['objectid']);
                    $result = S_LINK_TO_TEMPLATE . ' "' . $obj_data['host'] . '"';
                    break;
                case OPERATION_TYPE_TEMPLATE_REMOVE:
                    $obj_data = get_host_by_hostid($data['objectid']);
                    $result = S_UNLINK_FROM_TEMPLATE . ' "' . $obj_data['host'] . '"';
                    break;
                default:
                    break;
            }
            break;
        case LONG_DESCRITION:
            switch ($data['operationtype']) {
                case OPERATION_TYPE_MESSAGE:
                    // for PHP4
                    if (isset($data['default_msg']) && !empty($data['default_msg'])) {
                        if (isset($_REQUEST['def_shortdata']) && isset($_REQUEST['def_longdata'])) {
                            $temp = bold(S_SUBJECT . ': ');
                            $result = $temp->ToString() . $_REQUEST['def_shortdata'] . "\n";
                            $temp = bold(S_MESSAGE . ':');
                            $result .= $temp->ToString() . $_REQUEST['def_longdata'];
                        } else {
                            if (isset($data['operationid'])) {
                                $sql = 'SELECT a.def_shortdata,a.def_longdata ' . ' FROM actions a, operations o ' . ' WHERE a.actionid=o.actionid ' . ' AND o.operationid=' . $data['operationid'];
                                if ($rows = DBfetch(DBselect($sql, 1))) {
                                    $temp = bold(S_SUBJECT . ': ');
                                    $result = $temp->ToString() . $rows['def_shortdata'] . "\n";
                                    $temp = bold(S_MESSAGE . ':');
                                    $result .= $temp->ToString() . $rows['def_longdata'];
                                }
                            }
                        }
                    } else {
                        $temp = bold(S_SUBJECT . ': ');
                        $result = $temp->ToString() . $data['shortdata'] . "\n";
                        $temp = bold(S_MESSAGE . ':');
                        $result .= $temp->ToString() . $data['longdata'];
                    }
                    break;
                case OPERATION_TYPE_COMMAND:
                    $temp = bold(S_REMOTE_COMMANDS . ': ');
                    $result = $temp->ToString() . $data['longdata'];
                    break;
                default:
                    break;
            }
            break;
        default:
            break;
    }
    return $result;
}
예제 #6
0
파일: scripts.php 프로젝트: phedders/zabbix
 $numrows->setAttribute('name', 'numrows');
 $header = get_table_header(array(S_SCRIPTS, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
 show_table_header($header);
 $table = new CTableInfo(S_NO_SCRIPTS_DEFINED);
 $table->setHeader(array(new CCheckBox('all_scripts', null, "checkAll('" . $form->getName() . "','all_scripts','scripts');"), make_sorting_link(S_NAME, 's.name'), make_sorting_link(S_COMMAND, 's.command'), S_USER_GROUP, S_HOST_GROUP, S_HOST_ACCESS));
 $sql = 'SELECT s.* ' . ' FROM scripts s ' . ' WHERE ' . DBin_node('s.scriptid') . order_by('s.name,s.command');
 $scripts = DBselect($sql);
 while ($script = DBfetch($scripts)) {
     $user_group_name = S_ALL_S;
     if ($script['usrgrpid'] > 0) {
         $user_group = get_group_by_usrgrpid($script['usrgrpid']);
         $user_group_name = $user_group['name'];
     }
     $host_group_name = S_ALL_S;
     if ($script['groupid'] > 0) {
         $group = get_hostgroup_by_groupid($script['groupid']);
         $host_group_name = $group['name'];
     }
     $table->addRow(array(new CCheckBox('scripts[' . $script['scriptid'] . ']', 'no', NULL, $script['scriptid']), new CLink($script['name'], 'scripts.php?form=1' . '&scriptid=' . $script['scriptid'] . '#form'), htmlspecialchars($script['command']), $user_group_name, $host_group_name, PERM_READ_WRITE == $script['host_access'] ? S_WRITE : S_READ));
     $row_count++;
 }
 //----- GO ------
 $goBox = new CComboBox('go');
 $goBox->addItem('delete', S_DELETE_SELECTED);
 // goButton name is necessary!!!
 $goButton = new CButton('goButton', S_GO . ' (0)');
 $goButton->setAttribute('id', 'goButton');
 zbx_add_post_js('chkbxRange.pageGoName = "scripts";');
 $table->setFooter(new CCol(array($goBox, $goButton)));
 //----
 $form->addItem($table);
if ($_REQUEST['go'] != 'none' && isset($go_result) && $go_result) {
    $url = new CUrl();
    $path = $url->getPath();
    insert_js('cookie.eraseArray("' . $path . '")');
}
/*
 * Display
 */
$data = array('form' => get_request('form'));
if (isset($_REQUEST['form'])) {
    $data['groupid'] = get_request('groupid', 0);
    $data['hosts'] = get_request('hosts', array());
    $data['name'] = get_request('name', '');
    $data['twb_groupid'] = get_request('twb_groupid', -1);
    if ($data['groupid'] > 0) {
        $data['group'] = get_hostgroup_by_groupid($data['groupid']);
        // if first time select all hosts for group from db
        if (!isset($_REQUEST['form_refresh'])) {
            $data['name'] = $data['group']['name'];
            $options = array('groupids' => $data['groupid'], 'templated_hosts' => 1, 'output' => API_OUTPUT_SHORTEN);
            $data['hosts'] = API::Host()->get($options);
            $data['hosts'] = zbx_objectValues($data['hosts'], 'hostid');
            $data['hosts'] = zbx_toHash($data['hosts'], 'hostid');
        }
    }
    // get all possible groups
    $options = array('not_proxy_host' => 1, 'sortfield' => 'name', 'editable' => true, 'output' => API_OUTPUT_EXTEND);
    $data['db_groups'] = API::HostGroup()->get($options);
    if ($data['twb_groupid'] == -1) {
        $gr = reset($data['db_groups']);
        $data['twb_groupid'] = $gr['groupid'];
예제 #8
0
function insert_hostgroups_form()
{
    global $USER_DETAILS;
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
    $hosts = get_request('hosts', array());
    $frm_title = S_HOST_GROUP;
    if ($_REQUEST['groupid'] > 0) {
        $group = get_hostgroup_by_groupid($_REQUEST['groupid']);
        $frm_title = S_HOST_GROUP . ' [' . $group["name"] . ']';
    }
    if ($_REQUEST['groupid'] > 0 && !isset($_REQUEST["form_refresh"])) {
        $name = $group["name"];
        $db_hosts = DBselect('SELECT DISTINCT h.hostid,host ' . ' FROM hosts h, hosts_groups hg ' . ' WHERE h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ',' . HOST_STATUS_TEMPLATE . ')' . ' AND h.hostid=hg.hostid ' . ' AND hg.groupid=' . $_REQUEST['groupid'] . ' ORDER BY host');
        while ($db_host = DBfetch($db_hosts)) {
            if (uint_in_array($db_host['hostid'], $hosts)) {
                continue;
            }
            array_push($hosts, $db_host['hostid']);
        }
    } else {
        $name = get_request("gname", "");
    }
    $frmHostG = new CFormTable($frm_title, "hosts.php");
    $frmHostG->SetHelp("web.hosts.group.php");
    $frmHostG->addVar("config", get_request("config", 1));
    if ($_REQUEST['groupid'] > 0) {
        $frmHostG->addVar('groupid', $_REQUEST['groupid']);
    }
    $frmHostG->addRow(S_GROUP_NAME, new CTextBox("gname", $name, 48));
    $cmbHosts = new CTweenBox($frmHostG, 'hosts', $hosts, 25);
    $db_hosts = DBselect('SELECT DISTINCT hostid,host ' . ' FROM hosts ' . ' WHERE status in (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ',' . HOST_STATUS_TEMPLATE . ')' . ' AND ' . DBcondition('hostid', $available_hosts) . ' ORDER BY host');
    while ($db_host = DBfetch($db_hosts)) {
        $cmbHosts->addItem($db_host['hostid'], get_node_name_by_elid($db_host['hostid']) . $db_host["host"]);
    }
    $frmHostG->addRow(S_HOSTS, $cmbHosts->Get(S_HOSTS . SPACE . S_IN, S_OTHER . SPACE . S_HOSTS));
    $frmHostG->addItemToBottomRow(new CButton("save", S_SAVE));
    if ($_REQUEST['groupid'] > 0) {
        $frmHostG->addItemToBottomRow(SPACE);
        $frmHostG->addItemToBottomRow(new CButton("clone", S_CLONE));
        $frmHostG->addItemToBottomRow(SPACE);
        $frmHostG->addItemToBottomRow(new CButtonDelete("Delete selected group?", url_param("form") . url_param("config") . url_param('groupid')));
    }
    $frmHostG->addItemToBottomRow(SPACE);
    $frmHostG->addItemToBottomRow(new CButtonCancel(url_param("config")));
    $frmHostG->Show();
}
 public function bodyToString()
 {
     $this->cleanItems();
     $ok = $uncn = $uncl = $info = $warn = $avg = $high = $dis = 0;
     $options = array('monitored' => 1, 'skipDependent' => 1, 'output' => API_OUTPUT_SHORTEN);
     if ($this->hostid > 0) {
         $options['hostids'] = $this->hostid;
     } else {
         if ($this->groupid > 0) {
             $options['groupids'] = $this->groupid;
         }
     }
     $triggers = CTrigger::get($options);
     $triggers = zbx_objectValues($triggers, 'triggerid');
     $sql = 'SELECT t.priority,t.value,count(DISTINCT t.triggerid) as cnt ' . ' FROM triggers t ' . ' WHERE ' . DBcondition('t.triggerid', $triggers) . ' GROUP BY t.priority,t.value';
     $db_priority = DBselect($sql);
     while ($row = DBfetch($db_priority)) {
         switch ($row['value']) {
             case TRIGGER_VALUE_TRUE:
                 switch ($row['priority']) {
                     case TRIGGER_SEVERITY_NOT_CLASSIFIED:
                         $uncl += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_INFORMATION:
                         $info += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_WARNING:
                         $warn += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_AVERAGE:
                         $avg += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_HIGH:
                         $high += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_DISASTER:
                         $dis += $row['cnt'];
                         break;
                 }
                 break;
             case TRIGGER_VALUE_FALSE:
                 $ok += $row['cnt'];
                 break;
             default:
                 $uncn += $row['cnt'];
                 break;
         }
     }
     if ($this->show_header) {
         $header_str = S_TRIGGERS_INFO . SPACE;
         if (!is_null($this->nodeid)) {
             $node = get_node_by_nodeid($this->nodeid);
             if ($node > 0) {
                 $header_str .= '(' . $node['name'] . ')' . SPACE;
             }
         }
         if (remove_nodes_from_id($this->groupid) > 0) {
             $group = get_hostgroup_by_groupid($this->groupid);
             $header_str .= S_GROUP . SPACE . '&quot;' . $group['name'] . '&quot;';
         } else {
             $header_str .= S_ALL_GROUPS;
         }
         $header = new CCol($header_str, 'header');
         if ($this->style == STYLE_HORISONTAL) {
             $header->SetColspan(8);
         }
         $this->addRow($header);
     }
     $trok = new CCol($ok . SPACE . S_OK, get_severity_style('ok', false));
     $uncn = new CCol($uncn . SPACE . S_UNKNOWN, 'unknown');
     $uncl = new CCol($uncl . SPACE . S_NOT_CLASSIFIED, get_severity_style(TRIGGER_SEVERITY_NOT_CLASSIFIED, $uncl));
     $info = new CCol($info . SPACE . S_INFORMATION, get_severity_style(TRIGGER_SEVERITY_INFORMATION, $info));
     $warn = new CCol($warn . SPACE . S_WARNING, get_severity_style(TRIGGER_SEVERITY_WARNING, $warn));
     $avg = new CCol($avg . SPACE . S_AVERAGE, get_severity_style(TRIGGER_SEVERITY_AVERAGE, $avg));
     $high = new CCol($high . SPACE . S_HIGH, get_severity_style(TRIGGER_SEVERITY_HIGH, $high));
     $dis = new CCol($dis . SPACE . S_DISASTER, get_severity_style(TRIGGER_SEVERITY_DISASTER, $dis));
     if (STYLE_HORISONTAL == $this->style) {
         $this->addRow(array($trok, $uncn, $uncl, $info, $warn, $avg, $high, $dis));
     } else {
         $this->addRow($trok);
         $this->addRow($uncn);
         $this->addRow($uncl);
         $this->addRow($info);
         $this->addRow($warn);
         $this->addRow($avg);
         $this->addRow($high);
         $this->addRow($dis);
     }
     return parent::BodyToString();
 }
예제 #10
0
function delete_host_group($groupids)
{
    zbx_value2array($groupids);
    if (empty($groupids)) {
        return true;
    }
    // delete sysmap element
    if (!delete_sysmaps_elements_with_groupid($groupids)) {
        return false;
    }
    // delete host from maintenances
    DBexecute('DELETE FROM maintenances_groups WHERE ' . DBcondition('groupid', $groupids));
    // disable actions
    $actionids = array();
    // conditions
    $sql = 'SELECT DISTINCT c.actionid ' . ' FROM conditions c ' . ' WHERE c.conditiontype=' . CONDITION_TYPE_HOST_GROUP . ' AND ' . DBcondition('c.value', $groupids, false, true);
    $db_actions = DBselect($sql);
    while ($db_action = DBfetch($db_actions)) {
        $actionids[$db_action['actionid']] = $db_action['actionid'];
    }
    // operations
    $sql = 'SELECT DISTINCT o.actionid ' . ' FROM operations o ' . ' WHERE o.operationtype IN (' . OPERATION_TYPE_GROUP_ADD . ',' . OPERATION_TYPE_GROUP_REMOVE . ') ' . ' AND ' . DBcondition('o.objectid', $groupids);
    $db_actions = DBselect($sql);
    while ($db_action = DBfetch($db_actions)) {
        $actionids[$db_action['actionid']] = $db_action['actionid'];
    }
    if (!empty($actionids)) {
        DBexecute('UPDATE actions ' . ' SET status=' . ACTION_STATUS_DISABLED . ' WHERE ' . DBcondition('actionid', $actionids));
    }
    // delete action conditions
    DBexecute('DELETE FROM conditions' . ' WHERE conditiontype=' . CONDITION_TYPE_HOST_GROUP . ' AND ' . DBcondition('value', $groupids, false, true));
    // delete action operations
    DBexecute('DELETE FROM operations ' . ' WHERE operationtype IN (' . OPERATION_TYPE_GROUP_ADD . ',' . OPERATION_TYPE_GROUP_REMOVE . ') ' . ' AND ' . DBcondition('objectid', $groupids));
    DBexecute('DELETE FROM hosts_groups WHERE ' . DBcondition('groupid', $groupids));
    foreach ($groupids as $id) {
        /* The section should be improved */
        $hostgroup_old = get_hostgroup_by_groupid($id);
        $result = DBexecute('DELETE FROM groups WHERE groupid=' . $id);
        if ($result) {
            add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_HOST_GROUP, $id, $hostgroup_old['name'], 'groups', NULL, NULL);
        } else {
            break;
        }
    }
    return $result;
}
예제 #11
0
 public function bodyToString()
 {
     $this->cleanItems();
     $okCount = 0;
     $notClassifiedCount = 0;
     $informationCount = 0;
     $warningCount = 0;
     $averageCount = 0;
     $highCount = 0;
     $disasterCount = 0;
     $options = array('output' => array('triggerid', 'priority', 'value'), 'monitored' => true, 'skipDependent' => true);
     if ($this->hostid > 0) {
         $options['hostids'] = $this->hostid;
     } elseif ($this->groupid > 0) {
         $options['groupids'] = $this->groupid;
     }
     $triggers = API::Trigger()->get($options);
     foreach ($triggers as $trigger) {
         if ($trigger['value'] == TRIGGER_VALUE_TRUE) {
             switch ($trigger['priority']) {
                 case TRIGGER_SEVERITY_NOT_CLASSIFIED:
                     $notClassifiedCount++;
                     break;
                 case TRIGGER_SEVERITY_INFORMATION:
                     $informationCount++;
                     break;
                 case TRIGGER_SEVERITY_WARNING:
                     $warningCount++;
                     break;
                 case TRIGGER_SEVERITY_AVERAGE:
                     $averageCount++;
                     break;
                 case TRIGGER_SEVERITY_HIGH:
                     $highCount++;
                     break;
                 case TRIGGER_SEVERITY_DISASTER:
                     $disasterCount++;
                     break;
             }
         } elseif ($trigger['value'] == TRIGGER_VALUE_FALSE) {
             $okCount++;
         }
     }
     if ($this->show_header) {
         $header_str = _('Triggers info') . SPACE;
         if ($this->groupid != 0) {
             $group = get_hostgroup_by_groupid($this->groupid);
             $header_str .= _('Group') . SPACE . '&quot;' . $group['name'] . '&quot;';
         } else {
             $header_str .= _('All groups');
         }
         $header = new CCol($header_str, 'header');
         if ($this->style == STYLE_HORIZONTAL) {
             $header->setColspan(8);
         }
         $this->addRow($header);
     }
     $okCount = getSeverityCell(null, $okCount . SPACE . _('Ok'), true);
     $notClassifiedCount = getSeverityCell(TRIGGER_SEVERITY_NOT_CLASSIFIED, $notClassifiedCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), !$notClassifiedCount);
     $informationCount = getSeverityCell(TRIGGER_SEVERITY_INFORMATION, $informationCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), !$informationCount);
     $warningCount = getSeverityCell(TRIGGER_SEVERITY_WARNING, $warningCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_WARNING), !$warningCount);
     $averageCount = getSeverityCell(TRIGGER_SEVERITY_AVERAGE, $averageCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), !$averageCount);
     $highCount = getSeverityCell(TRIGGER_SEVERITY_HIGH, $highCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_HIGH), !$highCount);
     $disasterCount = getSeverityCell(TRIGGER_SEVERITY_DISASTER, $disasterCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_DISASTER), !$disasterCount);
     if (STYLE_HORIZONTAL == $this->style) {
         $this->addRow(array($okCount, $notClassifiedCount, $informationCount, $warningCount, $averageCount, $highCount, $disasterCount));
     } else {
         $this->addRow($okCount);
         $this->addRow($notClassifiedCount);
         $this->addRow($informationCount);
         $this->addRow($warningCount);
         $this->addRow($averageCount);
         $this->addRow($highCount);
         $this->addRow($disasterCount);
     }
     return parent::bodyToString();
 }
 public function bodyToString()
 {
     $this->cleanItems();
     $ok = $uncl = $info = $warn = $avg = $high = $dis = 0;
     $options = array('monitored' => true, 'skipDependent' => true, 'output' => API_OUTPUT_SHORTEN);
     if ($this->hostid > 0) {
         $options['hostids'] = $this->hostid;
     } elseif ($this->groupid > 0) {
         $options['groupids'] = $this->groupid;
     }
     $triggers = API::Trigger()->get($options);
     $triggers = zbx_objectValues($triggers, 'triggerid');
     $db_priority = DBselect('SELECT t.priority,t.value,count(DISTINCT t.triggerid) AS cnt' . ' FROM triggers t' . ' WHERE ' . dbConditionInt('t.triggerid', $triggers) . ' GROUP BY t.priority,t.value');
     while ($row = DBfetch($db_priority)) {
         switch ($row['value']) {
             case TRIGGER_VALUE_TRUE:
                 switch ($row['priority']) {
                     case TRIGGER_SEVERITY_NOT_CLASSIFIED:
                         $uncl += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_INFORMATION:
                         $info += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_WARNING:
                         $warn += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_AVERAGE:
                         $avg += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_HIGH:
                         $high += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_DISASTER:
                         $dis += $row['cnt'];
                         break;
                 }
                 break;
             case TRIGGER_VALUE_FALSE:
                 $ok += $row['cnt'];
                 break;
         }
     }
     if ($this->show_header) {
         $header_str = _('Triggers info') . SPACE;
         if (!is_null($this->nodeid)) {
             $node = get_node_by_nodeid($this->nodeid);
             if ($node > 0) {
                 $header_str .= '(' . $node['name'] . ')' . SPACE;
             }
         }
         if (remove_nodes_from_id($this->groupid) > 0) {
             $group = get_hostgroup_by_groupid($this->groupid);
             $header_str .= _('Group') . SPACE . '&quot;' . $group['name'] . '&quot;';
         } else {
             $header_str .= _('All groups');
         }
         $header = new CCol($header_str, 'header');
         if ($this->style == STYLE_HORISONTAL) {
             $header->setColspan(8);
         }
         $this->addRow($header);
     }
     $trok = getSeverityCell(null, $ok . SPACE . _('Ok'), true);
     $uncl = getSeverityCell(TRIGGER_SEVERITY_NOT_CLASSIFIED, $uncl . SPACE . getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), !$uncl);
     $info = getSeverityCell(TRIGGER_SEVERITY_INFORMATION, $info . SPACE . getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), !$info);
     $warn = getSeverityCell(TRIGGER_SEVERITY_WARNING, $warn . SPACE . getSeverityCaption(TRIGGER_SEVERITY_WARNING), !$warn);
     $avg = getSeverityCell(TRIGGER_SEVERITY_AVERAGE, $avg . SPACE . getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), !$avg);
     $high = getSeverityCell(TRIGGER_SEVERITY_HIGH, $high . SPACE . getSeverityCaption(TRIGGER_SEVERITY_HIGH), !$high);
     $dis = getSeverityCell(TRIGGER_SEVERITY_DISASTER, $dis . SPACE . getSeverityCaption(TRIGGER_SEVERITY_DISASTER), !$dis);
     if (STYLE_HORISONTAL == $this->style) {
         $this->addRow(array($trok, $uncl, $info, $warn, $avg, $high, $dis));
     } else {
         $this->addRow($trok);
         $this->addRow($uncl);
         $this->addRow($info);
         $this->addRow($warn);
         $this->addRow($avg);
         $this->addRow($high);
         $this->addRow($dis);
     }
     return parent::bodyToString();
 }
예제 #13
0
if (isset($_REQUEST['form'])) {
    $frmForm = null;
} else {
    $frmForm = new CForm();
    $frmForm->addItem(new CButton('form', S_CREATE_GROUP));
}
$groups_wdgt = new CWidget();
$groups_wdgt->addPageHeader(S_CONFIGURATION_OF_GROUPS, $frmForm);
if (isset($_REQUEST['form'])) {
    global $USER_DETAILS;
    $groupid = get_request('groupid', 0);
    $hosts = get_request('hosts', array());
    $group_name = get_request('gname', '');
    $frm_title = S_HOST_GROUP;
    if ($groupid > 0) {
        $group = get_hostgroup_by_groupid($groupid);
        $frm_title .= ' [' . $group['name'] . ']';
        // if first time select all hosts for group from db
        if (!isset($_REQUEST['form_refresh'])) {
            $group_name = $group['name'];
            $params = array('groupids' => $groupid, 'templated_hosts' => 1, 'output' => API_OUTPUT_SHORTEN);
            $hosts = CHost::get($params);
            $hosts = zbx_objectValues($hosts, 'hostid');
            $hosts = zbx_toHash($hosts, 'hostid');
        }
    }
    $frmHostG = new CFormTable($frm_title, 'hostgroups.php');
    $frmHostG->setName('hg_form');
    if ($groupid > 0) {
        $frmHostG->addVar('groupid', $groupid);
    }
예제 #14
0
파일: maps.inc.php 프로젝트: rennhak/zabbix
function get_info_by_selementid($selementid)
{
    global $colors;
    $el_name = '';
    $tr_info = array();
    $db_element = get_sysmaps_element_by_selementid($selementid);
    $el_type =& $db_element["elementtype"];
    $sql = array(SYSMAP_ELEMENT_TYPE_TRIGGER => 'SELECT DISTINCT t.triggerid,t.priority,t.value,t.description' . ',t.expression,h.host,h.status as h_status,i.status as i_status,t.status as t_status' . ' FROM triggers t, items i, functions f, hosts h ' . ' WHERE t.triggerid=' . $db_element['elementid'] . ' AND h.hostid=i.hostid ' . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid ', SYSMAP_ELEMENT_TYPE_HOST_GROUP => 'SELECT DISTINCT t.triggerid, t.priority, t.value, t.description, t.expression, h.host' . ' FROM items i,functions f,triggers t,hosts h,hosts_groups hg,groups g ' . ' WHERE h.hostid=i.hostid ' . ' AND hg.groupid=g.groupid ' . ' AND g.groupid=' . $db_element['elementid'] . ' AND hg.hostid=h.hostid ' . ' AND i.itemid=f.itemid' . ' AND f.triggerid=t.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE, SYSMAP_ELEMENT_TYPE_HOST => 'SELECT DISTINCT t.triggerid, t.priority, t.value, t.description, t.expression, h.host' . ' FROM items i,functions f,triggers t,hosts h WHERE h.hostid=i.hostid' . ' AND i.hostid=' . $db_element['elementid'] . ' AND i.itemid=f.itemid' . ' AND f.triggerid=t.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE);
    $out['triggers'] = array();
    if (isset($sql[$el_type])) {
        $db_triggers = DBselect($sql[$el_type]);
        $trigger = DBfetch($db_triggers);
        if ($trigger) {
            if ($el_type == SYSMAP_ELEMENT_TYPE_TRIGGER) {
                $el_name = expand_trigger_description_by_data($trigger);
            }
            do {
                if ($el_type == SYSMAP_ELEMENT_TYPE_TRIGGER && ($trigger['h_status'] != HOST_STATUS_MONITORED || $trigger['i_status'] != ITEM_STATUS_ACTIVE || $trigger['t_status'] != TRIGGER_STATUS_ENABLED)) {
                    $type = TRIGGER_VALUE_UNKNOWN;
                    $out['disabled'] = 1;
                } else {
                    $type =& $trigger['value'];
                }
                if (!isset($tr_info[$type])) {
                    $tr_info[$type] = array('count' => 0);
                }
                $tr_info[$type]['count']++;
                if (!isset($tr_info[$type]['priority']) || $tr_info[$type]['priority'] < $trigger["priority"]) {
                    $tr_info[$type]['priority'] = $trigger["priority"];
                    if ($el_type != SYSMAP_ELEMENT_TYPE_TRIGGER && $type != TRIGGER_VALUE_UNKNOWN) {
                        $tr_info[$type]['info'] = expand_trigger_description_by_data($trigger);
                    }
                }
                if ($type == TRIGGER_VALUE_TRUE) {
                    array_push($out['triggers'], $trigger['triggerid']);
                }
            } while ($trigger = DBfetch($db_triggers));
        }
    } else {
        if ($el_type == SYSMAP_ELEMENT_TYPE_MAP) {
            $triggers = array();
            $db_subelements = DBselect("select selementid FROM sysmaps_elements" . " WHERE sysmapid=" . $db_element["elementid"]);
            while ($db_subelement = DBfetch($db_subelements)) {
                // recursion
                $inf = get_info_by_selementid($db_subelement["selementid"]);
                foreach ($inf['triggers'] as $id => $triggerid) {
                    if (!in_array($triggerid, $triggers)) {
                        array_push($triggers, $triggerid);
                    }
                }
                $type = $inf['type'];
                if (!isset($tr_info[$type]['count'])) {
                    $tr_info[$type]['count'] = 0;
                }
                $tr_info[$type]['count'] += isset($inf['count']) ? $inf['count'] : 1;
                if (!isset($tr_info[$type]['priority']) || $tr_info[$type]['priority'] < $inf["priority"]) {
                    $tr_info[$type]['priority'] = $inf['priority'];
                    $tr_info[$type]['info'] = $inf['info'];
                }
            }
            $count = count($triggers);
            if ($count > 0) {
                $tr_info[TRIGGER_VALUE_TRUE]['count'] = $count;
                if ($tr_info[TRIGGER_VALUE_TRUE]['count'] == 1) {
                    $db_trigger = DBfetch(DBselect('SELECT DISTINCT t.triggerid,t.priority,t.value,t.description' . ',t.expression,h.host FROM triggers t, items i, functions f, hosts h' . ' WHERE t.triggerid=' . $triggers[0] . ' AND h.hostid=i.hostid' . ' AND i.itemid=f.itemid AND f.triggerid=t.triggerid'));
                    $tr_info[TRIGGER_VALUE_TRUE]['info'] = expand_trigger_description_by_data($db_trigger);
                }
            }
        }
    }
    if ($el_type == SYSMAP_ELEMENT_TYPE_HOST) {
        $host = get_host_by_hostid($db_element["elementid"]);
        $el_name = $host['host'];
        if ($host["status"] == HOST_STATUS_TEMPLATE) {
            $tr_info[TRIGGER_VALUE_UNKNOWN]['count'] = 0;
            $tr_info[TRIGGER_VALUE_UNKNOWN]['priority'] = 0;
            $tr_info[TRIGGER_VALUE_UNKNOWN]['info'] = 'template';
        } else {
            if ($host["status"] == HOST_STATUS_NOT_MONITORED) {
                $tr_info[TRIGGER_VALUE_UNKNOWN]['count'] = 0;
                $tr_info[TRIGGER_VALUE_UNKNOWN]['priority'] = 0;
                $out['disabled'] = 1;
            } else {
                if (!isset($tr_info[TRIGGER_VALUE_FALSE])) {
                    $tr_info[TRIGGER_VALUE_FALSE]['count'] = 0;
                    $tr_info[TRIGGER_VALUE_FALSE]['priority'] = 0;
                    $tr_info[TRIGGER_VALUE_FALSE]['info'] = 'OK';
                }
            }
        }
    } else {
        if ($el_type == SYSMAP_ELEMENT_TYPE_HOST_GROUP) {
            $group = get_hostgroup_by_groupid($db_element["elementid"]);
            $el_name = $group['name'];
            if (!isset($tr_info[TRIGGER_VALUE_FALSE])) {
                $tr_info[TRIGGER_VALUE_FALSE]['count'] = 0;
                $tr_info[TRIGGER_VALUE_FALSE]['priority'] = 0;
                $tr_info[TRIGGER_VALUE_FALSE]['info'] = 'OK';
            }
        } else {
            if ($el_type == SYSMAP_ELEMENT_TYPE_MAP) {
                $db_map = DBfetch(DBselect('select name FROM sysmaps WHERE sysmapid=' . $db_element["elementid"]));
                $el_name = $db_map['name'];
                if (!isset($tr_info[TRIGGER_VALUE_FALSE])) {
                    $tr_info[TRIGGER_VALUE_FALSE]['count'] = 0;
                    $tr_info[TRIGGER_VALUE_FALSE]['priority'] = 0;
                    $tr_info[TRIGGER_VALUE_FALSE]['info'] = 'OK';
                }
            }
        }
    }
    if (isset($tr_info[TRIGGER_VALUE_TRUE])) {
        $inf =& $tr_info[TRIGGER_VALUE_TRUE];
        $out['type'] = TRIGGER_VALUE_TRUE;
        $out['info'] = 'PROBLEM';
        if ($inf['count'] > 1) {
            $out['info'] = $inf['count'] . ' problems';
        } else {
            if (isset($inf['info'])) {
                $out['info'] = $inf['info'];
            }
        }
        if (isset($inf['priority']) && $inf['priority'] > 3) {
            $out['color'] = $colors['Red'];
        } else {
            $out['color'] = $colors['Dark Red'];
        }
        $out['iconid'] = $db_element['iconid_on'];
    } else {
        if (isset($tr_info[TRIGGER_VALUE_UNKNOWN]) && !isset($tr_info[TRIGGER_VALUE_FALSE])) {
            $inf =& $tr_info[TRIGGER_VALUE_UNKNOWN];
            $out['type'] = TRIGGER_VALUE_UNKNOWN;
            $out['info'] = 'UNKNOWN';
            $out['color'] = $colors['Gray'];
            if (isset($out['disabled']) && $out['disabled'] == 1) {
                $out['iconid'] = $db_element['iconid_disabled'];
            } else {
                $out['iconid'] = $db_element['iconid_unknown'];
            }
            if (isset($inf['info'])) {
                $out['info'] = $inf['info'];
            }
        } else {
            $inf =& $tr_info[TRIGGER_VALUE_FALSE];
            $out['type'] = TRIGGER_VALUE_FALSE;
            $out['info'] = 'OK';
            if (isset($inf['info'])) {
                $out['info'] = 'OK';
            }
            $out['color'] = $colors['Dark Green'];
            $out['iconid'] = $db_element['iconid_off'];
        }
    }
    // No label for Images
    if ($el_type == SYSMAP_ELEMENT_TYPE_IMAGE) {
        $out['info'] = '';
    }
    $out['count'] = $inf['count'];
    $out['priority'] = isset($inf['priority']) ? $inf['priority'] : 0;
    $out['name'] = $el_name;
    return $out;
}