If by "monitoring" you mean simply asking whether the server is up, I just use "ps" for this task like this:
Code:
ps ax | grep postgres | grep -v grep
I wrote a little script that runs from cron every fifteen minutes and checks to see if any of a set of programs is not running, i.e., where the command above returns an empty string. The script then tries to restart the program with the "service" command and sends an email notice to me if it fails.
Now if, by monitoring, you mean checking to see whether the server is functioning properly, perhaps the best test would be a script that ran some common queries against the databases and made sure they returned the correct answers. For this you'd need to write a script to invoke the "psql" client (for PostgreSQL) with a set of test queries.
This sounds like the kind of goof-ball request from management who throw out a word like "monitoring" as if there is some well-defined method for this task. Ask them what they mean specifically by monitoring before you invest much time in this.
Bookmarks