Changeset 37 for system/statistic
- Timestamp:
- Jan 31, 2008, 8:38:47 PM (17 years ago)
- Location:
- system
- Files:
-
- 7 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
system
-
Property svn:ignore
set to
nohup.out
-
Property svn:ignore
set to
-
system/statistic
-
Property svn:ignore
set to
nohup.out
-
Property svn:ignore
set to
-
system/statistic/connections.php
r1 r37 1 <? 2 include_once(' /a/html/is/db.php');3 DB_Init('localhost','root','','statistic');1 <?php 2 include_once('../html/global.php'); 3 $Database->select('statistic'); 4 4 5 5 while(1) 6 6 { 7 7 $Id = 1; 8 DB_Delete('ip_conntrack', '1');8 $Database->delete('ip_conntrack', '1'); 9 9 $File = fopen('/proc/net/ip_conntrack', 'r'); 10 10 while(!feof($File)) … … 40 40 $Size2 = array_shift($Parts); 41 41 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)); 43 43 $Id = $Id + 1; 44 44 } -
system/statistic/known_mac.php
r1 r37 1 <? 2 include_once(' /a/html/is/db.php');3 DB_Init('localhost','root','','statistic');1 <?php 2 include_once('../html/global.php'); 3 $Database->select_db('statistic'); 4 4 5 5 while(1) 6 6 { 7 DB_Delete('ip_conntrack', '1');7 $Database->delete('ip_conntrack', '1'); 8 8 $File = fopen('/proc/net/arp', 'r'); 9 9 fgets($File); // Title row … … 20 20 if($Mac != '00:00:00:00:00:00') 21 21 { 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()')); 25 25 } 26 26 } … … 28 28 } 29 29 fclose($File); 30 DB_Query('OPTIMIZE TABLE known_mac');30 $Database->query('OPTIMIZE TABLE known_mac'); 31 31 Sleep(50); // ARP cache timeout = 60 seconds 32 32 } -
system/statistic/traffic.php
r1 r37 1 <? 2 1 <?php 2 3 include('../../html/global.php'); 4 $Database->select_db('statistic'); 5 $Config['Web']['ShowError'] = 1; 3 6 echo("\nSledovac prenesenych dat\n"); 4 include('/a/html/is/db.php');5 DB_Init('localhost','root','','statistic');6 7 $ERR = 0; 7 8 8 9 function CpuUsage() 9 10 { 10 global $cpuIDLEprev, $cpuSYSTprev, $cpuUSERprev; 11 global $cpuIDLEprev, $cpuSYSTprev, $cpuUSERprev, $Database; 12 11 13 // get processor usage seconds for pct stats ### 12 14 $File = fopen('/proc/stat', 'r'); … … 88 90 function Resetuj() 89 91 { 90 global $ERR, $ID; 92 global $ERR, $ID, $Database; 93 91 94 echo("Error ".$ERR.". - restartuji pripojeni..."); 92 95 if($ERR == 0) 93 96 { 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(); 97 100 $ID = $Row[0]; 98 101 } 99 else DB_Update('failure', 'id='.$ID,array('attempt' => $ERR));102 else $Database->update('failure', 'id='.$ID,array('attempt' => $ERR)); 100 103 // echo($ID); 101 104 // if($ERR == 5) exec('killall -TERM pppd',$Output); … … 123 126 sleep(60); 124 127 $NetworkStat = GetNetworkStat(); 125 // zji ¹tìní vytí¾eníprocesoru128 // zjit��vyt�n�procesoru 126 129 $CPU = CpuUsage(); 127 130 //$loadavg = fopen('/proc/loadavg','r'); … … 129 132 //$CPU = $data[0]; 130 133 //fclose($loadavg); 131 // zji ¹tìní poètu zapnutých poèítaèù134 // zjit��po�u zapnutch po�ta� 132 135 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(); 136 139 $OnlineHosts = $Row[0]; 137 140 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(); 140 143 $MembersCount = $Row[0]; 141 144 142 DB_Init('localhost','root','','statistic');145 $Database->select_db('statistic'); 143 146 $HDD = round(disk_free_space('/')/1024); 144 147 $HDD2 = round(disk_free_space('/mnt/sda1')/1024); 145 148 146 // Na èteníteploty149 // Na�en�teploty 147 150 fseek($TemperatureFile,0); 148 151 $Temperature = fgets($TemperatureFile, 1000); … … 153 156 $Ping = Ping(); 154 157 158 /* 155 159 file_get_contents('http://localhost/statistic/new/add.php?MeasureId=1&Value='.$NetworkStat['eth1']['down_avg']); 156 160 file_get_contents('http://localhost/statistic/new/add.php?MeasureId=2&Value='.$NetworkStat['eth1']['up_avg']); … … 171 175 file_get_contents('http://localhost/statistic/new/add.php?MeasureId=20&Value='.$NetworkStat['eth2']['down_avg']); 172 176 echo(file_get_contents('http://localhost/statistic/new/add.php?MeasureId=21&Value='.$NetworkStat['eth2']['up_avg'])); 177 */ 173 178 174 179 // 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); … … 185 190 'wlan2_down' => $NetworkStat['wlan2']['down_avg'], 'wlan2_up' => $NetworkStat['wlan2']['up_avg'], 186 191 'eth2_down' => $NetworkStat['eth2']['down_avg'], 'eth2_up' => $NetworkStat['eth2']['up_avg']); 187 DB_Insert('traffic', $NewItem);192 $Database->insert('traffic', $NewItem); 188 193 //echo(serialize($NewItem)."\n"); 189 194 //$LevelDivider = 10;
Note:
See TracChangeset
for help on using the changeset viewer.