$descr_len = 12 + round(($width - 275) / 8);
}
// FIXME str_pad really needs a "limit to length" so we can rid of all the substrs all over the code to limit the length as below...
if ($width > '500') {
    $rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . " RTT      Loss    SDev   RTT\\:SDev\\l'";
} else {
    $rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . " RTT      Loss    SDev   RTT\\:SDev\\l'";
}
foreach ($smokeping_files[$direction][$device['hostname']] as $source => $filename) {
    if (!isset($config['graph_colours'][$colourset][$iter])) {
        $iter = 0;
    }
    $colour = $config['graph_colours'][$colourset][$iter];
    $iter++;
    $descr = rrdtool_escape($source, $descr_len);
    $filename = generate_smokeping_file($device, $filename);
    $rrd_options .= " DEF:median{$i}=" . $filename . ':median:AVERAGE ';
    $rrd_options .= " CDEF:dm{$i}=median{$i},UN,0,median{$i},IF";
    $rrd_options .= " DEF:loss{$i}=" . $filename . ':loss:AVERAGE';
    $rrd_options .= " CDEF:ploss{$i}=loss{$i},{$pings},/,100,*";
    // $rrd_options .= " CDEF:dm$i=median$i";
    // $rrd_options .= " CDEF:dm$i=median$i,0,".$max->{$start}.",LIMIT";
    // start emulate Smokeping::calc_stddev
    foreach (range(1, $pings) as $p) {
        $rrd_options .= ' DEF:pin' . $i . 'p' . $p . '=' . $filename . ':ping' . $p . ':AVERAGE';
        $rrd_options .= ' CDEF:p' . $i . 'p' . $p . '=pin' . $i . 'p' . $p . ',UN,0,pin' . $i . 'p' . $p . ',IF';
    }
    unset($pings_options, $m_options, $sdev_options);
    foreach (range(2, $pings) as $p) {
        $pings_options .= ',p' . $i . 'p' . $p . ',UN,+';
        $m_options .= ',p' . $i . 'p' . $p . ',+';
Exemplo n.º 2
0
function get_smokeping_files($device)
{
    global $config;
    $smokeping_files = array();
    if (isset($config['smokeping']['dir'])) {
        $smokeping_dir = generate_smokeping_file($device);
        if ($handle = opendir($smokeping_dir)) {
            while (false !== ($file = readdir($handle))) {
                if ($file != '.' && $file != '..') {
                    if (eregi('.rrd', $file)) {
                        if (eregi('~', $file)) {
                            list($target, $slave) = explode('~', str_replace('.rrd', '', $file));
                            $target = str_replace('_', '.', $target);
                            $smokeping_files['in'][$target][$slave] = $file;
                            $smokeping_files['out'][$slave][$target] = $file;
                        } else {
                            $target = str_replace('.rrd', '', $file);
                            $target = str_replace('_', '.', $target);
                            $smokeping_files['in'][$target][$config['own_hostname']] = $file;
                            $smokeping_files['out'][$config['own_hostname']][$target] = $file;
                        }
                    }
                }
            }
        }
    }
    return $smokeping_files;
}
Exemplo n.º 3
0
require 'smokeping_common.inc.php';
$i = 0;
$pings = $config['smokeping']['pings'];
$iter = 0;
$colourset = 'mixed';
if ($width > '500') {
    $descr_len = 18;
} else {
    $descr_len = 12 + round(($width - 275) / 8);
}
if ($width > '500') {
    $rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . " RTT      Loss    SDev   RTT\\:SDev                              \\l'";
} else {
    $rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . " RTT      Loss    SDev   RTT\\:SDev                              \\l'";
}
$filename_dir = generate_smokeping_file($device);
if ($src['hostname'] == $config['own_hostname']) {
    $filename = $filename_dir . $device['hostname'] . '.rrd';
    if (!file_exists($filename_dir . $device['hostname'] . '.rrd')) {
        // Try with dots in hostname replaced by underscores
        $filename = $filename_dir . str_replace('.', '_', $device['hostname']) . '.rrd';
    }
} else {
    $filename = $filename_dir . $device['hostname'] . '~' . $src['hostname'] . '.rrd';
    if (!file_exists($filename)) {
        // Try with dots in hostname replaced by underscores
        $filename = $filename_dir . str_replace('.', '-', $device['hostname']) . '~' . $src['hostname'] . '.rrd';
    }
}
if (!isset($config['graph_colours'][$colourset][$iter])) {
    $iter = 0;