In this paper, we consider a sensor network with either node replacement or battery replacement as the maintenance operation. We address the problem of how the failed nodes are to be replaced, in order to obtain a desirable tradeoff between maintenance cost and network performance, in the management of the network. Since node replacement and battery replacement are analytically identical, we solve this problem only for the network, where the maintenance operation is node replacement. We do this by converting performance loss into cost terms and minimizing the summation of node replacement costs and performance loss costs. We use Markov decision processes (MDP) to develop a probabilistic approach in order to estimate the longrun cost of the network. For this we use statistical data based on the past behaviour of the network. We also propose an algorithm to determine the optimal node-replacement policy. The longrun node replacement cost and the longrun performance loss cost of the simulated network are found to be theoretically consistent.