当前位置: 首页>>代码示例>>PHP>>正文


PHP rrdtool_pipe_close函数代码示例

本文整理汇总了PHP中rrdtool_pipe_close函数的典型用法代码示例。如果您正苦于以下问题:PHP rrdtool_pipe_close函数的具体用法?PHP rrdtool_pipe_close怎么用?PHP rrdtool_pipe_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rrdtool_pipe_close函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: print_cli_data

    print_cli_data('Poller Time', $poller_time . " secs", 0);
    print_cli_data('Memory usage', formatStorage(memory_get_usage(TRUE), 2, 4) . ' (peak: ' . formatStorage(memory_get_peak_usage(TRUE), 2, 4) . ')', 0);
    $mysql_time = 0;
    foreach ($db_stats as $cmd => $count) {
        if (isset($db_stats[$cmd . '_sec'])) {
            $mysql_times[] = ucfirst(str_replace("fetch", "", $cmd)) . "[" . $count . "/" . round($db_stats[$cmd . '_sec'], 3) . "s]";
            $mysql_time += $db_stats[$cmd . '_sec'];
        }
    }
    print_cli_data('MySQL Usage', implode(" ", $mysql_times) . ' (' . round($mysql_time, 3) . 's ' . round($mysql_time / $poller_time * 100, 3) . '%)', 0);
    $rrd_time = 0;
    foreach ($GLOBALS['rrdtool'] as $cmd => $data) {
        $rrd_times[] = $cmd . "[" . $data['count'] . "/" . round($data['time'], 3) . "s]";
        $rrd_time += $data['time'];
    }
    print_cli_data('RRDTool Usage', implode(" ", $rrd_times) . ' (' . round($rrd_time, 3) . 's ' . round($rrd_time / $poller_time * 100, 3) . '%)', 0);
    $snmp_time = 0;
    foreach ($GLOBALS['snmp_stats'] as $cmd => $data) {
        $snmp_times[] = $cmd . "[" . $data['count'] . "/" . round($data['time'], 3) . "s]";
        $snmp_time += $data['time'];
    }
    print_cli_data('SNMP Usage', implode(" ", $snmp_times) . ' (' . round($snmp_time, 3) . 's ' . round($snmp_time / $poller_time * 100, 3) . '%)', 0);
}
logfile($string);
rrdtool_pipe_close($rrd_process, $rrd_pipes);
unset($config);
// Remove this for testing
#print_vars(get_defined_vars());
echo "\n";
print_r($runtime_stats);
// EOF
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:poller.php

示例2: rrdtool_graph

/**
 * Generates a graph file at $graph_file using $options
 * Opens its own rrdtool pipe.
 *
 * @return integer
 * @param  string graph_file
 * @param  string options
 */
function rrdtool_graph($graph_file, $options)
{
    global $config, $debug;
    rrdtool_pipe_open($rrd_process, $rrd_pipes);
    if (is_resource($rrd_process)) {
        // $pipes now looks like this:
        // 0 => writeable handle connected to child stdin
        // 1 => readable handle connected to child stdout
        // Any error output will be appended to /tmp/error-output.txt
        if ($config['rrdcached']) {
            if (isset($config['rrdcached_dir']) && $config['rrdcached_dir'] !== false) {
                $options = str_replace($config['rrd_dir'] . '/', './' . $config['rrdcached_dir'] . '/', $options);
                $options = str_replace($config['rrd_dir'], './' . $config['rrdcached_dir'] . '/', $options);
            }
            fwrite($rrd_pipes[0], 'graph --daemon ' . $config['rrdcached'] . " {$graph_file} {$options}");
        } else {
            fwrite($rrd_pipes[0], "graph {$graph_file} {$options}");
        }
        fclose($rrd_pipes[0]);
        while (strlen($line) < 1) {
            $line = fgets($rrd_pipes[1], 1024);
            $data .= $line;
        }
        $return_value = rrdtool_pipe_close($rrd_process, $rrd_pipes);
        if ($debug) {
            echo '<p>';
            if ($debug) {
                echo "graph {$graph_file} {$options}";
            }
            echo '</p><p>';
            echo "command returned {$return_value} ({$data})\n";
            echo '</p>';
        }
        return $data;
    } else {
        return 0;
    }
}
开发者ID:kelixin,项目名称:librenms,代码行数:46,代码来源:rrdtool.inc.php

示例3: rrdtool_graph

function rrdtool_graph($graph_file, $options)
{
    global $config;
    // Note, always use pipes, because standard command line has limits!
    if ($config['rrdcached']) {
        $cmd = 'graph --daemon ' . $config['rrdcached'] . " {$graph_file} {$options}";
    } else {
        $cmd = "graph {$graph_file} {$options}";
    }
    $GLOBALS['rrd_status'] = FALSE;
    $GLOBALS['exec_status'] = array('command' => $config['rrdtool'] . ' ' . $cmd, 'stdout' => '', 'exitcode' => -1);
    $start = microtime(TRUE);
    rrdtool_pipe_open($rrd_process, $rrd_pipes);
    if (is_resource($rrd_process)) {
        // $pipes now looks like this:
        // 0 => writeable handle connected to child stdin
        // 1 => readable handle connected to child stdout
        // Any error output will be appended to /tmp/error-output.txt
        fwrite($rrd_pipes[0], $cmd);
        fclose($rrd_pipes[0]);
        $iter = 0;
        while (strlen($line) < 1 && $iter < 1000) {
            // wait for 10 milliseconds to loosen loop
            usleep(10000);
            $line = fgets($rrd_pipes[1], 1024);
            $stdout .= $line;
            $iter++;
        }
        $stdout = preg_replace('/(?:\\n|\\r\\n|\\r)$/D', '', $stdout);
        // remove last (only) eol
        unset($iter);
        $runtime = microtime(TRUE) - $start;
        // Check rrdtool's output for the command.
        if (preg_match('/\\d+x\\d+/', $stdout)) {
            $GLOBALS['rrd_status'] = TRUE;
        } else {
            $stderr = trim(stream_get_contents($rrd_pipes[2]));
            if (isset($config['rrd']['debug']) && $config['rrd']['debug']) {
                logfile('rrd.log', "RRD {$stderr}, CMD: " . $GLOBALS['exec_status']['command']);
            }
        }
        $exitcode = rrdtool_pipe_close($rrd_process, $rrd_pipes);
        $GLOBALS['exec_status']['exitcode'] = $exitcode;
        $GLOBALS['exec_status']['stdout'] = $stdout;
        $GLOBALS['exec_status']['stderr'] = $stderr;
    } else {
        $runtime = microtime(TRUE) - $start;
        $stdout = NULL;
    }
    $GLOBALS['exec_status']['runtime'] = $runtime;
    // Add some data to global array $graph_return
    $GLOBALS['graph_return']['status'] = $GLOBALS['rrd_status'];
    $GLOBALS['graph_return']['command'] = $GLOBALS['exec_status']['command'];
    $GLOBALS['graph_return']['filename'] = $graph_file;
    $GLOBALS['graph_return']['output'] = $stdout;
    $GLOBALS['graph_return']['runtime'] = $GLOBALS['exec_status']['runtime'];
    if (OBS_DEBUG) {
        print_message(PHP_EOL . 'RRD CMD[%y' . $cmd . '%n]', 'console', FALSE);
        $debug_msg = 'RRD RUNTIME[' . ($runtime > 0.1 ? '%r' : '%g') . round($runtime, 4) . 's%n]' . PHP_EOL;
        $debug_msg .= 'RRD STDOUT[' . ($GLOBALS['rrd_status'] ? '%g' : '%r') . $stdout . '%n]' . PHP_EOL;
        if ($stderr) {
            $debug_msg .= 'RRD STDERR[%r' . $stderr . '%n]' . PHP_EOL;
        }
        $debug_msg .= 'RRD_STATUS[' . ($GLOBALS['rrd_status'] ? '%gTRUE' : '%rFALSE') . '%n]';
        print_message($debug_msg . PHP_EOL, 'console');
    }
    return $stdout;
}
开发者ID:Natolumin,项目名称:observium,代码行数:68,代码来源:rrdtool.inc.php

示例4: rrdtool_graph

function rrdtool_graph($graph_file, $options)
{
    global $config, $debug;
    rrdtool_pipe_open($rrd_process, $rrd_pipes);
    if (is_resource($rrd_process)) {
        // $pipes now looks like this:
        // 0 => writeable handle connected to child stdin
        // 1 => readable handle connected to child stdout
        // Any error output will be appended to /tmp/error-output.txt
        if ($config['rrdcached']) {
            fwrite($rrd_pipes[0], "graph --daemon " . $config['rrdcached'] . " {$graph_file} {$options}");
        } else {
            fwrite($rrd_pipes[0], "graph {$graph_file} {$options}");
        }
        fclose($rrd_pipes[0]);
        $iter = 0;
        while (strlen($line) < 1 && $iter < 1000) {
            // wait for 10 milliseconds to loosen loop
            usleep(10000);
            $line = fgets($rrd_pipes[1], 1024);
            $data .= $line;
            $iter++;
        }
        unset($iter);
        $return_value = rrdtool_pipe_close($rrd_process, $rrd_pipes);
        if ($debug) {
            echo "<p>";
            if ($debug) {
                echo "graph {$graph_file} {$options}";
            }
            echo "</p><p>";
            echo "command returned {$return_value} ({$data})\n";
            echo "</p>";
        }
        return $data;
    } else {
        return 0;
    }
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:39,代码来源:rrdtool.inc.php

示例5: rrdtool_graph_xport

function rrdtool_graph_xport($options)
{
    global $config;
    $debug = 1;
    header('Content-type: text/html');
    if (substr_count($options, '--alt-autoscale-max') > 1) {
        $options = substr($options, strripos($options, '--alt-autoscale-max'));
    }
    $options = str_replace(array('--alt-autoscale-max ', '--rigid ', '-E'), '', $options);
    $options = preg_replace(array('/--(width|height)\\s[\\d]+/', '/-c\\s[^\\s]+/', '/--font\\s[^\\s]+/', '/--font-render-mode\\s[^\\s]+/', '/-R\\s[^\\s]+/'), '', $options);
    $xport = "";
    if (preg_match_all("/(?<=\\s)DEF:[\\s]?([a-zA-Z]+)(?==)/", $options, $matches)) {
        $def = $matches[1];
        foreach ($def as $d) {
            $xport .= "XPORT:" . $d . ":" . "\"" . str_replace(":", "", $d) . "\" ";
        }
    }
    rrdtool_pipe_open($rrd_process, $rrd_pipes);
    if (is_resource($rrd_process)) {
        // $pipes now looks like this:
        // 0 => writeable handle connected to child stdin
        // 1 => readable handle connected to child stdout
        // Any error output will be appended to /tmp/error-output.txt
        fwrite($rrd_pipes[0], "xport {$graph_file} {$options} {$xport}");
        fclose($rrd_pipes[0]);
        while (strlen($line) < 1) {
            // wait for 10 milliseconds to loosen loop
            usleep(10000);
            $line = fgets($rrd_pipes[1], 1024);
            $data .= $line;
        }
        $return_value = rrdtool_pipe_close($rrd_process, $rrd_pipes);
        return $data;
    } else {
        return 0;
    }
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:37,代码来源:hb_api.php


注:本文中的rrdtool_pipe_close函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。