Exemplo n.º 1
0
function graph_error($string)
{
    global $vars, $config, $debug, $graphfile;
    $vars['bg'] = 'FFBBBB';
    include 'includes/graphs/common.inc.php';
    $rrd_options .= ' HRULE:0#555555';
    $rrd_options .= " --title='" . $string . "'";
    rrdtool_graph($graphfile, $rrd_options);
    if ($height > '99') {
        shell_exec($rrd_cmd);
        d_echo('<pre>' . $rrd_cmd . '</pre>');
        if (is_file($graphfile) && !$debug) {
            header('Content-type: image/png');
            $fd = fopen($graphfile, 'r');
            fpassthru($fd);
            fclose($fd);
            unlink($graphfile);
            exit;
        }
    } else {
        if (!$debug) {
            header('Content-type: image/png');
        }
        $im = imagecreate($width, $height);
        $px = (imagesx($im) - 7.5 * strlen($string)) / 2;
        imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0));
        imagepng($im);
        imagedestroy($im);
        exit;
    }
}
Exemplo n.º 2
0
function graph_error($string)
{
    global $vars, $config, $debug, $graphfile;
    $vars['bg'] = "FFBBBB";
    include "includes/graphs/common.inc.php";
    $rrd_options .= " HRULE:0#555555";
    $rrd_options .= " --title='" . $string . "'";
    rrdtool_graph($graphfile, $rrd_options);
    if ($height > "99") {
        $woo = shell_exec($rrd_cmd);
        if ($debug) {
            echo "<pre>" . $rrd_cmd . "</pre>";
        }
        if (is_file($graphfile) && !$debug) {
            header('Content-type: image/png');
            $fd = fopen($graphfile, 'r');
            fpassthru($fd);
            fclose($fd);
            unlink($graphfile);
            exit;
        }
    } else {
        if (!$debug) {
            header('Content-type: image/png');
        }
        $im = imagecreate($width, $height);
        $orange = imagecolorallocate($im, 255, 225, 225);
        $px = (imagesx($im) - 7.5 * strlen($string)) / 2;
        imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0));
        imagepng($im);
        imagedestroy($im);
        exit;
    }
}
Exemplo n.º 3
0
 } elseif (isset($vars['command_only']) && $vars['command_only'] == TRUE) {
     $graph_start = utime();
     $return = rrdtool_graph($graphfile, $rrd_options);
     $graph_end = utime();
     $graph_run = $graph_end - $graph_start;
     $graph_time = substr($graph_run, 0, 5);
     $total_end = utime();
     $total_run = $total_end - $total_start;
     $total_time = substr($total_run, 0, 5);
     unlink($graphfile);
     $graph_return['total_time'] = $total_time;
     $graph_return['rrdtool_time'] = $graph_time;
     $graph_return['cmd'] = "rrdtool graph {$graphfile} {$rrd_options}";
 } else {
     if ($rrd_options) {
         rrdtool_graph($graphfile, $rrd_options);
         if ($debug) {
             echo $rrd_cmd;
         }
         if (is_file($graphfile)) {
             if ($vars['image_data_uri'] == TRUE) {
                 $image_data_uri = data_uri($graphfile, 'image/png');
             } elseif (!$debug) {
                 header('Content-type: image/png');
                 $fd = fopen($graphfile, 'r');
                 fpassthru($fd);
                 fclose($fd);
             } else {
                 echo `ls -l {$graphfile}`;
                 echo '<img src="' . data_uri($graphfile, 'image/png') . '" alt="graph" />';
             }
Exemplo n.º 4
0
function graph_error($string)
{
    global $vars, $config, $graphfile;
    $vars['bg'] = "FFBBBB";
    include $config['html_dir'] . "/includes/graphs/common.inc.php";
    $rrd_options .= " HRULE:0#555555";
    $rrd_options .= " --title='" . $string . "'";
    $rrd_options = preg_replace('/ --(start|end)(\\s+\\d+)?/', '', $rrd_options);
    // Remove start/end from error graph
    if ($height > 99) {
        rrdtool_graph($graphfile, $rrd_options);
        //$woo = shell_exec($rrd_cmd);
        //if (OBS_DEBUG) { echo("<pre>".$rrd_cmd."</pre>"); }
        if (is_file($graphfile)) {
            if (!OBS_DEBUG) {
                header('Content-type: image/png');
                header('Content-Length: ' . filesize($graphfile));
                header('Content-Disposition: inline; filename="' . basename($graphfile) . '"');
                $fd = fopen($graphfile, 'r');
                fpassthru($fd);
                fclose($fd);
            } else {
                echo '<img src="' . data_uri($graphfile, 'image/png') . '" alt="graph" />';
            }
            unlink($graphfile);
            #      exit();
        }
    } else {
        if (!OBS_DEBUG) {
            $im = imagecreate($width, $height);
            $orange = imagecolorallocate($im, 255, 225, 225);
            $px = (imagesx($im) - 7.5 * strlen($string)) / 2;
            imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0));
            header('Content-type: image/png');
            imagepng($im);
            imagedestroy($im);
        }
        #    exit();
    }
}