File: diskfree_report.php

package info (click to toggle)
ganglia 3.6.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 6,484 kB
  • ctags: 3,880
  • sloc: ansic: 27,874; sh: 11,052; python: 6,695; makefile: 565; perl: 366; php: 126; xml: 28
file content (98 lines) | stat: -rw-r--r-- 3,064 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php

/* Report to predict when the overall diskfree figures will reach zero */

/* Place this in the graph.d/ directory, and add "diskfree" to the
   $optional_graphs array in web/conf.php */

function graph_diskfree_report ( &$rrdtool_graph ) {

/* this is just the cpu_report (from revision r920) as an example, but with extra comments */

    // pull in a number of global variables, many set in conf.php (such as colors and $rrd_dir),
    // but other from elsewhere, such as get_context.php

    global $context, 
           $cpu_idle_color,
           $cpu_nice_color, 
           $cpu_system_color, 
           $cpu_user_color,
           $cpu_wio_color,
           $hostname,
           $range,
           $rrd_dir,
           $size;
    //
    // You *MUST* set at least the 'title', 'vertical-label', and 'series' variables.
    // Otherwise, the graph *will not work*.  
    //
    $rrdtool_graph['title']  = 'Diskfree Report';
                             //  This will be turned into:   
                             //  "Clustername $TITLE last $timerange", so keep it short
    $rrdtool_graph['vertical-label'] = 'Percent Free Space';
    $rrdtool_graph['upper-limit']    = '100';
    $rrdtool_graph['lower-limit']    = '0';
    $rrdtool_graph['extras']         = '--rigid';

    switch ($range) {

    case "day"   :
        $rrdtool_graph['end'] =  '+6h';
        break;
    case "week"  :
        $rrdtool_graph['end'] =  '+2d';
        break;
    case "month" :
        $rrdtool_graph['end'] =  '+3w';
        break;
    case "year"  :
        $rrdtool_graph['end'] =  '+2m';
        break;
    default:
        $rrdtool_graph['end'] =  'N';
        break;
   }


    /* Here we actually build the chart series.  This is moderately complicated
       to show off what you can do.  For a simpler example, look at network_report.php */
    if($context != "host" ) {

    }
    // Context is not "host"
    else {

    }

    $series_a = array(
        "DEF:'total_free'=$rrd_dir/disk_free.rrd:sum:AVERAGE",
        "DEF:'num_nodes'=$rrd_dir/disk_free.rrd:num:AVERAGE",
        "CDEF:free=total_free,num_nodes,/",
        "CDEF:threshold=num_nodes,UN,0,0,IF,5,+",
        "VDEF:intercept=free,LSLINT",
        "VDEF:slope=free,LSLSLOPE",
        "VDEF:correlation=free,LSLCORREL",
        "CDEF:free_trend=free,POP,intercept,COUNT,slope,*,+",
        "CDEF:space_exceeded=free_trend,threshold,LE,1,UNKN,IF",
        "VDEF:space_date=space_exceeded,FIRST",

        "AREA:free#999999",
        "LINE2:threshold#ff0000",
        "LINE1:free#000000:'Free Disk space\l'",
        "LINE2:free_trend#0000FF:'Current usage trend'",
        "VRULE:space_date#f00",
        "GPRINT:correlation:'Correlation is %1.2lf\l'",
        "GPRINT:space_date:'  Estimated out-of-space date is %a %d %B %Y\l':strftime",
    );

    $series = implode(' ',$series_a);

    // We have everything now, so add it to the array, and go on our way.
    $rrdtool_graph['series'] = $series;

//    error_log(var_export($rrdtool_graph,TRUE));

    return $rrdtool_graph;
}

?>