On social networks such as Facebook, your friends and colleagues typically provide you with a vast amount of information about what they’re doing and how they’re feeling. You should use this information to be a better friend.
When a friend makes some sort of comment or status update that makes you wonder “What’s wrong?”, “What happened?” or similar questions—don’t ask them that generic question. Take a quick look at their profile and check what they’ve been doing lately: have they been to a wedding? Did a relative fall ill or die? Did they just break up with someone? Did they just get laid off, or get a new job? Spend just a few minutes—literally!—checking in on your friend, use the resources that they have made available to you, and then use what you’ve learned to help your friend. If they’ve just broken up with someone, what’s better for them to hear: “What happened?” or “Hey, I heard you got laid off. Let me know if you want to talk or hang out anytime, my schedule is clear for you and dinner is on me.”? React to the event that happened; don’t just react because an event happened.
Look at this sort of research as the same way you would handle an in-person situation with a friend or co-worker: if one of your co-workers comes into the office and they seem excessively frustrated or angry, do you immediately confront them or ask them what’s wrong? Likely not; you’re more likely to talk to another co-worker first to see if you can find out what’s up. Sometimes, it’s better to learn things indirectly so you can approach a situation more delicately or give someone additional time and space. This works the same online as it does off.
If they didn’t say anything recently that makes it obvious why they’re in such a mood, then go ahead and ask them. But bear in mind that if they haven’t broadcasted the reason before, they might not want to broadcast the reason now, so a private message or email (not an instant message) is probably the best way to ask.
If you care about your friends, it’s worth spending a few more minutes to make sure that they are actually cared for, and not just bombarded with already-answered questions.