示例#1
0
function host_summary($hosts)
{
    global $CONFIG;
    $rrd = new RRDTool($CONFIG['rrdtool']);
    echo "<table class=\"summary\">\n";
    $row_style = array(0 => "even", 1 => "odd");
    $host_counter = 0;
    foreach ($hosts as $host) {
        $host_counter++;
        printf('<tr class="%s">', $row_style[$host_counter % 2]);
        printf('<th><a href="%s/host.php?h=%s">%s</a></th>', $CONFIG['weburl'], $host, $host);
        if ($CONFIG['showload']) {
            collectd_flush(sprintf('%s/load/load', $host));
            $rrd_info = $rrd->rrd_info($CONFIG['datadir'] . '/' . $host . '/load/load.rrd');
            # ignore if file does not exist
            if (!$rrd_info) {
                continue;
            }
            if (isset($rrd_info['ds[shortterm].last_ds']) && isset($rrd_info['ds[midterm].last_ds']) && isset($rrd_info['ds[longterm].last_ds'])) {
                printf('<td>%.2f</td><td>%.2f</td><td>%.2f</td>', $rrd_info['ds[shortterm].last_ds'], $rrd_info['ds[midterm].last_ds'], $rrd_info['ds[longterm].last_ds']);
            }
        }
        print "</tr>\n";
    }
    echo "</table>\n";
}
示例#2
0
if ($tinylegend) {
    $opts['tinylegend'] = 1;
}
$rrd_cmd = false;
if (isset($MetaGraphDefs[$type])) {
    $identifiers = array();
    foreach ($all_tinst as &$atinst) {
        $identifiers[] = collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, $atinst);
    }
    collectd_flush($identifiers);
    $rrd_cmd = $MetaGraphDefs[$type]($host, $plugin, $pinst, $type, $all_tinst, $opts);
} else {
    if (!in_array(is_null($tinst) ? '' : $tinst, $all_tinst)) {
        return error404($host . '/' . $plugin . (!is_null($pinst) ? '-' . $pinst : '') . '/' . $type . (!is_null($tinst) ? '-' . $tinst : ''), "No rrd file found for graphing");
    }
    collectd_flush(collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, is_null($tinst) ? '' : $tinst));
    if (isset($GraphDefs[$type])) {
        $rrd_cmd = collectd_draw_generic($timespan, $host, $plugin, $pinst, $type, $tinst);
    } else {
        $rrd_cmd = collectd_draw_rrd($host, $plugin, $pinst, $type, $tinst);
    }
}
if (isset($rrd_cmd)) {
    if ($vars['from']) {
        $from = $vars['from'];
    }
    if ($vars['to']) {
        $to = $vars['to'];
    }
    $rrd_cmd .= " -s " . escapeshellarg($from) . " -e " . escapeshellarg($to);
}
示例#3
0
文件: ping.php 项目: jrottenberg/cgp
require_once 'inc/collectd.inc.php';
## LAYOUT
# ping/
# ping/ping-<host>.rrd
# ping/ping_stddev-<host>.rrd
# ping/ping_droprate-<host>.rrd
$obj = new Type_Default($CONFIG);
$obj->data_sources = array('value');
$obj->ds_names = array('ping' => 'Ping time', 'ping_stddev' => 'Ping stddev', 'ping_droprate' => 'Ping droprate');
$obj->width = $width;
$obj->heigth = $heigth;
$obj->rrd_format = '%5.1lf';
switch ($obj->args['type']) {
    case 'ping':
        if ($CONFIG['version'] < 5) {
            $obj->data_sources = array('ping');
        }
        $obj->rrd_title = 'Ping latency';
        $obj->rrd_vertical = 'Milliseconds';
        break;
    case 'ping_stddev':
        $obj->rrd_title = 'Ping stddev';
        $obj->rrd_vertical = '';
        break;
    case 'ping_droprate':
        $obj->rrd_title = 'Ping droprate';
        $obj->rrd_vertical = '';
        break;
}
collectd_flush($obj->identifiers);
$obj->rrd_graph();