1
0
mirror of https://github.com/librenms/librenms-agent.git synced 2024-05-09 09:54:52 +00:00

if cache older than 360 seconds, don't use it

This commit is contained in:
VVelox
2017-02-23 09:54:38 -06:00
committed by GitHub
parent 0a78888889
commit 8bfbce68e5

View File

@ -45,7 +45,12 @@ getopts('u', \%opts);
my $noWrite=0;
if ( ! defined( $opts{u} ) ){
if ( -f $cache ){
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = stat($cache);
my $age=time-$mtime;
if (( -f $cache )&&( $age < 360 )){
my $old='';
open(my $readfh, "<", $cache) or die "Can't open '".$cache."'";
# if this is over 2048, something is most likely wrong
@ -55,7 +60,6 @@ if ( ! defined( $opts{u} ) ){
}else{
$opts{u}=1;
$noWrite=1;
}
}