Changeset 13
- Timestamp:
- Oct 17, 2007, 7:06:49 PM (17 years ago)
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
admin.php
r6 r13 45 45 } 46 46 47 function ShowAdd() 48 { 49 global $Database; 50 $Values = array(); 51 return(ShowEditTable('Measure', $Values)); 52 } 53 47 54 ?> -
classes.php
r4 r13 3 3 $Classes = array( 4 4 'Measure' => array( 5 'Name' => array('Type' => 'String', 'Caption' => 'Zkratka'), 6 'Title' => array('Type' => 'String', 'Caption' => 'Název'), 7 'Description' => array('Type' => 'String', 'Caption' => 'Popis'), 8 'Unit' => array('Type' => 'String', 'Caption' => 'Jednotka'), 9 'Continuity' => array('Type' => 'Boolean', 'Caption' => 'Spojitost'), 10 'Period' => array('Type' => 'Integer', 'Caption' => 'Perioda mìøení'), 11 'PermissionAdd' => array('Type' => 'String', 'Caption' => 'Oprávnìní k mìøení'), 12 'PermissionView' => array('Type' => 'String', 'Caption' => 'Oprávnìní k prohlí¾ení'), 13 'Enabled' => array('Type' => 'Boolean', 'Caption' => 'Povolení'), 5 'Name' => array('Type' => 'String', 'Caption' => 'Zkratka', 'Default' => 'measure'), 6 'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => 'Mìøení'), 7 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => 'Mìøení velièiny'), 8 'Unit' => array('Type' => 'String', 'Caption' => 'Jednotka', 'Default' => ''), 9 'Continuity' => array('Type' => 'Boolean', 'Caption' => 'Spojitost', 'Default' => '0'), 10 'Period' => array('Type' => 'Integer', 'Caption' => 'Perioda mìøení', 'Default' => '60'), 11 'PermissionAdd' => array('Type' => 'String', 'Caption' => 'Oprávnìní k mìøení', 'Default' => 'localhost.localdomain'), 12 'PermissionView' => array('Type' => 'String', 'Caption' => 'Oprávnìní k prohlíení', 'Default' => 'all'), 13 'Enabled' => array('Type' => 'Boolean', 'Caption' => 'Povolení', 'Default' => '1'), 14 'DataType' => array('Type' => 'String', 'Caption' => 'Typ datových poloek', 'Default' => 'int'), 15 'DataTable' => array('Type' => 'String', 'Caption' => 'Tabulka mìøených dat', 'Default' => 'data'), 14 16 ), 15 17 ); -
config.sample.php
r6 r13 30 30 'Measure' => 1, 31 31 'Period' => 'day', 32 'TimeSpecify' => 5,32 'TimeSpecify' => 0, 33 33 ), 34 34 ); -
global.php
r6 r13 63 63 foreach($Class as $Index => $Item) 64 64 { 65 if(!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default']; 65 66 switch($Item['Type']) 66 67 { 67 case 'Boolean': 68 case 'Boolean': 68 69 if($Values[$Index] == 0) $Checked = ''; else $Checked = ' checked="yes"'; 69 70 $Edit = '<input type="checkbox" name="'.$Index.'"'.$Checked.'>'; … … 80 81 array_push($Table['Rows'], array($Item['Caption'], $Edit)); 81 82 } 82 $Output = '<h3>Tabulka '.$ClassName.'</h3>'.Table($Table).Link('?Operation=Add', 'Pøidat'); 83 return($Output); } 83 $Output = '<h3>Tabulka '.$ClassName.'</h3>'.Table($Table).MakeLink('?Operation=Add2', 'Pøidat'); 84 return($Output); 85 } 84 86 85 87 ?> -
graph.php
r6 r13 171 171 $Y = $Height - 1 - ($VerticalLinesDistance * $I); 172 172 //$Y = $Height - 1 - ($VerticalLinesDistance * $I / ($MaxValue - $MinValue) * $K * $Height); 173 $Text = round(($I * $VerticalLinesDistance / $Height / $K * ($MaxValue - $MinValue) + $MinValue));173 $Text = AddPrefixMultipliers(round(($I * $VerticalLinesDistance / $Height / $K * ($MaxValue - $MinValue) + $MinValue)), $Measure['Unit'], 3); 174 174 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 175 175 if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10) … … 178 178 $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 179 179 180 imagettftext($Image, $FontSize, 0, $Width-94, 14, $Red, $FontFile, "Max. ". $MaxValue.' '.$Measure['Unit']);181 imagettftext($Image, $FontSize, 0, $Width-194, 14, $Green, $FontFile, "Avg. ". $AvgValue.' '.$Measure['Unit']);182 imagettftext($Image, $FontSize, 0, $Width-294, 14, $Blue, $FontFile, "Min. ". $MinValue.' '.$Measure['Unit']);180 imagettftext($Image, $FontSize, 0, $Width-94, 14, $Red, $FontFile, "Max. ".AddPrefixMultipliers($MaxValue, $Measure['Unit'])); 181 imagettftext($Image, $FontSize, 0, $Width-194, 14, $Green, $FontFile, "Avg. ".AddPrefixMultipliers($AvgValue, $Measure['Unit'])); 182 imagettftext($Image, $FontSize, 0, $Width-294, 14, $Blue, $FontFile, "Min. ".AddPrefixMultipliers($MinValue, $Measure['Unit'])); 183 183 imagestring($Image, 2, 50, 20, 'Vygenerováno za '.$GenerationTime.' sekund', $Black); 184 184 //imagestring($Image, 2, 50, 30, 'Level: '.$Level, $Black); -
index.php
r6 r13 174 174 175 175 $Output .= '<table border="1" cellspacing="0" cellpadding="2" style="font-size: small;">'; 176 $Output .= '<tr><th>Mìøená velièina</th><th> Èas posledního mìøení</th><th>Poslední hodnota</th><th>Interpolace</th><th>Poznámky</th>';176 $Output .= '<tr><th>Mìøená velièina</th><th>Poslední hodnota</th><th>Èas posledního mìøení</th><th>Interpolace</th><th>Poznámky</th>'; 177 177 if(array_key_exists('Debug', $_GET)) $Output .= '<th>Poèet polo¾ek</th><th>Èas vykonání</th>'; 178 178 $Output .= '</tr>'; … … 195 195 $Row = $Result2->fetch_array(); 196 196 $LastMeasureTime = date('j.n.Y G:i:s', MysqlDateTimeToTime($Row['time'])); 197 $LastMeasureValue = round($Row['avg'] / $Measure['Divider']);197 $LastMeasureValue = AddPrefixMultipliers($Row['avg'], $Measure['Unit']); 198 198 } else { 199 199 $LastMeasureTime = ' '; … … 203 203 if($Measure['Info'] == '') $Measure['Info'] = ' '; 204 204 $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 205 $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'">'.$Measure['Description'].'</a></td><td align="center">'.$LastMeasureValue.' '.$Measure['Unit'].'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Info'].'</td>';205 $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'">'.$Measure['Description'].'</a></td><td align="center">'.$LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Info'].'</td>'; 206 206 if(array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>'; 207 207 $Output .= '</tr>'; -
measure_scripts/traffic.php
r7 r13 3 3 include('../global.php'); 4 4 5 function CheckPortStatus($Ip, $Port) 6 { 7 function ErrorHandler($errno,$errmsg,$filename,$linenum,$vars) 8 { 9 } 10 set_error_handler('ErrorHandler'); 11 //error_reporting(0); 12 if($Fp1 = fsockopen($Ip, $Port, $ERROR_NO, $ERROR_STR,(float)0.5)) 13 { 14 fclose($Fp1); 15 return true; 16 } else 17 { 18 //echo($ERROR_NO.','.$ERROR_STR); 19 //die(); 20 return false; 21 } 22 restore_error_handler(); 23 } 24 5 25 function MemoryUsage() 6 26 { 7 27 $Output = array(); 8 exec('free - m', $Output);28 exec('free -b', $Output); 9 29 $Row = $Output[2]; 10 30 while(strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row); … … 99 119 // Network load 100 120 $NetworkStat = GetNetworkStat(); 101 $Value = round($NetworkStat['eth1']['down_avg'] /1024);121 $Value = round($NetworkStat['eth1']['down_avg']); 102 122 file_get_contents($URL.'?MeasureId=11&Value='.$Value); 103 $Value = round($NetworkStat['eth1']['up_avg'] /1024);123 $Value = round($NetworkStat['eth1']['up_avg']); 104 124 file_get_contents($URL.'?MeasureId=12&Value='.$Value); 105 125 … … 155 175 $Value = $Row[0]; 156 176 file_get_contents($URL.'?MeasureId=6&Value='.$Value); 157 177 178 // MaNGOS worldd availability 179 if(CheckPortStatus('localhost', 8085)) $Value = 100; else $Value = 0; 180 file_get_contents($URL.'?MeasureId=15&Value='.$Value); 181 158 182 sleep(60); 159 183 } -
stat_functions.php
r12 r13 2 2 3 3 $ValueTypes = array('min', 'avg', 'max'); 4 $PrefixMultipliers = array( 5 array('y', 'yocto', pow(10, -24)), 6 array('z', 'zepto', pow(10, -21)), 7 array('a', 'atto', pow(10, -18)), 8 array('f', 'femto', pow(10, -15)), 9 array('p', 'piko', pow(10, -12)), 10 array('n', 'nano', pow(10, -9)), 11 array('u', 'mikro', pow(10, -6)), 12 array('m', 'mili', pow(10, -3)), 13 array('', '', pow(10, 0)), 14 array('k', 'kilo', pow(10, 3)), 15 array('M', 'mega', pow(10, 6)), 16 array('G', 'giga', pow(10, 9)), 17 array('T', 'tera', pow(10, 12)), 18 array('P', 'peta', pow(10, 15)), 19 array('E', 'exa', pow(10, 18)), 20 array('Z', 'zetta', pow(10, 21)), 21 array('Y', 'yotta', pow(10, 24)), 22 ); 23 24 function AddPrefixMultipliers($Value, $Unit, $Digits = 4) 25 { 26 global $PrefixMultipliers; 27 if($Unit == '') return($Value); 28 $I = 8; 29 if($Value > 0) $II = 1; 30 else if($Value < 0) $II = -1; 31 else $II = 0; 32 while((($Value / $PrefixMultipliers[$I + $II][2]) > $II) and (($I + $II) >= 0) and (($I + $II) <= count($PrefixMultipliers))) $I = $I + $II; 33 $Value = $Value / $PrefixMultipliers[$I][2]; 34 35 // Truncate digits count 36 for($II=2; $II > -1; $II--) 37 { 38 if($Value >= pow(10, $II)) 39 { 40 if($Digits < ($II + 1)) $RealDigits = $II + 1; else $RealDigits = $Digits; 41 $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1); 42 break; 43 } 44 } 45 46 return($Value.' '.$PrefixMultipliers[$I][0].$Unit); 47 } 4 48 5 49 function GetMicrotime()
Note:
See TracChangeset
for help on using the changeset viewer.