Some animals (like the dolphin and even the lion) sleep only half their brain at a time. Giraffes only have deep sleep for a total of 5 minutes in a 24hr period!
I am not really sure how snakes do it, but I can guess that if they are not moving at all, and their breathing is much slower then usual, they are probably sleeping.