asterisk -rx ‘sip show peers’
monitors all sip devices (it does not monitor extensions).
grep is the Unix pattern matching command line tool. XXXX is presumably a device name that appears in the output of the first command, doesn’t contain characters that are special to grep, and is not spoofed by any other output from the first command.
grep can use regular expression patterns that can match multiple device names, or you can omit it completely and just look at the full output.
Note, as this involves launching three programs in at least two processes, it is quite expensive. watch will mean this happens every two seconds.
I’d strongly recommend running an interactive asterisk console and just trying commands to see what output they produced. You can use help for a list, and help XXX YYY for comands beginning XXX YYY, etc., for descriptions of the commands.