Exemple #1
0
     while ($host = DBfetch($db_hosts)) {
         $el_table = new CTableInfo(S_ONLY_HOST_INFO);
         $sqls = array(S_TEMPLATE => !isset($templates[$host['hostid']]) ? null : 'SELECT MIN(ht.hostid) as hostid, h.host as info, count(distinct ht.hosttemplateid) as cnt ' . ' FROM hosts h, hosts_templates ht ' . ' WHERE ht.templateid = h.hostid ' . ' GROUP BY h.host', S_ITEM => !isset($items[$host['hostid']]) ? null : 'SELECT hostid, description as info, 1 as cnt ' . ' FROM items' . ' WHERE hostid=' . $host['hostid'], S_TRIGGER => !isset($triggers[$host['hostid']]) ? null : 'SELECT i.hostid, t.description as info, count(distinct i.hostid) as cnt, f.triggerid ' . ' FROM functions f, items i, triggers t' . ' WHERE t.triggerid=f.triggerid' . ' AND f.itemid=i.itemid' . ' GROUP BY f.triggerid, i.hostid, t.description', S_GRAPH => !isset($graphs[$host['hostid']]) ? null : 'SELECT MIN(g.name) as info, i.hostid, count(distinct i.hostid) as cnt, gi.graphid' . ' FROM graphs_items gi, items i, graphs g ' . ' WHERE g.graphid=gi.graphid ' . ' AND gi.itemid=i.itemid' . ' GROUP BY gi.graphid, i.hostid');
         foreach ($sqls as $el_type => $sql) {
             if (!isset($sql)) {
                 continue;
             }
             $db_els = DBselect($sql);
             while ($el = DBfetch($db_els)) {
                 if ($el['cnt'] != 1 || bccomp($el['hostid'], $host['hostid']) != 0) {
                     continue;
                 }
                 $el_table->AddRow(array($el_type, $el['info']));
             }
         }
         $table->ShowRow(array(new CCol($host['host'], 'top'), $el_table));
         unset($el_table);
     }
     $form = new CForm(null, 'post');
     $form->setName('hosts');
     $form->addVar("config", $config);
     $form->addVar('update', true);
     $form->addVar('hosts', $hosts);
     $form->addVar('templates', $templates);
     $form->addVar('items', $items);
     $form->addVar('graphs', $graphs);
     $form->addVar('triggers', $triggers);
     $form->addItem(array(new CButton('back', S_BACK), new CButton('preview', S_REFRESH), new CButton('export', S_EXPORT)));
     $table->setFooter(new CCol($form));
     $table->showEnd();
 } else {
Exemple #2
0
             }
             if ($row["valuemapid"] > 0) {
                 $value = replace_value_by_map($row["value"], $row["valuemapid"]);
             } else {
                 $value = $row["value"];
             }
             $new_row = array(date("Y.M.d H:i:s", $row["clock"]));
             if (str_in_array($item_type, array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64))) {
                 array_push($new_row, $value);
             } else {
                 $pre = new CTag('pre', 'yes');
                 $pre->AddItem($value);
                 array_push($new_row, $pre);
             }
             if (!isset($_REQUEST["plaintext"])) {
                 $table->ShowRow($new_row);
             } else {
                 echo date("Y-m-d H:i:s", $row["clock"]);
                 echo "\t" . $row["clock"] . "\t" . htmlspecialchars($row["value"]) . "\n";
             }
         }
         if (!isset($_REQUEST["plaintext"])) {
             $table->ShowEnd();
             // to solve memory leak we call 'Show' method by steps
             echo SBR;
         } else {
             echo "</pre>";
         }
         COpt::profiling_stop("history");
     }
 }