Is there a way to query online status from command line

Seems you want to call an API instead
See