Only generate statistics if statistics.interval.ms is non-zero

Reported by Eugenio Peréz Martín