A WireGuard interface comes up even when the other side is unreachable. There is no connected state like other VPNs show. The handshake time is the closest thing, so that is what I’d look at.
sudo wg show wg0
For every peer you get the endpoint, the allowed IPs, the latest handshake and how much data went each way. If the handshake line is missing, the peers have never talked. If it says a few minutes ago, the tunnel is up; WireGuard renews it about every two minutes while there is traffic.
For a script, ask for just that field. It prints the peer’s public key and a Unix timestamp, with 0 for never:
sudo wg show wg0 latest-handshakes
transfer gives the byte counters the same way, and dump prints everything tab separated for parsing.
If there is no handshake, I’d check in this order: is the endpoint address and port right, is the UDP port open on the other side’s firewall and router, and do the keys match. A swapped public key fails silently, so compare the public key in one config with wg pubkey output from the other side’s private key.
A handshake that is hours old is not always a problem. Without traffic, WireGuard stays quiet.
Further reading: wg(8) man page, WireGuard quick start
Going deeper: Why a Tailscale device vanishes after 180 days, and how to stop it