Changeset 66
- Timestamp:
- Jan 2, 2016, 12:17:56 AM (9 years ago)
- Files:
-
- 4 added
- 1 deleted
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
client/php/Client.php
r65 r66 1 1 <?php 2 2 3 // Toto je ukázkový skript pro aktualizaci dat. Zkopírujte si jej jako monitor.php a upravte podle potřeby. 3 include('Global.php'); 4 4 5 include('../global.php'); 6 include('system.php'); 7 include('wow.php'); 5 // Various measure libraries 6 include('Linux.php'); 7 include('WoW.php'); 8 include('Centrala.php'); 9 include('Routerboard.php'); 8 10 9 //GetNetworkState(); 10 while(1) 11 function ProcessMeasure() 11 12 { 13 $Values[3] = MemoryUsage(); 14 $Values[4] = CpuUsage(); 15 $Values[5] = WoWPlayersOnline(); 16 $Values[6] = WoWEmulatorRestartCount(); 17 $Values[7] = DiskFree('/'); 18 $Values[8] = WoWAccountCount(); 19 $Values[10] = WoWGMOnline(); 12 20 $NetworkState = GetNetworkState(); 13 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=3&Value='.MemoryUsage()); 14 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=4&Value='.CpuUsage()); 15 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=5&Value='.WoWPlayersOnline()); 16 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=6&Value='.WoWEmulatorRestartCount()); 17 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=7&Value='.DiskFree()); 18 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=8&Value='.WoWAccountCount()); 19 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=10&Value='.WoWGMOnline()); 20 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=11&Value='.round($NetworkState['eth1']['DownAverage'])); 21 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=12&Value='.round($NetworkState['eth1']['UpAverage'])); 22 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=13&Value='.WoWCharacterCount()); 23 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=14&Value='.WoWGuildCount()); 24 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=15&Value='.WoWEmulatorAvailability()); 25 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=16&Value='.Ping()); 26 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=17&Value='.TeamSpeak()); 27 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=18&Value='.WoWTranslatedQuestsCount()); 28 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=19&Value='.DiskUtilization()); 21 $Values[11] = round($NetworkState['eth1']['DownAverage']); 22 $Values[12] = round($NetworkState['eth1']['UpAverage']); 23 $Values[13] = WoWCharacterCount(); 24 $Values[14] = WoWGuildCount(); 25 $Values[15] = WoWEmulatorAvailability(); 26 $Values[16] = Ping(); 27 $Values[17] = TeamSpeak(); 28 $Values[18] = WoWTranslatedQuestsCount(); 29 $Values[18] = DiskUtilization('sda'); 30 $RBNetworkState = GetRouterBoardNetworkState(); 31 $Values[19] = $RBNetworkState['DownAverage'] * 8; 32 $Values[20] = $RBNetworkState['UpAverage'] * 8; 33 $Values[21] = HostsOnline(); 34 $Values[22] = MemberCount(); 35 $Values[23] = ProcessorTemperature('Core0'); 29 36 30 sleep(58); // 60(measure period) - 2(disk utilization) 37 foreach($Values as $Index => $Value) 38 { 39 file_get_contents($URL.'?MeasureId='.$Index.'&Value='.$Value); 40 } 31 41 } 42 43 function RepeatFunction($Period, $Function) 44 { 45 while(1) 46 { 47 $StartTime = time(); 48 $Function(); 49 $EndTime = time(); 50 $Delay = $Period - ($EndTime - $StartTime); 51 if($Delay < 0) $Delay = 0; 52 53 echo('Waiting '.$Delay.' seconds...'."\n"); 54 sleep($Delay); 55 } 56 } 57 58 RepeatFunction(60 * 60, 'ProcessMeasure'); -
client/php/Linux.php
r63 r66 23 23 } 24 24 25 function Ping( )25 function Ping($Host = 'nix.cz') 26 26 { 27 exec('ping nix.cz-c 1 -W 1|grep time=', $Row);27 exec('ping '.$Host.' -c 1 -W 1|grep time=', $Row); 28 28 // W - timeout in seconds 29 29 // c - ping count … … 124 124 } 125 125 126 function DiskUtilization( )126 function DiskUtilization($Device = 'sda') 127 127 { 128 128 $Output = array(); 129 exec('iostat -d sda-x -m 2 2', $Output); // 2 second measure delay129 exec('iostat -d '.$Device.' -x -m 2 2', $Output); // 2 second measure delay 130 130 $Row = $Output[6]; 131 131 while(strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row); … … 135 135 } 136 136 137 function DiskFree( )137 function DiskFree($Path) 138 138 { 139 return(disk_free_space( '/'));139 return(disk_free_space($Path)); 140 140 } 141 141 -
client/php/WoW.php
r62 r66 3 3 // Funkce pro měření stavových veličin herního serveru hry World of Warcraft 4 4 5 include_once(' ../global.php');6 include_once(' system.php');5 include_once('Global.php'); 6 include_once('Linux.php'); 7 7 8 8 function WoWPlayersOnline()
Note:
See TracChangeset
for help on using the changeset viewer.