Ejemplo n.º 1
0
$res = $dbb->query($query);
$nbRows = $dbb->numberRows();
$data = array();
$outputLength = $preferences['output_length'] ? $preferences['output_length'] : 50;
$hostObj = new CentreonHost($db);
$svcObj = new CentreonService($db);
$gmt = new CentreonGMT($db);
$gmt->getMyGMTFromSession(session_id(), $db);
while ($row = $res->fetchRow()) {
    foreach ($row as $key => $value) {
        if ($key == "last_check") {
            $value = $gmt->getDate("Y-m-d H:i:s", $value);
            //$value = date("Y-m-d H:i:s", $value);
        } elseif ($key == "last_state_change" || $key == "last_hard_state_change") {
            $value = time() - $value;
            $value = CentreonDuration::toString($value);
        } elseif ($key == "check_attempt") {
            $value = $value . "/" . $row['max_check_attempts'] . ' (' . $aStateType[$row['state_type']] . ')';
        } elseif ($key == "s_state") {
            $data[$row['host_id'] . "_" . $row['service_id']]['color'] = $stateSColors[$value];
            $value = $stateLabels[$value];
        } elseif ($key == "h_state") {
            $data[$row['host_id'] . "_" . $row['service_id']]['hcolor'] = $stateHColors[$value];
            $value = $stateLabels[$value];
        } elseif ($key == "output") {
            $value = substr($value, 0, $outputLength);
        } elseif (($key == "h_action_url" || $key == "h_notes_url") && $value) {
            $value = urlencode($hostObj->replaceMacroInString($row['hostname'], $value));
        } elseif (($key == "s_action_url" || $key == "s_notes_url") && $value) {
            $value = $hostObj->replaceMacroInString($row['hostname'], $value);
            $value = urlencode($svcObj->replaceMacroInString($row['service_id'], $value));
Ejemplo n.º 2
0
            }
        }
        // Display Host problems
        $problemList = $gmapObj->getHostProblemsForHostGroup($marker["name"]);
        if (count($problemList)) {
            $popupString .= "<br/><b><u>" . _("Details Problems:") . "</u></b>" . "<br/>";
            foreach ($problemList as $key => $value) {
                $popupString .= "{$key} is <font color='" . $gmapObj->getHostStateColor($value["state"]) . "'>" . $gmapObj->getHostStateString($value['state']) . "</font> (" . CentreonDuration::toString(time() - $value['last_hard_state_change']) . ")<br/>";
            }
        }
        // Display Service problems
        $problemList = $gmapObj->getProblemsForHostGroup($marker["name"]);
        if (count($problemList)) {
            $popupString .= "<br/><b><u>" . _("Details Problems:") . "</u></b>" . "<br/>";
            foreach ($problemList as $key => $value) {
                $popupString .= "{$key} is <font color='" . $tabColorServices[$value["state"]] . "'>" . $serviceState[$value['state']] . "</font> (" . CentreonDuration::toString(time() - $value['last_hard_state_change']) . ")<br/>";
            }
        }
        /* 
         * Get HG Filter ids.
         */
        $hostGroupIDList = $gmapObj->getHostGroupIDList($marker['name']);
        $popupString .= "<br/><br/><center><a href='?p=20201&o=svc&hostgroup={$hostGroupIDList}'>" . _("Show Services Details") . "</a></center>";
    }
    $newnode2 = $node->appendChild($dom->createTextNode($popupString));
}
$DBRESULT->free();
/*
 * Send HEader
 */
header("Content-type: text/xml");
Ejemplo n.º 3
0
 public function loadSelection($db_storage = null, $cmd, $selection)
 {
     global $centreon_bg;
     if (is_null($db_storage)) {
         $db_storage = new CentreonDB('centstorage');
     }
     $selected_values = explode(',', $selection);
     $selected = array('host_selected' => array(), 'service_selected' => array());
     if ($cmd == 3) {
         $selected_str = '';
         $selected_str_append = '';
         foreach ($selected_values as $value) {
             $str = explode(';', $value);
             $selected_str .= $selected_str_append . 'services.host_id = ' . $str[0] . ' AND services.service_id = ' . $str[1];
             $selected_str_append = ' OR ';
         }
         $query = "SELECT services.*, hosts.state as host_state, hosts.name as host_name, hosts.instance_id FROM services, hosts";
         $query_where = " WHERE (" . $selected_str . ') AND services.host_id = hosts.host_id';
         if (!$centreon_bg->is_admin) {
             $query_where .= " AND EXISTS(SELECT * FROM centreon_acl WHERE centreon_acl.group_id IN (" . $centreon_bg->grouplistStr . ") AND hosts.host_id = centreon_acl.host_id \n                AND services.service_id = centreon_acl.service_id)";
         }
         $DBRESULT = $db_storage->query($query . $query_where);
         while ($row = $DBRESULT->fetchRow()) {
             $row['service_state'] = $row['state'];
             $row['state_str'] = $this->getServiceStateStr($row['state']);
             $row['last_state_change_duration'] = CentreonDuration::toString(time() - $row['last_state_change']);
             $row['last_hard_state_change_duration'] = CentreonDuration::toString(time() - $row['last_hard_state_change']);
             $selected['service_selected'][] = $row;
         }
     } else {
         if ($cmd == 4) {
             $hosts_selected_str = '';
             $hosts_selected_str_append = '';
             foreach ($selected_values as $value) {
                 $str = explode(';', $value);
                 $hosts_selected_str .= $hosts_selected_str_append . $str[0];
                 $hosts_selected_str_append = ', ';
             }
             $query = "SELECT * FROM hosts";
             $query_where = " WHERE host_id IN (" . $hosts_selected_str . ")";
             if (!$centreon_bg->is_admin) {
                 $query_where .= " AND EXISTS(SELECT * FROM centreon_acl WHERE centreon_acl.group_id IN (" . $centreon_bg->grouplistStr . ") AND hosts.host_id = centreon_acl.host_id)";
             }
             $DBRESULT = $db_storage->query($query . $query_where);
             while ($row = $DBRESULT->fetchRow()) {
                 $row['host_state'] = $row['state'];
                 $row['state_str'] = $this->getHostStateStr($row['state']);
                 $row['last_state_change_duration'] = CentreonDuration::toString(time() - $row['last_state_change']);
                 $row['last_hard_state_change_duration'] = CentreonDuration::toString(time() - $row['last_hard_state_change']);
                 $selected['host_selected'][] = $row;
             }
         }
     }
     return $selected;
 }