[Nagios-db-checkins] nagios-db/neb/postgres inserter.c,1.7,1.8
Status: Beta
Brought to you by:
bench23
From: Bench <be...@us...> - 2005-03-11 01:08:50
|
Update of /cvsroot/nagios-db/nagios-db/neb/postgres In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1824 Modified Files: inserter.c Log Message: let logging happen correctly when using sprintf(q,"%s",q) constructs Index: inserter.c =================================================================== RCS file: /cvsroot/nagios-db/nagios-db/neb/postgres/inserter.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- inserter.c 28 Jan 2005 00:27:16 -0000 1.7 +++ inserter.c 11 Mar 2005 01:08:39 -0000 1.8 @@ -135,8 +135,9 @@ res = PQexec(pgconn,"select empty_config()"); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(q,sizeof(q),"nagios-db: couldn't clear config info (%s)", PQresultErrorMessage(res)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't clear config info (%s)", PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } PQclear(res); @@ -162,8 +163,9 @@ res = PQexec(pgconn,q); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(q,sizeof(q),"nagios-db: couldn't configure host using '%s' (%s)", q, PQresultErrorMessage(res)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't configure host using '%s' (%s)", q, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } PQclear(res); @@ -190,8 +192,9 @@ res = PQexec(pgconn,q); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(q,sizeof(q),"nagios-db: couldn't configure hostgroup using '%s' (%s)", q, PQresultErrorMessage(res)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't configure hostgroup using '%s' (%s)", q, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } groupid = atol(PQgetvalue(res,0,0)); PQclear(res); @@ -206,8 +209,9 @@ res = PQexec(pgconn,q); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(q,sizeof(q),"nagios-db: couldn't configure hostgroup membership using '%s' (%s)", q, PQresultErrorMessage(res)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't configure hostgroup membership using '%s' (%s)", q, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } PQclear(res); } @@ -243,8 +247,9 @@ res = PQexec(pgconn,q); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(q,sizeof(q),"nagios-db: couldn't configure service using '%s' (%s)", q, PQresultErrorMessage(res)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't configure service using '%s' (%s)", q, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } PQclear(res); @@ -259,15 +264,17 @@ res = PQexec(pgconn,q); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(q,sizeof(q),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } else { if(atoi(PQgetvalue(res,0,0)) < 0) { - snprintf(q,sizeof(q),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } } PQclear(res); @@ -276,15 +283,17 @@ res = PQexec(pgconn,q); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(q,sizeof(q),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } else { if(atoi(PQgetvalue(res,0,0)) < 0) { - snprintf(q,sizeof(q),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } } PQclear(res); @@ -293,15 +302,17 @@ res = PQexec(pgconn,q); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(q,sizeof(q),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } else { if(atoi(PQgetvalue(res,0,0)) < 0) { - snprintf(q,sizeof(q),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } } PQclear(res); @@ -310,15 +321,17 @@ res = PQexec(pgconn,q); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(q,sizeof(q),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } else { if(atoi(PQgetvalue(res,0,0)) < 0) { - snprintf(q,sizeof(q),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } } PQclear(res); @@ -327,15 +340,17 @@ res = PQexec(pgconn,q); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(q,sizeof(q),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } else { if(atoi(PQgetvalue(res,0,0)) < 0) { - snprintf(q,sizeof(q),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } } PQclear(res); @@ -344,15 +359,17 @@ res = PQexec(pgconn,q); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(q,sizeof(q),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } else { if(atoi(PQgetvalue(res,0,0)) < 0) { - snprintf(q,sizeof(q),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } } PQclear(res); @@ -361,15 +378,17 @@ res = PQexec(pgconn,q); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(q,sizeof(q),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", q, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } else { if(atoi(PQgetvalue(res,0,0)) < 0) { - snprintf(q,sizeof(q),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); - write_to_all_logs(q,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back %s", q, PQgetvalue(res,0,0)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } } PQclear(res); @@ -436,15 +455,17 @@ res = PQexec(pgconn,temp_buffer); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(temp_buffer,sizeof(temp_buffer),"nagios-db: couldn't execute '%s' (%s)", temp_buffer, PQresultErrorMessage(res)); - write_to_all_logs(temp_buffer,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", temp_buffer, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } else { if(atoi(PQgetvalue(res,0,0)) < 0) { - snprintf(temp_buffer,sizeof(temp_buffer),"nagios-db: executed '%s' and got back %s", temp_buffer, PQgetvalue(res,0,0)); - write_to_all_logs(temp_buffer,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back %s", temp_buffer, PQgetvalue(res,0,0)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } } @@ -579,15 +600,17 @@ res = PQexec(pgconn,temp_buffer); if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { - snprintf(temp_buffer,sizeof(temp_buffer),"nagios-db: couldn't execute '%s' (%s)", temp_buffer, PQresultErrorMessage(res)); - write_to_all_logs(temp_buffer,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", temp_buffer, PQresultErrorMessage(res)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } else { if(atoi(PQgetvalue(res,0,0)) < 0) { - snprintf(temp_buffer,sizeof(temp_buffer),"nagios-db: executed '%s' and got back %s", temp_buffer, PQgetvalue(res,0,0)); - write_to_all_logs(temp_buffer,NSLOG_INFO_MESSAGE); + char str[2048]; + snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back %s", temp_buffer, PQgetvalue(res,0,0)); + write_to_all_logs(str,NSLOG_INFO_MESSAGE); } } |