Sunan an-Nasa'i, Book 20, Hadith 10 (In-Book)

It was narrated that Abu Hurairah said: The Messenger of Allah said: 'When any one of you goes to sleep, the Shaitan ties three knots on his head, saying each time: "(Sleep) a long night." If he wakes up and remembers Allah (SWT), one knot is undone. If he performs wudu', another knot is undone. If he prays, all the knots are undone and he starts his day in a good mood and feeling energetic. Otherwise he starts his day in a bad mood and feeling lethargic.'"

أَخْبَرَنَا مُحَمَّدُ بْنُ عَبْدِ اللَّهِ بْنِ يَزِيدَ، قَالَ حَدَّثَنَا سُفْيَانُ، عَنْ أَبِي الزِّنَادِ، عَنِ الأَعْرَجِ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ إِذَا نَامَ أَحَدُكُمْ عَقَدَ الشَّيْطَانُ عَلَى رَأْسِهِ ثَلاَثَ عُقَدٍ يَضْرِبُ عَلَى كُلِّ عُقْدَةٍ لَيْلاً طَوِيلاً أَىِ ارْقُدْ فَإِنِ اسْتَيْقَظَ فَذَكَرَ اللَّهَ انْحَلَّتْ عُقْدَةٌ فَإِنْ تَوَضَّأَ انْحَلَّتْ عُقْدَةٌ أُخْرَى فَإِنْ صَلَّى انْحَلَّتِ الْعُقَدُ كُلُّهَا فَيُصْبِحُ طَيِّبَ النَّفْسِ نَشِيطًا وَإِلاَّ أَصْبَحَ خَبِيثَ النَّفْسِ كَسْلاَنَ ‏" ‏ ‏.‏

sunnah.com