I've been reading up on the methods to prevent players from the famous "15-minute workday", resting up after each fight. There are a lot of interesting solutions, like introducing a time constraint, or making the dungeon change due to time passing. See for example How do I prevent retreating to rest and heal from being tedious.
However from a RAW point of view, it appears that interrupting a long rest by DM action isn't all that easy, as players can fight 59 minutes without their rest being interrupted. It is more a question of the DM inventing some sort of punishment every time the group wants to rest "too early". And if the consequence of resting is arbitrary, the players don't know when a long rest is actually supposed to happen.
So I would rather have some guidelines how dangerous a long rest really is. Is there any system to determine the number of random encounters and the difficulty of those encounters a group would be likely to have if resting in a dungeon or in the wilderness? If I have some basic rules on how often to roll and some base values for probability, I could adjust them for example if the players rest just outside the dungeon, or in a room with doors barred.
TLDR: I'd rather use some dice rolls to determine consequences of a long rest in dangerous environments. What would appropriate probabilities for a random encounter be, and how hard should it be?