mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
replace recently committed duration() by already existing format_uptime()
git-svn-id: http://www.observium.org/svn/observer/trunk@594 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -728,28 +728,6 @@ function discover_process_ipv6($ifIndex,$ipv6_address,$ipv6_prefixlen,$ipv6_orig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function duration($seconds, $max_periods = 6)
|
|
||||||
{
|
|
||||||
$periods = array("year" => 31536000, "month" => 2419200, "week" => 604800, "day" => 86400, "hour" => 3600, "minute" => 60, "second" => 1);
|
|
||||||
$i = 1;
|
|
||||||
foreach ( $periods as $period => $period_seconds )
|
|
||||||
{
|
|
||||||
$period_duration = floor($seconds / $period_seconds);
|
|
||||||
$seconds = $seconds % $period_seconds;
|
|
||||||
if ( $period_duration == 0 )
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$duration[] = "{$period_duration} {$period}" . ($period_duration > 1 ? 's' : '');
|
|
||||||
$i++;
|
|
||||||
if ( $i > $max_periods )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return implode(' ', $duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_astext($asn)
|
function get_astext($asn)
|
||||||
{
|
{
|
||||||
$result = dns_get_record("AS$asn.asn.cymru.com",DNS_TXT);
|
$result = dns_get_record("AS$asn.asn.cymru.com",DNS_TXT);
|
||||||
|
@@ -169,7 +169,7 @@ while ($device = mysql_fetch_array($device_query)) {
|
|||||||
|
|
||||||
if( $uptime < $device['uptime'] ) {
|
if( $uptime < $device['uptime'] ) {
|
||||||
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
||||||
mail($email, "Device Rebooted: " . $device['hostname'], "Device Rebooted : " . $device['hostname'] . " " . duration($uptime) . " ago.", $config['email_headers']);
|
mail($email, "Device Rebooted: " . $device['hostname'], "Device Rebooted : " . $device['hostname'] . " " . format_uptime($uptime) . " ago.", $config['email_headers']);
|
||||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $device['device_id'] . "', '', NOW(), 'Device rebooted')");
|
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $device['device_id'] . "', '', NOW(), 'Device rebooted')");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user