#!/usr/local/bin/perl

chop(my $datadir = `argus-config --datadir`);
#$datadir = '/home/argus/data/'; # if argus-config is not in your path

opendir(D, "$datadir/stats/") || die "cannot opendir $datadir/stats/: $!\n";
foreach my $object (grep {!/^\./} readdir D){
	open(F, "$datadir/stats/$object") || die "cannot open $datadir/stats/$object: $!\n";
	chop(my $line = <F>);
	close F;

	if($line =~ /(\d+)$/){
		my $seconds = ($^T - $1);
		print "$object hasn't missed a poll for ";
		if($seconds >= 86400){
			$days = sprintf("%.0d",($seconds/86400));
			print "$days days";
		}elsif($seconds >= 3600){
			$hour = sprintf("%.0d",($seconds/3600));
			print "$hour hours";
		}elsif($seconds >= 60){
			$min = sprintf("%.0d",($seconds/60));
			print "$min minutes";
		}
		print " ($seconds seconds)\n";
		
	}else{
		warn "$object unknown\n";
	}
}
closedir D;
