summaryrefslogtreecommitdiff
path: root/skins/stone_flat/memory.tmpl
blob: 64878149bdab31dde3abe5b8139a6062448b8cc0 (plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!-- Memory Template -->
<?% IF ! global.bodyinc.defined;global.bodyinc = 1 %?>
<body class="frame">
<?% INCLUDE status.inc %?>
<?% INCLUDE header.inc %?>
<div id="body">
<?% END %?>

<?%
    USE date;
    statusfiles = [];
    fields = data.shift;

    FILTER null;
        name = 'memory_stat';
        swapdata = [];
        activedata = [];
        cacheddata = [];
        inactivedata = [];
        timestamps = [];
        FOREACH row IN data;
            t = date.format(row.6, '%H:%M');
            timestamps.push(t);
            activedata.push(row.2 / (1024));
            inactivedata.push(row.3 / (1024));
            cacheddata.push(row.4 / (1024));
            swapdata.push(row.5 / (1024));
        END;

        # Data ...
        d = [
             timestamps ,
             activedata ,
             inactivedata
             cacheddata ,
             swapdata
        ];

        USE my_graph = GD.Graph.lines(575,375);

        # Xsteps
        steps = data.size div 5;

        label = gettext('Memory usage since');
        label_y = gettext('Memory usage in MB')
        label = "${label} ${d.first.first} (${label_y})";

        my_graph.set(
                x_label_skip => steps,
                x_long_ticks => 1,

                y_long_ticks => 1,

                line_width   => 2,
                box_axis     => 1,
                boxclr       => '#FFFFFF',
                fgclr        => '#BBBBBB'
                legend_placement => '>BO',
                legend_spacing => 5,
        );
        my_graph.set_title_font(param.font,10);
        my_graph.set_y_label_font(param.font,10);
        my_graph.set_x_label_font(param.font,10);
        my_graph.set_x_axis_font(param.font,6);
        my_graph.set_y_axis_font(param.font,6);
        my_graph.set_legend( fields.2, fields.3, fields.4, fields.5);
        file = writefile("status_${name}.gif", my_graph.plot(d).gif );
        statusfiles.push([ label , file ]);
        END;

        # ------------------- Piegraph für Speicher
        row = data.last;
        FILTER null;
        name = 'memory_now';
        MemTotal = row.0 div 1024;
        MemFree = row.1 div 1024;
        Active = row.2 div 1024;
        Cached = row.4 div 1024;
        Inactive = row.3 div 1024;
        Swapped = row.5 div 1024;

        d2 = [
            [ "${fields.2} ${Active} MB","${fields.3} ${Inactive} MB","${fields.4} ${Cached} MB","${fields.5} ${Swapped} MB","${fields.1} ${MemFree} MB"],
            [ row.2, row.3, row.4, row.5, row.1]
        ];

        USE my_graph = GD.Graph.pie(300, 200);
        label = fields.0;
        label = "${label} ${MemTotal} MB";
        my_graph.set(
                axislabelclr => 'black',
                pie_height => 20,
                transparent => 1,
        );
        my_graph.set_title_font(param.font,10);
        my_graph.set_label_font(param.font,10);
        my_graph.set_value_font(param.font,8);
        file = writefile("status_${name}.gif", my_graph.plot(d2).gif );
        statusfiles.push([ label , file ]);

      END;
 %?>

<?% IF param.headingText %?>
<h1><?% param.headingText %?></h1>
<?% END %?>

<?% FOREACH file IN statusfiles %?>
<table class="editortable" summary="">
    <tr><td class="editorhead"><?% file.0 %?></td></tr>
    <tr>
        <td class="editortext" align="center">
          <img src="<?% file.1 %?>" alt="<?% file.0 %?>" />
        </td>
    </tr>
    <tr><td class="editorbottom"></td></tr>
</table>
<?% END %?>