Changeset 37 for system/statistic


Ignore:
Timestamp:
Jan 31, 2008, 8:38:47 PM (17 years ago)
Author:
george
Message:

Upraveno: Přepsán přístup k databázi přes třídu mysqli v systémové složce.
Odstraněno: Staré verze souborů a staré nepoužité soubory.

Location:
system
Files:
7 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • system

    • Property svn:ignore set to
      nohup.out
  • system/statistic

    • Property svn:ignore set to
      nohup.out
  • system/statistic/connections.php

    r1 r37  
    1 <?
    2 include_once('/a/html/is/db.php');
    3 DB_Init('localhost','root','','statistic');
     1<?php
     2include_once('../html/global.php');
     3$Database->select('statistic');
    44
    55while(1)
    66{
    77  $Id = 1;
    8   DB_Delete('ip_conntrack', '1');
     8  $Database->delete('ip_conntrack', '1');
    99  $File = fopen('/proc/net/ip_conntrack', 'r');
    1010  while(!feof($File))
     
    4040      $Size2 = array_shift($Parts);
    4141
    42       DB_Insert('ip_conntrack', array('id' => $Id, 'proto' => $ProtocolType, 'timeout' => $Timeout, 'state' => $TcpState,    'src_addr' => $SourceAddress, 'dst_addr' => $DestinationAddress, 'src_port' => $SourcePort, 'dst_port' => $DestinationPort, 'size' => $Size, 'src_addr2' => $SourceAddress2, 'dst_addr2' => $DestinationAddress2, 'src_port2' => $SourcePort2, 'dst_port2' => $DestinationPort2, 'size2' => $Size2));
     42      $Database->insert('ip_conntrack', array('id' => $Id, 'proto' => $ProtocolType, 'timeout' => $Timeout, 'state' => $TcpState,    'src_addr' => $SourceAddress, 'dst_addr' => $DestinationAddress, 'src_port' => $SourcePort, 'dst_port' => $DestinationPort, 'size' => $Size, 'src_addr2' => $SourceAddress2, 'dst_addr2' => $DestinationAddress2, 'src_port2' => $SourcePort2, 'dst_port2' => $DestinationPort2, 'size2' => $Size2));
    4343      $Id = $Id + 1;
    4444    } 
  • system/statistic/known_mac.php

    r1 r37  
    1 <?
    2 include_once('/a/html/is/db.php');
    3 DB_Init('localhost','root','','statistic');
     1<?php
     2include_once('../html/global.php');
     3$Database->select_db('statistic');
    44
    55while(1)
    66{
    7   DB_Delete('ip_conntrack', '1');
     7  $Database->delete('ip_conntrack', '1');
    88  $File = fopen('/proc/net/arp', 'r');
    99  fgets($File);  // Title row
     
    2020      if($Mac != '00:00:00:00:00:00')
    2121      {
    22         DB_Select('known_mac', '*', 'ip="'.$Ip.'" AND mac="'.$Mac.'" AND interface="'.$Interface.'"');
    23         if(DB_NumRows() == 0) DB_Insert('known_mac', array('ip' => $Ip, 'mac' => $Mac, 'interface' => $Interface, 'first_time' => 'NOW()', 'last_time' => 'NOW()'));
    24           else DB_Update('known_mac', 'ip="'.$Ip.'" AND mac="'.$Mac.'" AND interface="'.$Interface.'"', array('last_time' => 'NOW()'));
     22        $DbResult = $Database->select('known_mac', '*', 'ip="'.$Ip.'" AND mac="'.$Mac.'" AND interface="'.$Interface.'"');
     23        if($DbResult->num_rows == 0) $Database->insert('known_mac', array('ip' => $Ip, 'mac' => $Mac, 'interface' => $Interface, 'first_time' => 'NOW()', 'last_time' => 'NOW()'));
     24          else $Database->update('known_mac', 'ip="'.$Ip.'" AND mac="'.$Mac.'" AND interface="'.$Interface.'"', array('last_time' => 'NOW()'));
    2525      }
    2626    } 
     
    2828  }
    2929  fclose($File);
    30   DB_Query('OPTIMIZE TABLE known_mac');
     30  $Database->query('OPTIMIZE TABLE known_mac');
    3131  Sleep(50);  // ARP cache timeout = 60 seconds
    3232}
  • system/statistic/traffic.php

    r1 r37  
    1 <?
    2 
     1<?php
     2
     3include('../../html/global.php');
     4$Database->select_db('statistic');
     5$Config['Web']['ShowError'] = 1;
    36echo("\nSledovac prenesenych dat\n");
    4 include('/a/html/is/db.php');
    5 DB_Init('localhost','root','','statistic');
    67$ERR = 0;
    78
    89function CpuUsage()
    910
    10   global $cpuIDLEprev, $cpuSYSTprev, $cpuUSERprev;
     11  global $cpuIDLEprev, $cpuSYSTprev, $cpuUSERprev, $Database;
     12
    1113  // get processor usage seconds for pct stats ###
    1214  $File = fopen('/proc/stat', 'r');
     
    8890function Resetuj()
    8991{
    90   global $ERR, $ID;
     92  global $ERR, $ID, $Database;
     93
    9194  echo("Error ".$ERR.". - restartuji pripojeni...");
    9295  if($ERR == 0)
    9396  {
    94     DB_Insert('failure', array('time' => 'NOW()', 'attempt' => 0));
    95     DB_Query('SELECT LAST_INSERT_ID() FROM failure LIMIT 0,1');
    96     $Row = DB_Row();   
     97    $Database->insert('failure', array('time' => 'NOW()', 'attempt' => 0));
     98    $DbResult = $Database->query('SELECT LAST_INSERT_ID() FROM failure LIMIT 0,1');
     99    $Row = $DbResult->fetch_array();   
    97100    $ID = $Row[0];
    98101  }
    99   else DB_Update('failure', 'id='.$ID,array('attempt' => $ERR));
     102  else $Database->update('failure', 'id='.$ID,array('attempt' => $ERR));
    100103  // echo($ID);
    101104//  if($ERR == 5) exec('killall -TERM pppd',$Output);
     
    123126  sleep(60);
    124127  $NetworkStat = GetNetworkStat();
    125   // zji¹tìní vytí¾ení procesoru
     128  // zjit��vyt�n�procesoru
    126129  $CPU = CpuUsage();
    127130  //$loadavg = fopen('/proc/loadavg','r');
     
    129132  //$CPU = $data[0];
    130133  //fclose($loadavg);
    131   // zji¹tìní poètu zapnutých poèítaèù
     134  // zjit��po�u zapnutch po�ta�
    132135 
    133   DB_Init('localhost','root','','is');
    134   DB_Query('SELECT COUNT(*) FROM hosts WHERE online=1 AND show_online=1');
    135   $Row = DB_Row();
     136  $Database->select_db('is');
     137  $DbResult = $Database->query('SELECT COUNT(*) FROM hosts WHERE online=1 AND show_online=1');
     138  $Row = $DbResult->fetch_array();
    136139  $OnlineHosts = $Row[0];
    137140
    138   DB_Query('SELECT COUNT(*) FROM users WHERE role=0');
    139   $Row = DB_Row();
     141  $DbResult = $Database->query('SELECT COUNT(*) FROM users WHERE role=0');
     142  $Row = $DbResult->fetch_array();
    140143  $MembersCount = $Row[0];
    141144
    142   DB_Init('localhost','root','','statistic');
     145  $Database->select_db('statistic');
    143146  $HDD = round(disk_free_space('/')/1024);
    144147  $HDD2 = round(disk_free_space('/mnt/sda1')/1024);
    145148 
    146   // Naètení teploty
     149  // Na�en�teploty
    147150  fseek($TemperatureFile,0);
    148151  $Temperature = fgets($TemperatureFile, 1000);
     
    153156  $Ping = Ping(); 
    154157
     158/*
    155159  file_get_contents('http://localhost/statistic/new/add.php?MeasureId=1&Value='.$NetworkStat['eth1']['down_avg']);
    156160  file_get_contents('http://localhost/statistic/new/add.php?MeasureId=2&Value='.$NetworkStat['eth1']['up_avg']);
     
    171175  file_get_contents('http://localhost/statistic/new/add.php?MeasureId=20&Value='.$NetworkStat['eth2']['down_avg']);
    172176  echo(file_get_contents('http://localhost/statistic/new/add.php?MeasureId=21&Value='.$NetworkStat['eth2']['up_avg']));
     177*/
    173178 
    174179//  echo('Down: '.$NetworkStat['eth1']['down_avg'].'  Up: '.$NetworkStat['eth1']['up_avg'].'  CPU: '.$CPU.'  HDD: '.$HDD.'  Hosts: '.$OnlineHosts.' Temperature: '.$Temperature.' GameServerCpu: '.$GameServerCpu.' WowPlayerCount2: '.$WowPlayerCount2.' Game-serverUsedMemory: '.$Centrala2UsedMemory.' Ping: '.$Ping);
     
    185190    'wlan2_down' => $NetworkStat['wlan2']['down_avg'], 'wlan2_up' => $NetworkStat['wlan2']['up_avg'],
    186191    'eth2_down' => $NetworkStat['eth2']['down_avg'], 'eth2_up' => $NetworkStat['eth2']['up_avg']);
    187   DB_Insert('traffic', $NewItem);
     192  $Database->insert('traffic', $NewItem);
    188193  //echo(serialize($NewItem)."\n");
    189194    //$LevelDivider = 10;
Note: See TracChangeset for help on using the changeset viewer.