<?php header("Content-Type: image/jpeg"); $fp = fopen ("ping.txt", "r"); $values = array(); $count = 0; while (!feof($fp)) { $line = fgets($fp, 1024); $input = split("\ ", $line); $packet = split("=", $input[7]); $packet = $packet[1]; array_push ($values, $packet); if ($count == 0) array_pop($values); $count++; } fclose($fp); $im = ImageCreateTrueColor(400,100); $black = ImageColorAllocate($im, 0, 0, 0); $white = ImageColorAllocate($im, 255, 255, 255); $red = ImageColorAllocate($im, 255, 0, 0); $green = ImageColorAllocate($im, 0, 255, 0); ImageFill($im, 0, 0, $white); ImageRectangle($im, 0, 0, 399, 99, $black); $max=max($values); $fac=$max/100; $x=0; $y=0; foreach ($values as $value) { $x_old = $x; $x += round(400/count($values)); $y = abs($height-($value/$fac)); $y_old = abs($height-($value_old/$fac)); ImageLine($im, $x_old, $y_old, $x, $y, $red); $value_old = $value; } ImageJPEG($im, "",80); ?>
|
Einfachstdiagramm:die Antwortzeiten aus ping, aus einer Datei gelesen (Abb. 2) |
Dieser Text ist der Zeitschriften-Ausgabe 05/2002 von iX entnommen.
iOS, Android, Windows Phone 7 und HTML5 - das neue Sonderheft von heise Developer führt Einsteiger und Profis in die Programmierung mobiler Geräte ein.