A Markovian stochastic model for a system subject to random shocks is considered. Each shock arriving according to a Poisson process decreases the state of the system by a random amount. A repairman arriving according to another Poisson process repairs the system only if the state is below a threshold. Costs are assigned to each visit of the repairman, to each repair, and to the system being in bad states below the threshold. It is shown that there exists a unique arrival rate of the repairman which minimizes the expected long-run average cost.