Machine diagnostics and predictive maintenance for Industry 4.0 and IoT