[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
postgresql test
From: |
nonotats |
Subject: |
postgresql test |
Date: |
Tue, 17 Jan 2006 17:41:25 +0900 |
Hi, every one.
As I need to watch PostgreSQL on my server, I wrote a protocol test,
using libpq library. It works as I expected. PGSQL test is something
like this:
int check_pgsql(Socket_T s) {
const char *conninfo;
PGconn *conn;
char connstat;
ASSERT(s);
conninfo = "dbname=statdb port=5432";
conn = PQconnectdb(conninfo);
connstat = PQstatus(conn);
if(connstat != CONNECTION_OK) {
...
But a couple of big questions are left unresolved;
1. The main goal was to do a "graceful" test in the postgres point of
view. With monit's general purpouse test, postgres log gets filled up
with "incomplete startup packet" every poll interval, say, every two
minutes. HOW can I prevent monit from doing do_connect() ONLY in case
proto be PGSQL, as check_pgsql() does its own peculiar test independent
of raw connection made by monit ? I tried modifying socket.c:
socket_create_t() like;
if(port == 5432){
<make a dummy NEW Socket_T S object and return it to caller routine
before doing "if((s= create_socket(...>
but in vain.
2. As you can see, my poor check_pgsql() code has dbname and port hard-
coded. How can I build string variable conninfo in accordance with the
setting in monitrc? I am a newbie in C programming.
These struggles would be unncessary only if I knew how to "speak" to
postgres directly...
Best regards.
- postgresql test,
nonotats <=