2012-12-19 1 views
1

매우 구체적인 용도이지만 유용 할 수 있습니다.가독성을 극대화하기 위해 표준 편차로 RRD 스택 가능 데이터를 그래프로 표시하는 방법

스택에 다른 값이 있다고 상상해보십시오. 일부 데이터는 많이 변하고 일부는 거의 일정합니다. 기본 순서를 사용하고 변수 데이터가 상수 데이터 아래에 쌓인 경우 변수 데이터를 통해 상수 데이터가 매우 가변적 인 기본이됩니다. 그래서 변수가 적은 데이터를 맨 아래에 스택하면 도움이됩니다.

예 :이 두 그래프는 less를 이동하는 더 깊은, 즉 더 작은 표준 편차를 갖는 더 깊은 데이터를 스태킹하여 가독성을 향상시키는 방법을 보여줍니다.

답변

1
  1. 표준 편차에 의해 사용 rrdtool graph을 정렬 할 때

    Default graphing doesn't help readibility
    기본 그래프는 (데이터 소스의 표준 편차를 얻을 수 PRINT 명령으로 나쁜 일기 좋게에 stdev_array

    Improved readibility when sorting by standard deviation
    향상을 일기 좋게을 초래할 수)

  2. sort stdev_array
  3. stdev_array

의 순서로 적층해서

  • 그래프는 여기에 PHP의 코드 그러나 어떤 언어는 그것을 할 수 있습니다. 내가 $rrd_path (RRD 파일 경로), $img_path (이미지를 쓸 수있는 경로), $data_sources (DS 이름의 배열을 정의하는 것을 잊지 마세요 RRDtool의 1.4.5
    을 사용하고
    는 빌드 방법에 따라 달라집니다 RRD), $rrd_colors (헥사 색의 배열).

    $rrd_colors_count = count($rrd_colors); 
    $stdev_command = "rrdtool graph /dev/null "; 
    foreach ($data_sources as $index => $ds_name) 
    { 
        $stdev_command .= "DEF:serv$index=$rrd_path:$ds_name:AVERAGE "; 
        $stdev_command .= "VDEF:stdev$index=serv$index,STDEV PRINT:stdev$index:%lf "; 
    } 
    exec($stdev_command, $stdev_order, $ret); 
    if ($ret === 0) 
    { 
        array_shift($stdev_order); // remove first useless line "0x0" (may depend on your rrdtool version?) 
        asort($stdev_order); // sort by standard deviation keeping the indexes 
    } 
    else $stdev_order = $data_sources; // backup in case $stdev_command failed 
    
    $graph_command = "rrdtool graph $img_path "; 
    $graph_command .= "AREA:0 "; 
    foreach ($stdev_order as $index => $useless) 
    { 
        $ds_name = $data_sources[$index]; 
        $graph_command .= "DEF:line$index=$rrd_path:$ds_name:AVERAGE "; 
        $graph_command .= "STACK:line$index" . $rrd_colors[$index%$rrd_colors_count].' '; 
    } 
    exec($graph_command, $out, $ret); 
    // check $ret (and $out) to see if all is good