Merge pull request #2719 from SaaldjorMike/del-utime-func

Replaced custom utime() function with microtime(true)
This commit is contained in:
Neil Lathwood
2016-01-10 22:43:31 +00:00
8 changed files with 14 additions and 29 deletions

View File

@@ -20,7 +20,7 @@ require 'includes/definitions.inc.php';
require 'includes/functions.php';
require 'includes/discovery/functions.inc.php';
$start = utime();
$start = microtime(true);
$runtime_stats = array();
$sqlparams = array();
$options = getopt('h:m:i:n:d::a::q',array('os:','type:'));
@@ -129,7 +129,7 @@ foreach (dbFetch("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $whe
discover_device($device, $options);
}
$end = utime();
$end = microtime(true);
$run = ($end - $start);
$proctime = substr($run, 0, 5);

View File

@@ -12,15 +12,7 @@
*/
function utime() {
$time = explode(' ', microtime());
$usec = (double) $time[0];
$sec = (double) $time[1];
return ($sec + $usec);
}
$start = utime();
$start = microtime(true);
require_once 'Net/IPv4.php';
@@ -54,7 +46,7 @@ require 'includes/graphs/graph.inc.php';
$console_color = new Console_Color2();
$end = utime();
$end = microtime(true);
$run = ($end - $start);

View File

@@ -72,7 +72,7 @@ $config['memcached']['ttl'] = $config['time']['now']+300;
Plugins::start();
$runtime_start = utime();
$runtime_start = microtime(true);
ob_start();
@@ -263,7 +263,7 @@ else {
</div>
<?php
$runtime_end = utime();
$runtime_end = microtime(true);
$runtime = $runtime_end - $runtime_start;
$gentime = substr($runtime, 0, 5);

View File

@@ -89,7 +89,7 @@ function discover_device($device, $options=null) {
// Reset $valid array
$attribs = get_dev_attribs($device['device_id']);
$device_start = utime();
$device_start = microtime(true);
// Start counting device poll time
echo $device['hostname'].' '.$device['device_id'].' '.$device['os'].' ';
@@ -146,7 +146,7 @@ function discover_device($device, $options=null) {
}
}
$device_end = utime();
$device_end = microtime(true);
$device_run = ($device_end - $device_start);
$device_time = substr($device_run, 0, 5);

View File

@@ -529,13 +529,6 @@ function is_odd($number) {
return $number & 1; // 0 = even, 1 = odd
}
function utime() {
$time = explode(" ", microtime());
$usec = (double)$time[0];
$sec = (double)$time[1];
return $sec + $usec;
}
function getpollergroup($poller_group='0') {
//Is poller group an integer
if (is_int($poller_group) || ctype_digit($poller_group)) {

View File

@@ -135,7 +135,7 @@ function poll_device($device, $options) {
$status = 0;
unset($array);
$device_start = utime();
$device_start = microtime(true);
// Start counting device poll time
echo $device['hostname'].' '.$device['device_id'].' '.$device['os'].' ';
if ($config['os'][$device['os']]['group']) {
@@ -253,7 +253,7 @@ function poll_device($device, $options) {
}
}//end if
$device_end = utime();
$device_end = microtime(true);
$device_run = ($device_end - $device_start);
$device_time = substr($device_run, 0, 5);

View File

@@ -14,7 +14,7 @@ if ($device['os_group'] == 'unix') {
$config['unix-agent']['read-timeout'] = $config['unix-agent-read-time-out'];
}
$agent_start = utime();
$agent_start = microtime(true);
$agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent']['connection-timeout']);
// Set stream timeout (for timeouts during agent fetch
@@ -36,7 +36,7 @@ if ($device['os_group'] == 'unix') {
}
}
$agent_end = utime();
$agent_end = microtime(true);
$agent_time = round(($agent_end - $agent_start) * 1000);
if (!empty($agent_raw)) {

View File

@@ -21,7 +21,7 @@ require 'includes/functions.php';
require 'includes/polling/functions.inc.php';
require 'includes/alerts.inc.php';
$poller_start = utime();
$poller_start = microtime(true);
echo $config['project_name_version']." Poller\n";
$versions = version_info(false);
echo "Version info:\n";
@@ -136,7 +136,7 @@ foreach (dbFetch($query) as $device) {
$polled_devices++;
}
$poller_end = utime();
$poller_end = microtime(true);
$poller_run = ($poller_end - $poller_start);
$poller_time = substr($poller_run, 0, 5);