Abu Huraira (may Allah be pleased with him) reports that the Messenger of Allah (peace and blessings be upon him) said: If someone were to sit on a burning ember that burns his clothes and reaches his skin, it would still be better than sitting on a grave (i.e., keeping vigil there).
Sayyiduna Abu Marthad Ghanawi (may Allah be pleased with him) narrates that the Messenger of Allah (peace and blessings be upon him) said: Do not sit on the grave and do not pray towards it.