Changeset 66 for client/php/Client.php


Ignore:
Timestamp:
Jan 2, 2016, 12:17:56 AM (9 years ago)
Author:
chronos
Message:
  • Moved: Measure scripts should be part of client, not statistic web itself.
Location:
client/php
Files:
1 added
1 copied

Legend:

Unmodified
Added
Removed
  • client/php/Client.php

    r65 r66  
    11<?php
    22
    3 // Toto je ukázkový skript pro aktualizaci dat. Zkopírujte si jej jako monitor.php a upravte podle potřeby.
     3include('Global.php');
    44
    5 include('../global.php');
    6 include('system.php');
    7 include('wow.php');
     5// Various measure libraries
     6include('Linux.php');
     7include('WoW.php');
     8include('Centrala.php');
     9include('Routerboard.php');
    810
    9 //GetNetworkState();
    10 while(1)
     11function ProcessMeasure()
    1112{
     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();
    1220  $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');
    2936
    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  }
    3141}
     42
     43function 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
     58RepeatFunction(60 * 60, 'ProcessMeasure');
Note: See TracChangeset for help on using the changeset viewer.