How can you tell if an onion is rotten?

Soft or firm. Onions can keep a long time in a cool, dark space. An onion is usually rotten if it is soft/mushy. If it is firm, it should be ok...Even if it has started growing a greenish plant from the middle. Just cut that part out.
Odor, appearance. Fresh onions are firm and uniform in color. When they start to rot they will give off odor and develop discolored soft spots. As this advances they will start to leak brownish, sticky fluid. This is not a health risk but is distasteful and useless for eating and cooking.