Changeset 873 for trunk/Modules/TimeMeasure/Measurement/System.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/TimeMeasure/Measurement/System.php
r660 r873 11 11 set_error_handler('ErrorHandler'); 12 12 //error_reporting(0); 13 if ($Fp1 = fsockopen($Ip, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout))13 if ($Fp1 = fsockopen($Ip, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout)) 14 14 { 15 15 fclose($Fp1); 16 return (TRUE);16 return (TRUE); 17 17 } else 18 18 { 19 19 //echo($ERROR_NO.','.$ERROR_STR); 20 return (FALSE);20 return (FALSE); 21 21 } 22 22 restore_error_handler(); … … 30 30 // c - ping count 31 31 $Parts = explode(' ', $Row[0]); 32 if (count($Parts) > 6)32 if (count($Parts) > 6) 33 33 { 34 34 $Time = $Parts[7]; 35 35 $TimeParts = explode('=', $Time); 36 return ($TimeParts[1]);37 } else return (0);36 return ($TimeParts[1]); 37 } else return (0); 38 38 } 39 39 … … 43 43 exec('free -b', $Output); 44 44 $Row = $Output[2]; 45 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row);45 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row); 46 46 $RowParts = explode(' ', $Row); 47 47 $Row = $Output[3]; 48 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row);48 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row); 49 49 $RowParts2 = explode(' ', $Row); 50 return ($RowParts[2] + $RowParts2[2]);50 return ($RowParts[2] + $RowParts2[2]); 51 51 } 52 52 … … 81 81 } 82 82 file_put_contents($CpuStateFileName, serialize($CpuUsage)); 83 return (100 - round($CpuUsagePercent['Idle'], 2));83 return (100 - round($CpuUsagePercent['Idle'], 2)); 84 84 } 85 85 … … 93 93 array_shift($Output); // Skip header 94 94 array_shift($Output); // Skip header 95 foreach ($Output as $Item)95 foreach ($Output as $Item) 96 96 { 97 while (strpos($Item, ' ') !== false) $Item = str_replace(' ', ' ', $Item); // Rrmove multiple spaces97 while (strpos($Item, ' ') !== false) $Item = str_replace(' ', ' ', $Item); // Rrmove multiple spaces 98 98 $Item = explode(':', $Item); 99 99 $Interface = trim($Item[0]); 100 100 $Item = explode(' ', trim($Item[1])); 101 101 $NetworkState[$Interface] = array('Down' => $Item[0], 'Up' => $Item[8]); 102 if (array_key_exists($Interface, $LastNetworkState))102 if (array_key_exists($Interface, $LastNetworkState)) 103 103 { 104 104 $Period = time() - $LastNetworkState['Time']; … … 110 110 $NetworkState[$Interface]['UpAverage'] = 0; 111 111 } 112 if ($NetworkState[$Interface]['DownAverage'] < 0) $NetworkState[$Interface]['DownAverage'] = 0;113 if ($NetworkState[$Interface]['UpAverage'] < 0) $NetworkState[$Interface]['UpAverage'] = 0;112 if ($NetworkState[$Interface]['DownAverage'] < 0) $NetworkState[$Interface]['DownAverage'] = 0; 113 if ($NetworkState[$Interface]['UpAverage'] < 0) $NetworkState[$Interface]['UpAverage'] = 0; 114 114 } 115 115 file_put_contents($NetworkStateFile, serialize($NetworkState)); 116 return ($NetworkState);116 return ($NetworkState); 117 117 } 118 118 … … 120 120 { 121 121 $NetworkState = $this->GetNetworkState(); 122 return ($NetworkState['Interface']['DownAverage']);122 return ($NetworkState['Interface']['DownAverage']); 123 123 } 124 124 … … 126 126 { 127 127 $NetworkState = $this->GetNetworkState(); 128 return ($NetworkState['Interface']['UpAverage']);128 return ($NetworkState['Interface']['UpAverage']); 129 129 } 130 130 … … 134 134 $Output = array(); 135 135 exec('cat /proc/net/nf_conntrack|grep "dst='.$HostIP.' "|grep "dport='.$Port.' "|grep "ASSURED"', $Output); 136 return (count($Output));136 return (count($Output)); 137 137 } 138 138 … … 142 142 exec('iostat -d '.$Device.' -x -m 2 2', $Output); // 2 second measure delay 143 143 $Row = $Output[6]; 144 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row);144 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row); 145 145 $Parts = explode(' ', $Row); 146 146 $Value = str_replace(',', '.', $Parts[11]); 147 return ($Value);147 return ($Value); 148 148 } 149 149 150 150 function DiskFree($Path) 151 151 { 152 return (disk_free_space($Path));152 return (disk_free_space($Path)); 153 153 } 154 154 … … 157 157 $Output = array(); 158 158 exec('/usr/bin/sensors', $Output); 159 foreach ($Output as $Line)159 foreach ($Output as $Line) 160 160 { 161 if (substr($Line, 0, strlen($Sensor)) == $Sensor)161 if (substr($Line, 0, strlen($Sensor)) == $Sensor) 162 162 { 163 163 $Line = substr($Line, strpos($Line, '+') + 1); 164 164 $Line = substr($Line, 0, strpos($Line, '°')); 165 return ($Line);165 return ($Line); 166 166 } 167 167 } 168 return (0);168 return (0); 169 169 } 170 170 … … 175 175 fclose($File); 176 176 $UptimeParts = explode(' ', $Uptime); 177 return ($UptimeParts[0]);177 return ($UptimeParts[0]); 178 178 } 179 179 }
Note:
See TracChangeset
for help on using the changeset viewer.