index.php 19.8 KB
Newer Older
1
2
<?php

's avatar
committed
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
/*
 * Copyright (c) 2006, CESNET
 * All rights reserved.
 *
 * LICENSE TERMS
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the company nor the names of its contributors 
 *       may be used to endorse or promote products derived from this 
 *       software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
 * THE COMPANY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * $Id$
 *
 */

's avatar
committed
36
/* require_once("common.php"); */
37

's avatar
committed
38
39
40
41
/* BEGINNING OF USER CONFIGURATION SECTION */

/* Picture of the monitored network to be shown in the user interface */
define(NET_IMG, "cesnet2-20060804-passivem.jpg");
's avatar
committed
42

43
/*
's avatar
committed
44
 * Define subjects
45
46
 */

's avatar
committed
47
/* 
's avatar
committed
48
49
50
51
 * Single-word names (without spaces) refering to monitored links.
 * They must be the same as "label" field in [subject] section in
 *	the abw.cfg configuration file. You can choose them here and edit
 * abw.cfg afterwards.
's avatar
committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 */
$subject_label=array(
	"GN2_CESNET", 
	"Brno_PoP", 
	"Budejovice_PoP", 
	"Hradec_PoP", 
	"Liberec_PoP", 
	"Olomouc_PoP", 
	"Ostrava_PoP", 
	"Pardubice_PoP", 
	"Plzen_PoP", 
	"Prague_PoP", 
	"Usti_PoP"
);

67
/*
's avatar
committed
68
69
70
 * Description of monitored links, can include spaces. It is probably a good 
 * idea to make it the same as "description" field in [subject] section in 
 * the abw.cfg configuration file (but it is not required).
's avatar
committed
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
 */
$subject_description=array(
	"GN2 CESNET2", 
	"Brno PoP", 
	"Budejovice PoP", 
	"Hradec PoP", 
	"Liberec PoP", 
	"Olomouc PoP", 
	"Ostrava PoP", 
	"Pardubice PoP", 
	"Plzen PoP", 
	"Prague PoP", 
	"Usti PoP"
);

/*
 * Hostnames where results are stored in RRD files and from which they should
's avatar
committed
88
 * be retrieved. It can be a central station that communicates with remote
's avatar
committed
89
 * monitoring stations via DiMAPI. Or it can be individual remote monitoring
's avatar
committed
90
 * stations directly.
's avatar
committed
91
92
93
94
95
96
97
98
99
 */
$subject_hostname=array(
	"jra1-2.cesnet.cz", 
	"perfmon2.cesnet.cz", 
	"perfmon-budejovice.cesnet.cz", 
	"perfmon-hradec.cesnet.cz", 
	"perfmon-liberec.cesnet.cz", 
	"perfmon-olomouc.cesnet.cz", 
	"perfmon-ostrava.cesnet.cz", 
's avatar
committed
100
	"195.113.125.254", 
's avatar
committed
101
102
103
104
105
	"perfmon-plzen.cesnet.cz", 
	"perfmon1.cesnet.cz", 
	"perfmon-usti.cesnet.cz"
);

's avatar
committed
106
107
108
109
110
111
112
113
114
115
/* If 1 then the subject is disabled (shown gray in the user interface) */
$subject_disabled=array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 );

/* END OF USER CONFIGURATION SECTION */

define(REMOTE_USERNAME, "abw");
define(GRAPH_SCRIPT, "/usr/local/abw/bin/rrd_graph_all.sh");
define(GRAPH_DIR, "/var/www/perfmon/abw/graph");
define(REMOTE_GRAPH_DIR, "/usr/local/abw/graph");

's avatar
committed
116
117
/*
 * Predefined time intervals and granularities
's avatar
committed
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 *
 * Keep in mind the following requirements:
 *
 *   - each resolution must be >= time of one pixel on X axis
 *     (set in rrd_graph_all.sh) otherwise time of one pixel is used
 *
 *   - UNIX timestamps of both start time and end time must be multiples
 *     of both resolutions (set time_length accordingly and compute
 *     end time to be on boundary) and it is safer to skip the most recent
 *     samples, see variable $hhmmYYYYMMDD below
 *
 *   - RRD files must include RRA samples for the whole requested period,
 *     create RRD files to include enough RRA samples for possible browsing
 *     in time axis
's avatar
committed
132
133
134
 */

$time_description[0]="last 10 mins (interval 1 sec, avg/max 30 sec)";
's avatar
committed
135
136
$time_description[1]="last 1 hour (interval 10 sec, avg/max 3 min)";
$time_description[2]="last 10 hours (interval 1 min, avg/max 20 min)";
's avatar
committed
137
138
139
140
141
142
143
144
145
$time_description[3]="last 1 day (interval 3 min, avg/max 1 hour)";
$time_description[4]="last 1 week (interval 20 min, avg/max 6 hour)";
$time_description[5]="last 1 month (interval 3 hour, avg/max 1 day)";
$time_description[6]="last 1 year (interval 1 day, avg/max 1 month)";

$r1[0]=1;
$r2[0]=30;
$time_length[0]="10min";

's avatar
committed
146
$r1[1]=10;
's avatar
committed
147
148
149
$r2[1]=180;
$time_length[1]="1h";

's avatar
committed
150
$r1[2]=60;
's avatar
committed
151
$r2[2]=1200;
's avatar
committed
152
$time_length[2]="10h";
's avatar
committed
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171

$r1[3]=180;
$r2[3]=3600;
$time_length[3]="1day";

$r1[4]=120;
$r2[4]=21600;
$time_length[4]="1week";

$r1[5]=10800;
$r2[5]=86400;
$time_length[5]="1month";

$r1[6]=86400;
$r2[6]=2628000;
$time_length[6]="1year";

/*
 * Define graph types
172
173
 */

's avatar
committed
174
175
176
177
178
179
$graph_type_label=array("l4", "apps");
$graph_type_description=array("L4", "Application");

/* For conversion of month number to month name */
$monthNumberToLongName=array("January", "February", "March", "April", "May", 
	"June", "July", "August", "September", "October", "November", "December");
180

's avatar
committed
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
function time_to_sec($number, $unit) {
	switch ($unit) {
		case "Seconds":
			return $number;
		case "Minutes":
			return $number * 60;
		case "Hours":
			return $number * 3600;
		case "Days":
			return $number * 86400;
		case "Weeks":
			return $number * 86400 * 7;
		case "Months":
			return $number * 86400 * 30;
		case "Years":
			return $number * 86400 * 365;
		default:
			return -1;
	}
} /* time_to_sec() */

function time_diff($time1, $time2) {
	if ($time2["sec"] > $time1["sec"]) {

		if ($time2["sec"] > ($time1["sec"]+1))
			$res=$time2["sec"] - $time1["sec"];
		else
			$res=0;

		$res=$res+(float)(1000000-$time1["usec"])/1000000 +
					 (float)($time2["usec"])/1000000;
	}
	else
		$res=(float)($time2["usec"]-$time1["usec"])/1000000;

	return $res;
} /* time_diff() */

219
220
221
/*
 * Start application
 */
222
223
224
225
226
227
228
229

$func="main()";

openlog($_SERVER['REMOTE_USER'], LOG_PID, LOG_LOCAL0);
syslog(LOG_INFO, "$func: starting");

echo "<html>\n";
echo "<head>\n";
230
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"../../style.css\">\n";
231
232
echo "</head>\n";
echo "<body>\n";
233
echo "<h2>ABW - Passive bandwith usage monitoring</h2>\n";
234

's avatar
committed
235
echo "<a href=\"" . NET_IMG . "\"><img src=\"" . NET_IMG . "\" width=\"400\" align=\"right\"></a>\n";
236

237
238
if (!isset($subject_selected))
	$subject_selected=1;
239

240
241
242
243
echo "<form method=post action=\"index.php?action=gen_graph\">\n";

/*
 * Print form to select graph types
244
245
 */

's avatar
committed
246
247
/* if (!isset($graph_types))
	$graph_types[0]="l4"; */
248
249
250

echo "<b>Type of graphs:</b><p>\n";

's avatar
committed
251
252
253
foreach ($graph_type_label as $key => $value) {
	echo "$graph_type_description[$key] protocols ";
	echo "<input type=checkbox name=\"graph_types[]\" value=\"$value\"";
254
	if (isset($graph_types)) {
's avatar
committed
255
		if (in_array($value, $graph_types))
256
257
258
259
260
261
262
			echo " checked";
	}
	echo ">\n";
}

/*
 * Print form to select monitored links
263
264
 */

's avatar
committed
265
266
267
268
269
/* if (!isset($subjects))
	$subjects[0]="Prague_PoP"; */

$half=count($subject_label)/2 + $subject_label%2;
$i=0;
270

271
echo "<p>\n";
272
273
echo "<b>Monitored links:</b><p>\n";
echo "<table border=1>\n";
's avatar
committed
274
275
276
277
278
foreach ($subject_label as $key => $value) {
	if (($i%2)==0)
		echo "<tr>\n";
	echo "<td>$subject_description[$key]</td>";
	echo "<td><input type=checkbox name=\"subjects[]\" value=\"$value\"";
279
	if (isset($subjects)) {
's avatar
committed
280
		if (in_array($value, $subjects))
281
282
			echo " checked";
	}
's avatar
committed
283
284
285
286
287
288
	if ($subject_disabled[$key] > 0)
		echo " disabled";
	echo "></td>\n";
	if (($i%2)>0)
		echo "</tr>\n";
	$i++;
289
}
's avatar
committed
290
291
292

if (($i%2)==0)
	echo "<tr>\n";
's avatar
committed
293
echo "<td>all links</td>\n";
's avatar
committed
294
295
296
297
298
299
echo "<td><input type=checkbox name=\"subject_all\"";
if ($subject_all)
   echo " checked";
echo "></td>\n";
$i++;

's avatar
committed
300
301
if (($i%2)>0)
	echo "<td>&nbsp;</td><td>&nbsp;</td>";
's avatar
committed
302
echo "</tr></table>\n";
303

304
305
306
/*
 * Print form to select time granularities and periods
 */
307
308

echo "<p>\n";
's avatar
committed
309
echo "<b>Time period and granularity:</b><p>\n";
310

's avatar
committed
311
312
313
314
315
316
echo "<table>\n";

echo "<tr><td>Predefined:</td><td width=20>&nbsp;</td><td>User defined:</td></tr>\n";

echo "<tr><td><table border=1>\n";
foreach ($time_description as $key => $value) {
317
	echo "<tr>\n";
's avatar
committed
318
319
320
321
	echo "<td>$value</td>\n";
	$time_label=$r1[$key] . "_" . $r2[$key] . "_" . $time_length[$key];
   echo "<td><input type=checkbox name=\"times[]\" value=\"" . $time_label . "\"";
	if (isset($times)) {
's avatar
committed
322
		if (in_array($time_label, $times))
's avatar
committed
323
324
   		echo " checked";
	}
325
326
	echo "></td>\n";
	echo "</tr>\n";
327
}
328
echo "<tr>\n";
's avatar
committed
329
echo "<td>all predefined time periods</td>\n";
330
331
332
333
echo "<td><input type=checkbox name=\"time_all\"";
if ($time_all)
	echo " checked";
echo "></td>\n";
334
echo "</tr>\n";
's avatar
committed
335
336
337
338
echo "</table></td>\n";

echo "<td>&nbsp;</td><td><p>Start or end time:<br>";

's avatar
committed
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
echo "<select name=time_hour>";
	for ($i=0; $i<=23; $i++) {
		echo "<option value=$i";
		if ($time_hour==$i)
			echo " selected";
		echo ">";
		printf("%02d", $i);
		echo "</option>\n";
	}
echo "</select>\n";

echo "<select name=time_minute>";
	for ($i=0; $i<=59; $i++) {
		echo "<option value=$i";
		if ($time_minute==$i)
			echo " selected";
		echo ">";
		printf("%02d", $i);
		echo "</option>\n";
	}
echo "</select>\n";

's avatar
committed
361
echo "<select name=time_day>";
's avatar
committed
362
363
364
365
366
367
	for ($i=1; $i<=31; $i++) {
		echo "<option value=$i";
		if ($time_day==$i)
			echo " selected";
		echo ">$i</option>\n";
	}
's avatar
committed
368
369
370
echo "</select>\n";

echo "<select name=time_month>";
's avatar
committed
371
372
373
374
375
376
	for ($i=1; $i<=12; $i++) {
		echo "<option value=$i";
		if ($time_month==$i)
			echo " selected";
		echo ">" . $monthNumberToLongName[$i-1] . "</option>\n";
	}
's avatar
committed
377
378
379
echo "</select>\n";

echo "<select name=time_year>";
's avatar
committed
380
381
382
383
384
385
	for ($i=2006; $i<=2015; $i++) {
		echo "<option value=$i";
		if ($time_year==$i)
			echo " selected";
		echo ">$i</option>\n";
	}
's avatar
committed
386
387
388
echo "</select>\n";

echo "<p>Time length:<br>\n";
's avatar
committed
389
echo "<input type=text size=3 name=time_length_number value=\"$time_length_number\"></input>\n";
's avatar
committed
390
391
392
393

echo "<select name=time_length_unit>";
$time_length_units=array("Minutes", "Hours", "Days", "Weeks", "Months", 
	"Years");
's avatar
committed
394
395
396
397
398
399
foreach ($time_length_units as $value) {
	echo "<option value=$value";
	if ($time_length_unit==$value)
		echo " selected";
	echo ">$value</option>\n";
}
's avatar
committed
400
401
402
403
echo "</select>\n";

/* Interval + avg/max are as a separate table */
echo "<p><table><tr><td>Interval:</td><td>Avg/Max:</td></tr><tr>\n";
's avatar
committed
404
echo "<td><input type=text size=3 name=r1_number value=\"$r1_number\"></input>\n";
's avatar
committed
405
406
407
echo "<select name=r1_unit>";
$r1_units=array("Seconds", "Minutes", "Hours", "Days", "Weeks", "Months",
   "Years");
's avatar
committed
408
409
410
411
412
413
foreach ($r1_units as $value) {
	echo "<option value=$value";
	if ($r1_unit==$value)
		echo " selected";
	echo ">$value</option>\n";
}
's avatar
committed
414
echo "</select></td>\n";
's avatar
committed
415
echo "<td><input type=text size=3 name=r2_number value=\"$r2_number\"></input>\n";
's avatar
committed
416
417
418
echo "<select name=r2_unit>";
$r2_units=array("Seconds", "Minutes", "Hours", "Days", "Weeks", "Months",
   "Years");
's avatar
committed
419
420
421
422
423
424
foreach ($r2_units as $value) {
	echo "<option value=$value";
	if ($r2_unit==$value)
		echo " selected";
	echo ">$value</option>\n";
}
's avatar
committed
425
426
427
428
429
430
431
432
433
echo "</select></td>\n";
echo "</tr></table>\n";

if (!isset($time_type))
	$time_type="predefined";

echo "<p>Time type:<br>\n";
echo "Predefined <input type=radio name=\"time_type\" value=\"predefined\"";
if (!strcmp($time_type, "predefined"))
's avatar
committed
434
	echo " checked";
's avatar
committed
435
436
437
echo ">";
echo "  Start time <input type=radio name=\"time_type\" value=\"start_time\"";
if (!strcmp($time_type, "start_time"))
's avatar
committed
438
   echo " checked";
's avatar
committed
439
440
441
echo ">";
echo "  End time <input type=radio name=\"time_type\" value=\"end_time\"";
if (!strcmp($time_type, "end_time"))
's avatar
committed
442
   echo " checked";
's avatar
committed
443
444
445
446
447
448
echo ">";

echo "</td>\n";

echo "</tr></table\n";

's avatar
committed
449
/* echo "<p>Note: selecting all time periods will require a lot of processing time\n"; */
450
451

echo "<p>\n";
's avatar
committed
452
453
454
echo "<input type=submit name=button_name value=\"Generate graphs\">\n";

echo "</form><br>\n";
455

456
457
if ($action=="gen_graph") {

's avatar
committed
458
	$current_time=date("G:i:s Ymd", time());
's avatar
committed
459
460

	foreach (glob(GRAPH_DIR . "/*") as $filename)
461
462
      unlink($filename);

's avatar
committed
463
464
465
	/* If at least one graph type, one subject and one time period were
		selected, then generate and show graphs */

's avatar
committed
466
467
	if (isset($graph_types) && 
		 (isset($subjects) || $subject_all) && 
's avatar
committed
468
		 (isset($times) || $time_all || strcmp($time_type, "predefined"))) {
's avatar
committed
469

's avatar
committed
470
471
472
473
		$total_time=0;
		echo "<p>\n";
		echo "<table>\n";
		echo "<tr><td>Graph type</td><td>Link</td><td>Time (gen / copy)</td></tr>\n";
474

's avatar
committed
475
		/* Go over all selected graph types */
's avatar
committed
476

's avatar
committed
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
		foreach($graph_type_label as $graph_type_key => $graph_type_value) {
			if (in_array($graph_type_value, $graph_types)) {

				/* Go over all subjects and for each selected subject issue
					one remote command to generate graphs */

				$i=0;
				foreach ($subject_label as $subject_key => $subject_value) {
		      	if (($subject_all || in_array($subject_value, $subjects)) &&
						 !$subject_disabled[$subject_key]) {

						$hostname=$subject_hostname[$i];

						$command="ssh " . REMOTE_USERNAME . "@" . $subject_hostname[$i] . " \"" . GRAPH_SCRIPT . " -r --protocols=" . $graph_type_value . " --label=" . $subject_value . " --parameters_id=1";

						/* Append one --time argument for each selected time period */

						if (!strcmp($time_type, "predefined")) {
					
							foreach ($time_description as $time_key => $time_value) {
								$time_label=$r1[$time_key] . "_" . $r2[$time_key] . 
									"_" . $time_length[$time_key];
					   		if ($time_all || in_array($time_label, $times)) {
									$hhmmYYYYMMDD=date("G:i Ymd", (int)(time() / $r2[$time_key]) * $r2[$time_key] - $r2[$time_key]);

							 		$command=$command . " --time=\\\"" .
							 			$r1[$time_key] . " " . $r2[$time_key] . " " .
										$time_length[$time_key] . " " . $hhmmYYYYMMDD . "\\\"";
								}
							}
						} /* if (!strcmp($time_type, "predefined")) */
						else {
							/* echo "time_type: $time_type<br>\n";
							echo "time_hour: $time_hour<br>\n";
							echo "time_minute: $time_minute<br>\n";
							echo "time_day: $time_day<br>\n";
							echo "time_month: $time_month<br>\n";
							echo "time_year: $time_year<br>\n";
							echo "time_length_number: $time_length_number, time_length_unit: $time_length_unit<br>\n";
							echo "r1_number: $r1_number, r1_unit: $r1_unit<br>\n";
							echo "r2_number: $r2_number, r2_unit: $r2_unit<br>\n"; */
		
							/* Convert R1, R2 and time length to seconds, 
								adjust time_length to R2 boundary */

							$r1_sec=time_to_sec($r1_number, $r1_unit);
							$r2_sec=time_to_sec($r2_number, $r2_unit);
							/* echo "r1_sec: $r1_sec, r2_sec: $r2_sec<br>\n"; */
							if ($r1_sec<=0 || $r2_sec<=0 || $r2_sec<$r1_sec ||
								 ($r2_sec%$r1_sec)>0) {
							 	echo "Incorrect time or date specification.<br>\n";
							 	exit();
							}
							$time_length_sec=time_to_sec($time_length_number, 
								$time_length_unit);
							$time_length_sec=
								((int)($time_length_sec / $r2_sec)) * $r2_sec;
							if ($time_length_sec<=0) {
								echo "Incorrect time or date specification.<br>\n";
								exit();
							}

							/* Compute timestamp of start or end of requested period */

							$timestamp=strtotime($time_year . "-" . $time_month . "-" .
								$time_day . " " . $time_hour . ":" . $time_minute);
							/* echo "timestamp: $timestamp<br>\n"; */
							$hhmmYYYYMMDD=date("G:i Ymd", $timestamp);
							/* echo "hhmmYYYYMMDD: $hhmmYYYYMMDD<br>\n"; */

							/* If start time was given, then compute end time */

							if (!strcmp($time_type, "start_time")) {
								$timestamp=$timestamp + $time_length_sec;
								/* echo "timestamp + time_length: $timestamp<br>\n"; */
								$hhmmYYYYMMDD=date("G:i Ymd", $timestamp);
					      	/* echo "hhmmYYYYMMDD + time_length: $hhmmYYYYMMDD<br>\n"; */
							}

							/* Adjust timestamp to R2 boundary */

							$timestamp=((int)($timestamp / $r2_sec)) * $r2_sec;

							$command=$command . " --time=\\\"" . $r1_sec . " " . 
								$r2_sec . " " . $time_length_number . 
								$time_length_unit . " " . $hhmmYYYYMMDD . "\\\"";
									
's avatar
committed
564
						}
's avatar
committed
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
		
						/* Execute command and measure how long it takes */

						$command=$command . " 2>&1 > /dev/null\"";
						/* echo "Command: $command<br>\n"; */
						$time1=gettimeofday();
						system($command);
						$time2=gettimeofday();
						$diff=time_diff($time1, $time2);
						$total_time+=$diff;
						printf("<tr><td>%s protocols</td><td>%s</td><td>%.02fs / ", 
							$graph_type_description[$graph_type_key], $subject_value, 
							$diff);

						$command="scp " . REMOTE_USERNAME . "@" . $subject_hostname[$i] . ":" . REMOTE_GRAPH_DIR . "/* " . GRAPH_DIR;	
						/* echo "Command: $command<br>\n"; */
						$time1=gettimeofday(TRUE);
						system($command);
						$time2=gettimeofday(TRUE);
						$diff=time_diff($time1, $time2);
						$total_time+=$diff;
						printf("%.02fs</td></tr>\n", $diff);
's avatar
committed
587
					}
's avatar
committed
588
				$i++;
's avatar
committed
589
				}
's avatar
committed
590
591
592
593
			} /* if (in_array($graph_type_value, $graph_types)) */
		} /* foreach($graph_type_label as $graph_type_key => $graph_type_value) */
		printf("<tr><td>Total time</td><td>&nbsp;</td><td>%.02fs</td></tr>\n", $total_time);
		echo "</table>\n";
's avatar
committed
594
595
596
597
598
599

		echo "<p>\n<table>\n";
		$graphs=0;

		foreach($graph_types as $graph_type) {
			foreach ($subject_label as $subject_key => $subject_value) {
's avatar
committed
600
601
		      if (($subject_all || in_array($subject_value, $subjects)) &&
					 !$subject_disabled[$subject_key]) {
's avatar
committed
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616

					if (!strcmp($time_type, "predefined")) {
					
						foreach ($time_description as $time_key => $time_value) {
							$time_label=$r1[$time_key] . "_" . $r2[$time_key] . "_" . 
								$time_length[$time_key];
					   	if ($time_all || in_array($time_label, $times)) {

								$graph_filename="graph/graph_" . $subject_value . "_" . 
									$graph_type . "_" . $r1[$time_key] . "s_" .
									$r2[$time_key] . "s_" . $time_length[$time_key] . 
									".png";

								if (($graphs%2)==0)
									echo "<tr>\n";
617
	
's avatar
committed
618
619
620
621
622
623
624
625
626
627
628
629
630
								echo "<td width=430 align=center>\n";
								echo "  <table>\n";
								echo "  <tr>\n";
								echo "    <td align=center><a href=\"$graph_filename\"><img width=400 src=\"$graph_filename\"></a></td>\n";
								echo "  </tr>\n";
								echo "  <tr>\n";
								echo "    <td align=center>" . $graph_type_description[array_search($graph_type, $graph_type_label)] . " protocols, Monitored link: " . $subject_description[$subject_key] . "<br>$time_description[$time_key]</td>\n";
								echo "  </tr>\n";
								echo "  </table>\n";
								echo "</td>\n";

								if (($graphs%2)!=0)
									echo "</tr>\n";
631
			
's avatar
committed
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
								$graphs++;
							}
						} 

					} /* if (!strcmp($time_type, "predefined")) */
					else {
						$graph_filename="graph/graph_" . $subject_value . "_" .
							$graph_type . "_" . $r1_sec . "s_" . $r2_sec . "s_" .
							$time_length_number . $time_length_unit . ".png";

						if (($graphs%2)==0)
							echo "<tr>\n";

						echo "<td width=430 align=center>\n";
						echo "  <table>\n";
						echo "  <tr>\n";
						echo "    <td align=center><a href=\"$graph_filename\"><img width=400 src=\"$graph_filename\"></a></td>\n";
						echo "  </tr>\n";
						echo "  <tr>\n";
						echo "    <td align=center>" . $graph_type_description[array_search($graph_type, $graph_type_label)] . " protocols, Monitored link: " . $subject_description[$subject_key] . "<br>$time_length_number $time_length_unit";
						if (!strcmp($time_type, "start_time"))
							echo " from";
						else
							echo " to";
						printf(" %02d:%02d %d-%02d-%02d", $time_hour, $time_minute,
							$time_year, $time_month, $time_day);
						echo "<br>(interval $r1_number $r1_unit, Avg/Max $r2_number $r2_unit)</td>\n";
						echo "  </tr>\n";
						echo "  </table>\n";
						echo "</td>\n";

						if (($graphs%2)!=0)
							echo "</tr>\n";
			
						$graphs++;
					}

669
				}
's avatar
committed
670
671
672
673
674
			} /* foreach($subject_label as $subject_key => $subject_value) */
		} /* foreach ($graph_types as $graph_type) */

		echo "</table>\n";

's avatar
committed
675
	} /* if (isset($graph_types) && ... */
676
677

} /* if ($action=="gen_graph") */
678
679
680
681
682

echo "</body>\n";
echo "</html>\n";

?>