Show
Ignore:
Timestamp:
05/22/08 18:51:17 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1211482277 +0000
git-parent:

[6b0b6dae8b7aab690a7936f7501acf45b87d3a6b]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1211482277 +0000
Message:

closes #9

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/postgres.c

    rcce9b78 r3263a9a  
    5858  current.duration = duration.tv_sec * 1000 + duration.tv_usec / 1000; 
    5959  current.available = NP_UNAVAILABLE; 
     60  current.state = NP_BAD; 
    6061  if(ci->error) current.status = ci->error; 
    6162  else if(ci->timed_out) current.status = "timeout"; 
    6263  else if(ci->rv == PGRES_COMMAND_OK) { 
    6364    current.available = NP_AVAILABLE; 
     65    current.state = NP_GOOD; 
    6466    current.status = "command ok"; 
    6567  } 
    6668  else if(ci->rv == PGRES_TUPLES_OK) { 
    6769    current.available = NP_AVAILABLE; 
     70    current.state = NP_GOOD; 
    6871    current.status = "tuples ok"; 
    6972  } 
     
    7679    ncols = PQnfields(ci->result); 
    7780    for (i=0; i<nrows; i++) { 
    78       if(j<2) continue; 
    79       if(!PQgetisnull(ci->result, i, 0)) continue; 
     81      noitL(nldeb, "postgres: row %d [%d cols]:\n", i, ncols); 
     82      if(ncols<2) continue; 
     83      if(PQgetisnull(ci->result, i, 0)) continue; 
    8084      for (j=1; j<ncols; j++) { 
    8185        Oid coltype; 
     
    8993                 PQgetvalue(ci->result, i, 0), PQfname(ci->result, j)); 
    9094        coltype = PQftype(ci->result, j); 
     95        noitL(nldeb, "postgres:   col %d (%s) type %d:\n", j, mname, coltype); 
    9196        switch(coltype) { 
    9297          case BOOLOID: 
     
    119124            if(PQgetisnull(ci->result, i, j)) sv = NULL; 
    120125            else sv = PQgetvalue(ci->result, i, j); 
    121             noit_stats_set_metric(&current, mname, METRIC_STRING, sv); 
     126            noit_stats_set_metric(&current, mname, METRIC_GUESS, sv); 
    122127            break; 
    123128        } 
     
    161166      noit_check_interpolate(dsn_buff, sizeof(dsn_buff), dsn, 
    162167                             &ci->attrs, check->config); 
    163       ci->conn = PQconnectdb(dsn); 
     168      ci->conn = PQconnectdb(dsn_buff); 
    164169      if(!ci->conn) AVAIL_BAIL("PQconnectdb failed"); 
    165170      if(PQstatus(ci->conn) != CONNECTION_OK) 
     
    169174      noit_check_interpolate(sql_buff, sizeof(sql_buff), sql, 
    170175                             &ci->attrs, check->config); 
    171       ci->result = PQexec(ci->conn, sql); 
     176      ci->result = PQexec(ci->conn, sql_buff); 
    172177      if(!ci->result) AVAIL_BAIL("PQexec failed"); 
    173178      ci->rv = PQresultStatus(ci->result);