Ignore:
Timestamp:
Mar 21, 2009, 9:38:58 AM (16 years ago)
Author:
george
Message:
  • Upraveno: Funkce pro zjištění zátěže CPU nyní uchovává poslední stav v jedné proměnné. * Upraveno: Skript monitor.php se nyní spouští periodicky pomocí cronu namísto vnitřní nekonečné smyčky. Stavové informace pro některé funce se nyní ukládáají do temp souborů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/measure_scripts/monitor_sample.php

    r37 r39  
    22
    33// Toto je ukázkový skript pro aktualizaci dat. Zkopírujte si jej jako monitor.php a upravte podle potřeby.
     4// Skript spouštět přes crona každou minutu
    45
    56include('../global.php');
     
    78include('wow.php');
    89
    9 //GetNetworkState();
    10 while(1)
    11 {
    12   $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());
     10$LastNetworkState = unserializa(file_get_contents('/tmp/LastNetworkState'));
     11$LastCpuUsage = unserializa(file_get_contents('/tmp/LastCpuUsage'));
    2912
    30   sleep(58);  // 60(measure period) - 2(disk utilization)
    31 }
     13$NetworkState = GetNetworkState();
     14file_get_contents($Config['AddNewValueUrl'].'?MeasureId=3&Value='.MemoryUsage());
     15file_get_contents($Config['AddNewValueUrl'].'?MeasureId=4&Value='.CpuUsage());
     16file_get_contents($Config['AddNewValueUrl'].'?MeasureId=5&Value='.WoWPlayersOnline());
     17file_get_contents($Config['AddNewValueUrl'].'?MeasureId=6&Value='.WoWEmulatorRestartCount());
     18file_get_contents($Config['AddNewValueUrl'].'?MeasureId=7&Value='.DiskFree());
     19file_get_contents($Config['AddNewValueUrl'].'?MeasureId=8&Value='.WoWAccountCount());
     20file_get_contents($Config['AddNewValueUrl'].'?MeasureId=10&Value='.WoWGMOnline());
     21file_get_contents($Config['AddNewValueUrl'].'?MeasureId=11&Value='.round($NetworkState['eth1']['DownAverage']));
     22file_get_contents($Config['AddNewValueUrl'].'?MeasureId=12&Value='.round($NetworkState['eth1']['UpAverage']));
     23file_get_contents($Config['AddNewValueUrl'].'?MeasureId=13&Value='.WoWCharacterCount());
     24file_get_contents($Config['AddNewValueUrl'].'?MeasureId=14&Value='.WoWGuildCount());
     25file_get_contents($Config['AddNewValueUrl'].'?MeasureId=15&Value='.WoWEmulatorAvailability());
     26file_get_contents($Config['AddNewValueUrl'].'?MeasureId=16&Value='.Ping());
     27file_get_contents($Config['AddNewValueUrl'].'?MeasureId=17&Value='.TeamSpeak());
     28file_get_contents($Config['AddNewValueUrl'].'?MeasureId=18&Value='.WoWTranslatedQuestsCount());
     29file_get_contents($Config['AddNewValueUrl'].'?MeasureId=19&Value='.DiskUtilization());
     30
     31file_put_contents('/tmp/LastNetworkState', serialize($LastNetworkState));
     32file_put_contents('/tmp/LastCpuUsage', serialize($LastCpuUsage));
     33
    3234?>
Note: See TracChangeset for help on using the changeset viewer.