The detection of impending failure in implanted pacemakers