Sometimes when I want to sleep within my house, I can't because of the "You may not sleep now, there are monsters nearby" warning. Within how many blocks does a hostile mob have to be to my bed to trigger this warning?
The system is much simpler since the full release — sleep is not allowed within 10 blocks of a hostile mob.
Quoted from the minecraft wiki. Hope this helps.