Machine diagnostics and monitoring