Abstract We study the maintenance of a machine operating under environmental conditions producing shocks affecting the lifetime of the machine. The shocks cause different types of damage depending on their strength and eventually the total failure. The maintenance of the machine is performed by repairs and replacement. The interarrival times of shocks are dependent. We introduce a multidimensional stochastic model for simulating the evolution of the lifetime of the machine. This model implies the application of the matrix-analytic methods, that are being used in stochastic modelling with interesting results. Under this methodology, the availability, the reliability, and the rates of occurrence of the different types of failures and of the replacements are calculated, obtaining mathematically tractable expressions. The results are applied to a numerical example.