Al-Walid bin Ubadah (may Allah have mercy on him) said: I visited Sayyiduna Ubadah bin al-Samit (may Allah be pleased with him) while he was ill and death was thought to be near him, or (its signs) were becoming clear. I said: "O my father, give me your counsel and exert yourself (in advising) me." He said: "Sit me up." When they had sat him up, he said: "O my dear son, you will never taste the sweetness of faith, nor attain the true reality of knowledge, until you believe in the divine decree, its good and its bad." I said: "O my father, how can I know what is the good of the decree and what is its bad?" He said: "Be firmly certain that whatever (affliction) missed you was not going to reach you, and whatever reached you was not going to miss you. O my son, I heard the Messenger of Allah (peace and blessings be upon him) say: 'The first thing Allah, the Mighty and Majestic, created was the Pen, and He commanded it: Write! So in that very moment the Pen wrote everything that would happen until the Day of Resurrection.' O my son, if you die in any state other than this (belief), you will enter the Fire of Hell."
I (al-Busiri) say: This chain is sahih (authentic) and all its narrators are thiqat (trustworthy).
Imam Abu Dawud al-Sijistani (may Allah have mercy on him) recorded it in abridged form in his Sunan via Abu Hafsah from Sayyiduna Ubadah bin al-Samit (may Allah be pleased with him).
Imam al-Tirmidhi (may Allah have mercy on him) recorded it in his Jami' via Yahya bin Musa, Abu Dawud al-Tayalisi, Abd al-Wahid bin Sulaym and Ata bin Abi Rabah, as the narration of al-Walid bin Ubadah (may Allah have mercy on him) from his father (Sayyiduna Ubadah bin al-Samit (may Allah be pleased with him)).
He too mentioned it in abridged form,
and said that this hadith is hasan sahih gharib.
That is what Imam al-Tirmidhi (may Allah have mercy on him) said, but in fact its chain has weakness because of the weakness of Abd al-Wahid bin Sulaym.