I'm running a watch
on a command to monitor the number of open connections for a service we're diagnosing. I need to keep an eye on it while doing other work, to help other developers identify when the service is acting up.
The result of the watch is a number between 1 and 5000. I'd like to show the number as green when it's below 500, yellow when its between 501 and 4000, and red for above 4000.
Is there a command which can set the color easily based on the value of my command?
watch -n 1 ps aux
-- A poor man's process monitor, for example (executeps aux
to list processes every1
second and print the results).