I'm currently debugging an issue where I see a large number of threads in my application hanging on to a database connection even though they are asleep, often the threads sleep for a significant length of time (10-300s) (they're sensor reading/normality checking threads; that's not important)

I wanted to know if there's a decent way to graph something like:

watch "echo select count(*) from pg_stat_activity where procpid <> pg_backend_pid(); | psql"

and have it shown in the CLI or as an image that I can simply open, or write the image at the end of the run?

Surely there's a unix tool for histograms over time using the CLI to draw it (curses)?


I am not sure about a curses based solution back for graphing arbitrary data gnuplot can be of help. The relevant URL http://www.gnuplot.info/ . It is quite complex but for basic things the documentation should be more than enough.


gnuplot is one option for this, but it's a bit awkward if you want a continuous feed of data. This related question suggests that you could use eplot for more convenient terminal output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.