I've come across this problem before when I was developing some physics code for a college project. I'm going to make an assumption that there is some code handling whether or not your rock is in a rest state. If you don't have this piece of code then it can be implemented as follows:
float positionEpsilon = [EPSILONVAL] // Use to check if the position of the rock has changed by a significant amount
// Update the rock
void UpdateRock(Time delta)
{
changeInPosition = [CURRPOS] - [PREVPOS] // Take the last position from the current position
.
. // Some code
.
if(changeInPosition < positionEpsilon)
{
// Here you could perform an action on the rock
// or put it to sleep and check if it's asleep
// in another part of the code
}
}
That's a general enough explanation of how I got it working in my project where I just used basic C++ to build the engine. You're using Box2D so it should be much easier to check if a body is asleep using b2Body::isAwake() function.