device-statistics-to-db.sh modified