File: traffic_util.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 (45 lines) | stat: -rw-r--r-- 1,491 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
43
44
45
<?
/* This file is part of JFFNMS
 * Copyright (C) <2002-2005> Javier Szyszlican <javier@szysz.com>
 * This program is licensed under the GNU GPL, full terms in the LICENSE file
 */
function graph_traffic_util ($data) { 

    if ($data["flipinout"]==1) {
	$opts_DEF = rrdtool_get_def($data,array(output=>"input",input=>"output"));
	$flip_legend = "     (In / Out Flipped)";
    } else 
	$opts_DEF = rrdtool_get_def($data,array("input","output"));

    $opts_GRAPH = array( 		    
        "CDEF:inputbits=input,UN,0,input,IF,8,*",
        "CDEF:outputbits=output,UN,0,output,IF,8,*",	
        "HRULE:100#FF0000:"
    );
    
    if ($data["bandwidthin"] > 0)
	$opts_GRAPH = array_merge($opts_GRAPH,array(
    	    "CDEF:input1=inputbits,100,*,".  $data["bandwidthin"]. ",/",

	    "AREA:input1#00CC00:'Input Utilization '",
	    "GPRINT:input1:MAX:'Max\:%8.2lf %%'",
	    "GPRINT:input1:AVERAGE:'Average\:%8.2lf %%'",
	    "GPRINT:input1:LAST:'Last\:%8.2lf %%$flip_legend\\n'",
	));

    if ($data["bandwidthout"] > 0)
	$opts_GRAPH = array_merge($opts_GRAPH,array(
    	    "CDEF:output1=outputbits,100,*,".$data["bandwidthout"].",/",
        
	    "LINE2:output1#0000FF:'Output Utilization'",
    	    "GPRINT:output1:MAX:'Max\:%8.2lf %%'",
    	    "GPRINT:output1:AVERAGE:'Average\:%8.2lf %%'",
    	    "GPRINT:output1:LAST:'Last\:%8.2lf %%'" 
	));

    $opts_header[] = "--vertical-label='Utilization %'";

    return array ($opts_header, @array_merge($opts_DEF,$opts_GRAPH));    
}

?>