Changeset 31 for measure_scripts
- Timestamp:
- May 19, 2008, 7:25:54 AM (17 years ago)
- Location:
- measure_scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
measure_scripts/monitor_sample.php
r30 r31 18 18 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=8&Value='.WoWAccountCount()); 19 19 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=10&Value='.WoWGMOnline()); 20 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=11&Value='.round($NetworkState['eth1'][' down_avg']));21 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=12&Value='.round($NetworkState['eth1'][' up_avg']));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 22 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=13&Value='.WoWCharacterCount()); 23 23 file_get_contents($Config['AddNewValueUrl'].'?MeasureId=14&Value='.WoWGuildCount()); -
measure_scripts/system.php
r30 r31 73 73 } else 74 74 { 75 $cpuUSERcent =0;76 $cpuSYSTcent =0;77 $cpuIDLEcent =0;75 $cpuUSERcent =0; 76 $cpuSYSTcent = 0; 77 $cpuIDLEcent = 0; 78 78 } 79 $cpuUSERprev =$cpuUSER;80 $cpuSYSTprev =$cpuSYST;81 $cpuIDLEprev =$cpuIDLE;82 return(100 -round($cpuIDLEcent*100)/100);79 $cpuUSERprev = $cpuUSER; 80 $cpuSYSTprev = $cpuSYST; 81 $cpuIDLEprev = $cpuIDLE; 82 return(100 - round($cpuIDLEcent * 100) / 100); 83 83 } 84 84 85 85 function GetNetworkState() 86 86 { 87 // Get last values 88 $File = fopen('/tmp/traffic', 'r'); 89 $LastResult = unserialize(fgets($File)); 90 fclose($File); 87 global $LastNetworkState; 91 88 92 $Result = array('time' => time()); 89 if(!isset($LastNetworkState)) $LastNetworkState = array(); 90 $NetworkState = array('Time' => time()); 93 91 $Output = array(); 94 92 exec('cat /proc/net/dev', $Output); 95 array_shift($Output); 96 array_shift($Output); 93 array_shift($Output); // Skip header 94 array_shift($Output); // Skip header 97 95 foreach($Output as $Item) 98 96 { 99 // echo($Item."\n"); 100 while(strpos($Item, ' ') !== false) $Item = str_replace(' ', ' ', $Item); 97 while(strpos($Item, ' ') !== false) $Item = str_replace(' ', ' ', $Item); // Rrmove multiple spaces 101 98 $Item = explode(':', $Item); 102 99 $Interface = trim($Item[0]); 103 100 $Item = explode(' ', trim($Item[1])); 104 $Period = time() - $LastResult['time']; 105 $Result[$Interface] = array('down' => $Item[0], 'up' => $Item[8]); 106 $Result[$Interface]['down_avg'] = round(($Result[$Interface]['down'] - $LastResult[$Interface]['down']) / $Period); 107 $Result[$Interface]['up_avg'] = round(($Result[$Interface]['up'] - $LastResult[$Interface]['up']) / $Period); 108 if($Result[$Interface]['down_avg'] < 0) $Result[$Interface]['down_avg'] = 0; 109 if($Result[$Interface]['up_avg'] < 0) $Result[$Interface]['up_avg'] = 0; 101 $NetworkState[$Interface] = array('Down' => $Item[0], 'Up' => $Item[8]); 102 if(array_key_exists($Interface, $LastNetworkState)) 103 { 104 $Period = time() - $LastNetworkState['Time']; 105 $NetworkState[$Interface]['DownAverage'] = round(($NetworkState[$Interface]['Down'] - $LastNetworkState[$Interface]['Down']) / $Period); 106 $NetworkState[$Interface]['UpAverage'] = round(($NetworkState[$Interface]['Up'] - $LastNetworkState[$Interface]['Up']) / $Period); 107 } else 108 { 109 $NetworkState[$Interface]['DownAverage'] = 0; 110 $NetworkState[$Interface]['UpAverage'] = 0; 111 } 112 if($NetworkState[$Interface]['DownAverage'] < 0) $NetworkState[$Interface]['DownAverage'] = 0; 113 if($NetworkState[$Interface]['UpAverage'] < 0) $NetworkState[$Interface]['UpAverage'] = 0; 110 114 } 111 // Save last values 112 $File = fopen('/tmp/traffic', 'w+'); 113 fputs($File, serialize($Result)); 114 fclose($File); 115 // print_r($Result); 116 return($Result); 115 $LastNetworkState = $NetworkState; 116 return($NetworkState); 117 117 } 118 118 119 function TeamSpeak()119 function NetworkServiceConnectionCount($Port) 120 120 { 121 $HostIP = gethostbyname(trim(`hostname`)); 121 122 $Output = array(); 122 exec('cat /proc/net/nf_conntrack|grep "dst= 192.168.0.14 "|grep "dport=8767"|grep "ASSURED"', $Output);123 exec('cat /proc/net/nf_conntrack|grep "dst='.$HostIP.' "|grep "dport='.$Port.' "|grep "ASSURED"', $Output); 123 124 return(count($Output)); 124 125 } -
measure_scripts/wow.php
r30 r31 51 51 52 52 $Database->select_db('characters'); 53 $DbResult = $Database->query('SELECT COUNT(*) FROM `character `');53 $DbResult = $Database->query('SELECT COUNT(*) FROM `characters`'); 54 54 $Row = $DbResult->fetch_array(); 55 55 return($Row[0]); … … 60 60 global $Database; 61 61 62 $Database->select_db(' wow');63 $DbResult = $Database->query('SELECT COUNT(*) FROM mangos_restart');62 $Database->select_db('mangos'); 63 $DbResult = $Database->query('SELECT COUNT(*) FROM uptime'); 64 64 $Row = $DbResult->fetch_array(); 65 65 return($Row[0]);
Note:
See TracChangeset
for help on using the changeset viewer.