It is narrated from Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him): The Messenger of Allah (peace and blessings be upon him) used to command us to pray at the eclipse of the sun and the moon, (and he would say:) "When you see that an eclipse has occurred, hasten at once to the prayer, for if what you fear does happen, you will not be in a state of heedlessness; and if it does not, you will still have gained good and earned it."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 9747