File: cpu_util_aggregation.inc.php

package info (click to toggle)
jffnms 0.8.3dfsg.1-2.1etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 4,928 kB
  • ctags: 5,050
  • sloc: php: 19,981; sh: 266; makefile: 91; perl: 52
file content (42 lines) | stat: -rw-r--r-- 1,113 bytes parent folder | download | duplicates (5)
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
<?
/* CPU Utilization Aggregation. This file is part of JFFNMS
 * Copyright (C) <2004> Robert St.Denis <service@iahu.ca>
 * This program is licensed under the GNU GPL, full terms in the LICENSE file
 */

function graph_cpu_util_aggregation ($data) {

    $opts_agg = array();
    $str_cdef_cpu .= "CDEF:cpu=0";
    $cant = count($data["id"]);

    foreach ($data["id"] as $id) {
	$interface=$data[$id];

	$opts_agg = @array_merge($opts_agg,rrdtool_get_def($interface,array(
				    "cpu$id"=>"cpu")));

	$str_cdef_cpu .=",cpu$id,UN,0,cpu$id,IF,+";
    }

    $str_cdef_cpu .= ",$cant,/";

    $opts_GRAPH = array(
	$str_cdef_cpu,
	"COMMENT:'Number of Processors:".$cant."\\n'",

        "AREA:cpu#00CC00:'Average CPU Utilization '",
        "LINE1:cpu#0000FF:''",

	"GPRINT:cpu:MAX:'Max\:%8.2lf %%'",
        "GPRINT:cpu:AVERAGE:'Average\:%8.2lf %%'",
        "GPRINT:cpu:LAST:'Last\:%8.2lf %%'"
	);
	
    $opts_header[] = "--vertical-label='CPU Utilization %'";
    $opts_header[] = "--rigid";
    $opts_header[] = "--upper-limit=100";

    return array ($opts_header, @array_merge($opts_agg,$opts_GRAPH));
}
?>