mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #2719 from SaaldjorMike/del-utime-func
Replaced custom utime() function with microtime(true)
This commit is contained in:
@@ -20,7 +20,7 @@ require 'includes/definitions.inc.php';
|
|||||||
require 'includes/functions.php';
|
require 'includes/functions.php';
|
||||||
require 'includes/discovery/functions.inc.php';
|
require 'includes/discovery/functions.inc.php';
|
||||||
|
|
||||||
$start = utime();
|
$start = microtime(true);
|
||||||
$runtime_stats = array();
|
$runtime_stats = array();
|
||||||
$sqlparams = array();
|
$sqlparams = array();
|
||||||
$options = getopt('h:m:i:n:d::a::q',array('os:','type:'));
|
$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);
|
discover_device($device, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
$end = utime();
|
$end = microtime(true);
|
||||||
$run = ($end - $start);
|
$run = ($end - $start);
|
||||||
$proctime = substr($run, 0, 5);
|
$proctime = substr($run, 0, 5);
|
||||||
|
|
||||||
|
@@ -12,15 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function utime() {
|
$start = microtime(true);
|
||||||
$time = explode(' ', microtime());
|
|
||||||
$usec = (double) $time[0];
|
|
||||||
$sec = (double) $time[1];
|
|
||||||
return ($sec + $usec);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$start = utime();
|
|
||||||
|
|
||||||
require_once 'Net/IPv4.php';
|
require_once 'Net/IPv4.php';
|
||||||
|
|
||||||
@@ -54,7 +46,7 @@ require 'includes/graphs/graph.inc.php';
|
|||||||
|
|
||||||
$console_color = new Console_Color2();
|
$console_color = new Console_Color2();
|
||||||
|
|
||||||
$end = utime();
|
$end = microtime(true);
|
||||||
$run = ($end - $start);
|
$run = ($end - $start);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -72,7 +72,7 @@ $config['memcached']['ttl'] = $config['time']['now']+300;
|
|||||||
|
|
||||||
Plugins::start();
|
Plugins::start();
|
||||||
|
|
||||||
$runtime_start = utime();
|
$runtime_start = microtime(true);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ else {
|
|||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$runtime_end = utime();
|
$runtime_end = microtime(true);
|
||||||
$runtime = $runtime_end - $runtime_start;
|
$runtime = $runtime_end - $runtime_start;
|
||||||
$gentime = substr($runtime, 0, 5);
|
$gentime = substr($runtime, 0, 5);
|
||||||
|
|
||||||
|
@@ -89,7 +89,7 @@ function discover_device($device, $options=null) {
|
|||||||
// Reset $valid array
|
// Reset $valid array
|
||||||
$attribs = get_dev_attribs($device['device_id']);
|
$attribs = get_dev_attribs($device['device_id']);
|
||||||
|
|
||||||
$device_start = utime();
|
$device_start = microtime(true);
|
||||||
// Start counting device poll time
|
// Start counting device poll time
|
||||||
echo $device['hostname'].' '.$device['device_id'].' '.$device['os'].' ';
|
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_run = ($device_end - $device_start);
|
||||||
$device_time = substr($device_run, 0, 5);
|
$device_time = substr($device_run, 0, 5);
|
||||||
|
|
||||||
|
@@ -529,13 +529,6 @@ function is_odd($number) {
|
|||||||
return $number & 1; // 0 = even, 1 = odd
|
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') {
|
function getpollergroup($poller_group='0') {
|
||||||
//Is poller group an integer
|
//Is poller group an integer
|
||||||
if (is_int($poller_group) || ctype_digit($poller_group)) {
|
if (is_int($poller_group) || ctype_digit($poller_group)) {
|
||||||
|
@@ -135,7 +135,7 @@ function poll_device($device, $options) {
|
|||||||
|
|
||||||
$status = 0;
|
$status = 0;
|
||||||
unset($array);
|
unset($array);
|
||||||
$device_start = utime();
|
$device_start = microtime(true);
|
||||||
// Start counting device poll time
|
// Start counting device poll time
|
||||||
echo $device['hostname'].' '.$device['device_id'].' '.$device['os'].' ';
|
echo $device['hostname'].' '.$device['device_id'].' '.$device['os'].' ';
|
||||||
if ($config['os'][$device['os']]['group']) {
|
if ($config['os'][$device['os']]['group']) {
|
||||||
@@ -253,7 +253,7 @@ function poll_device($device, $options) {
|
|||||||
}
|
}
|
||||||
}//end if
|
}//end if
|
||||||
|
|
||||||
$device_end = utime();
|
$device_end = microtime(true);
|
||||||
$device_run = ($device_end - $device_start);
|
$device_run = ($device_end - $device_start);
|
||||||
$device_time = substr($device_run, 0, 5);
|
$device_time = substr($device_run, 0, 5);
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ if ($device['os_group'] == 'unix') {
|
|||||||
$config['unix-agent']['read-timeout'] = $config['unix-agent-read-time-out'];
|
$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']);
|
$agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent']['connection-timeout']);
|
||||||
|
|
||||||
// Set stream timeout (for timeouts during agent fetch
|
// 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);
|
$agent_time = round(($agent_end - $agent_start) * 1000);
|
||||||
|
|
||||||
if (!empty($agent_raw)) {
|
if (!empty($agent_raw)) {
|
||||||
|
@@ -21,7 +21,7 @@ require 'includes/functions.php';
|
|||||||
require 'includes/polling/functions.inc.php';
|
require 'includes/polling/functions.inc.php';
|
||||||
require 'includes/alerts.inc.php';
|
require 'includes/alerts.inc.php';
|
||||||
|
|
||||||
$poller_start = utime();
|
$poller_start = microtime(true);
|
||||||
echo $config['project_name_version']." Poller\n";
|
echo $config['project_name_version']." Poller\n";
|
||||||
$versions = version_info(false);
|
$versions = version_info(false);
|
||||||
echo "Version info:\n";
|
echo "Version info:\n";
|
||||||
@@ -136,7 +136,7 @@ foreach (dbFetch($query) as $device) {
|
|||||||
$polled_devices++;
|
$polled_devices++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$poller_end = utime();
|
$poller_end = microtime(true);
|
||||||
$poller_run = ($poller_end - $poller_start);
|
$poller_run = ($poller_end - $poller_start);
|
||||||
$poller_time = substr($poller_run, 0, 5);
|
$poller_time = substr($poller_run, 0, 5);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user