コード例 #1
0
ファイル: history.php プロジェクト: songyuanjie/zabbix-stats
         $ptData['body'][] = "\t" . $data['clock'] . "\t" . htmlspecialchars($data['value']) . "\n";
     }
 } else {
     // NUMERIC, FLOAT
     $table = new CTableInfo();
     $table->setHeader(array(S_TIMESTAMP, S_VALUE));
     $options['sortfield'] = 'clock';
     $hData = CHistory::get($options);
     foreach ($hData as $hnum => $data) {
         $item = $items[$data['itemid']];
         $host = reset($item['hosts']);
         if (!isset($data['value'])) {
             $data['value'] = '';
         }
         if ($item['valuemapid'] > 0) {
             $value = replace_value_by_map($data['value'], $item['valuemapid']);
             $value_mapped = true;
         } else {
             $value = $data['value'];
             $value_mapped = false;
         }
         if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT && !$value_mapped) {
             sscanf($data['value'], '%f', $value);
         }
         $table->addRow(array(zbx_date2str(S_HISTORY_ITEM_DATE_FORMAT, $data['clock']), zbx_nl2br($value)));
         // Plaintext
         if (!isset($_REQUEST['plaintext'])) {
             continue;
         }
         if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT) {
             sscanf($data['value'], '%f', $value);
コード例 #2
0
function get_screen_plaintext($itemid, $elements, $style = 0)
{
    if ($itemid == 0) {
        $table = new CTableInfo(S_ITEM_DOES_NOT_EXIST);
        $table->setHeader(array(S_TIMESTAMP, S_ITEM));
        return $table;
    }
    $item = get_item_by_itemid($itemid);
    switch ($item['value_type']) {
        case ITEM_VALUE_TYPE_TEXT:
        case ITEM_VALUE_TYPE_LOG:
            $order_field = 'id';
            break;
        case ITEM_VALUE_TYPE_FLOAT:
        case ITEM_VALUE_TYPE_UINT64:
        default:
            $order_field = 'clock';
    }
    $host = get_host_by_itemid($itemid);
    $table = new CTableInfo();
    $table->setHeader(array(S_TIMESTAMP, $host['host'] . ': ' . item_description($item)));
    $options = array('history' => $item['value_type'], 'itemids' => $itemid, 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN, 'sortfield' => $order_field, 'limit' => $elements);
    $hData = CHistory::get($options);
    foreach ($hData as $hnum => $data) {
        switch ($item['value_type']) {
            case ITEM_VALUE_TYPE_TEXT:
                /* do not use break */
            /* do not use break */
            case ITEM_VALUE_TYPE_STR:
                if ($style) {
                    $value = new CJSscript($data['value']);
                } else {
                    $value = $data['value'];
                }
                break;
            case ITEM_VALUE_TYPE_LOG:
                if ($style) {
                    $value = new CJSscript($data['value']);
                } else {
                    $value = $data['value'];
                }
                break;
            default:
                $value = $data['value'];
                break;
        }
        if ($item['valuemapid'] > 0) {
            $value = replace_value_by_map($value, $item['valuemapid']);
        }
        $table->addRow(array(zbx_date2str(S_SCREENS_PLAIN_TEXT_DATE_FORMAT, $data['clock']), new CCol($value, 'pre')));
    }
    return $table;
}
コード例 #3
0
ファイル: screens.inc.php プロジェクト: phedders/zabbix
function get_screen_plaintext($itemid, $elements, $style = 0)
{
    if ($itemid == 0) {
        $table = new CTableInfo(S_ITEM_DOES_NOT_EXIST);
        $table->setHeader(array(S_TIMESTAMP, S_ITEM));
        return $table;
    }
    global $DB;
    $item = get_item_by_itemid($itemid);
    switch ($item['value_type']) {
        case ITEM_VALUE_TYPE_FLOAT:
            $history_table = 'history';
            $order_field = 'clock';
            break;
        case ITEM_VALUE_TYPE_UINT64:
            $history_table = 'history_uint';
            $order_field = 'clock';
            break;
        case ITEM_VALUE_TYPE_TEXT:
            $history_table = 'history_text';
            $order_field = 'id';
            break;
        case ITEM_VALUE_TYPE_LOG:
            $history_table = 'history_log';
            $order_field = 'id';
            break;
        default:
            $history_table = 'history_str';
            $order_field = 'clock';
            break;
    }
    $sql = 'SELECT h.clock,h.value,i.valuemapid ' . ' FROM ' . $history_table . ' h, items i ' . ' WHERE h.itemid=i.itemid ' . ' AND i.itemid=' . $itemid . ' ORDER BY h.' . $order_field . ' DESC';
    $result = DBselect($sql, $elements);
    $host = get_host_by_itemid($itemid);
    $table = new CTableInfo();
    $table->setHeader(array(S_TIMESTAMP, $host['host'] . ': ' . item_description($item)));
    while ($row = DBfetch($result)) {
        switch ($item['value_type']) {
            case ITEM_VALUE_TYPE_TEXT:
                if ($DB['TYPE'] == 'ORACLE') {
                    if (isset($row['value'])) {
                        $row['value'] = $row['value']->load();
                    } else {
                        $row['value'] = '';
                    }
                }
                /* do not use break */
            /* do not use break */
            case ITEM_VALUE_TYPE_STR:
                if ($style) {
                    $value = new CScript($row['value']);
                } else {
                    $value = nbsp(htmlspecialchars($row['value']));
                    $value = zbx_nl2br($value);
                }
                break;
            case ITEM_VALUE_TYPE_LOG:
                if ($style) {
                    $value = new CScript($row['value']);
                } else {
                    $value = nbsp(htmlspecialchars($row['value']));
                    $value = zbx_nl2br($value);
                }
                break;
            default:
                $value = $row['value'];
                break;
        }
        if ($row['valuemapid'] > 0) {
            $value = replace_value_by_map($value, $row['valuemapid']);
        }
        $table->AddRow(array(date(S_DATE_FORMAT_YMDHMS, $row['clock']), $value));
    }
    return $table;
}
コード例 #4
0
ファイル: items.inc.php プロジェクト: rennhak/zabbix
function format_lastvalue($db_item)
{
    if ($db_item["value_type"] == ITEM_VALUE_TYPE_LOG) {
        $row = DBfetch(DBselect('SELECT value FROM history_log WHERE itemid=' . $db_item['itemid'] . ' ORDER BY clock DESC', 1));
        if ($row) {
            $lastvalue = $row['value'];
            if (strlen($lastvalue) > 20) {
                $lastvalue = substr($lastvalue, 0, 20) . " ...";
            }
            $lastvalue = nbsp(htmlspecialchars($lastvalue));
        } else {
            $lastvalue = '-';
        }
    } else {
        if (isset($db_item["lastvalue"])) {
            if ($db_item["value_type"] == ITEM_VALUE_TYPE_FLOAT) {
                $lastvalue = convert_units($db_item["lastvalue"], $db_item["units"]);
            } else {
                if ($db_item["value_type"] == ITEM_VALUE_TYPE_UINT64) {
                    $lastvalue = convert_units($db_item["lastvalue"], $db_item["units"]);
                } else {
                    if ($db_item["value_type"] == ITEM_VALUE_TYPE_TEXT) {
                        $lastvalue = "...";
                    } else {
                        if ($db_item["value_type"] == ITEM_VALUE_TYPE_STR) {
                            $lastvalue = nbsp(htmlspecialchars(substr($db_item["lastvalue"], 0, 20)));
                            if (strlen($db_item["lastvalue"]) > 20) {
                                $lastvalue .= " ...";
                            }
                        } else {
                            $lastvalue = "Unknown value type";
                        }
                    }
                }
            }
            if ($db_item["valuemapid"] > 0) {
            }
            $lastvalue = replace_value_by_map($lastvalue, $db_item["valuemapid"]);
        } else {
            $lastvalue = "-";
        }
    }
    return $lastvalue;
}
コード例 #5
0
ファイル: history.php プロジェクト: rennhak/zabbix
     $table->ShowStart();
     // to solve memory leak we call 'Show' method by steps
 } else {
     echo "<pre>\n";
 }
 COpt::profiling_start("history");
 while ($row = DBfetch($result)) {
     if ($DB['TYPE'] == "ORACLE" && $item_type == ITEM_VALUE_TYPE_TEXT) {
         if (isset($row["value"])) {
             $row["value"] = $row["value"]->load();
         } else {
             $row["value"] = "";
         }
     }
     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"]);
コード例 #6
0
function format_lastvalue($db_item)
{
    if (isset($db_item["lastvalue"])) {
        if ($db_item["value_type"] == ITEM_VALUE_TYPE_FLOAT) {
            $lastvalue = convert_units($db_item["lastvalue"], $db_item["units"]);
        } else {
            if ($db_item["value_type"] == ITEM_VALUE_TYPE_UINT64) {
                $lastvalue = convert_units($db_item["lastvalue"], $db_item["units"]);
            } else {
                if ($db_item["value_type"] == ITEM_VALUE_TYPE_STR || $db_item["value_type"] == ITEM_VALUE_TYPE_TEXT || $db_item["value_type"] == ITEM_VALUE_TYPE_LOG) {
                    $lastvalue = $db_item["lastvalue"];
                    if (zbx_strlen($lastvalue) > 20) {
                        $lastvalue = zbx_substr($lastvalue, 0, 20) . " ...";
                    }
                    $lastvalue = nbsp(htmlspecialchars($lastvalue));
                } else {
                    $lastvalue = S_UNKNOWN_VALUE_TYPE;
                }
            }
        }
        if ($db_item["valuemapid"] > 0) {
        }
        $lastvalue = replace_value_by_map($lastvalue, $db_item["valuemapid"]);
    } else {
        $lastvalue = "-";
    }
    return $lastvalue;
}
コード例 #7
0
ファイル: history.php プロジェクト: phedders/zabbix
     $table->ShowStart();
     // to solve memory leak we call 'Show' method by steps
 } else {
     echo '<span class="textcolorstyles"><pre>' . "\n";
 }
 COpt::profiling_start('history');
 while ($row = DBfetch($result)) {
     if ($DB['TYPE'] == 'ORACLE' && $item_type == ITEM_VALUE_TYPE_TEXT) {
         if (isset($row['value'])) {
             $row['value'] = $row['value']->load();
         } else {
             $row['value'] = '';
         }
     }
     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']);