Группа :: Мониторинг
Пакет: xymon
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: xymon_trunk.old_sqlite.patch
Скачать
Скачать
--- xymonnet/netsql.c.old_sqlite 2012-08-01 16:07:53.000000000 -0700
+++ xymonnet/netsql.c 2012-08-02 14:54:51.000000000 -0700
@@ -52,10 +52,16 @@
sqlfn = (char *)malloc(strlen(xgetenv("XYMONTMP")) + strlen("/xymon.sqlite3") + 1);
sprintf(sqlfn, "%s/xymon.sqlite3", xgetenv("XYMONTMP"));
+#ifdef HAVE_SQLITE3_OPEN_V2
dbres = sqlite3_open_v2(sqlfn, &xymonsqldb, SQLITE_OPEN_READWRITE, NULL);
+#else
+ dbres = sqlite3_open(sqlfn, &xymonsqldb);
+#endif
if (dbres != SQLITE_OK) {
/* Try creating the database - in that case, we must also create the tables */
+#ifdef HAVE_SQLITE3_OPEN_V2
dbres = sqlite3_open_v2(sqlfn, &xymonsqldb, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
+#endif
if (dbres == SQLITE_OK) {
char *err = NULL;
dbres = sqlite3_exec(xymonsqldb, "CREATE TABLE hostip (hostname varchar(200) unique, ip4 varchar(15), upd4time int, ip6 varchar(40), upd6time int)", NULL, NULL, &err);
@@ -157,7 +163,11 @@
int dbres;
if (!dns_ip4update_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "update hostip set ip4=?,upd4time=strftime('%s','now') where hostname=LOWER(?)", -1, &dns_ip4update_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "update hostip set ip4=?,upd4time=strftime('%s','now') where hostname=LOWER(?)", -1, &dns_ip4update_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("ip4update prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return;
@@ -165,7 +175,11 @@
}
if (!dns_ip6update_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "update hostip set ip6=?,upd6time=strftime('%s','now') where hostname=LOWER(?)", -1, &dns_ip6update_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "update hostip set ip6=?,upd6time=strftime('%s','now') where hostname=LOWER(?)", -1, &dns_ip6update_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("ip6update prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return;
@@ -195,7 +209,11 @@
int dbres;
if (!dns_ip4query_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "select ip4,upd4time from hostip where hostname=LOWER(?)", -1, &dns_ip4query_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "select ip4,upd4time from hostip where hostname=LOWER(?)", -1, &dns_ip4query_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("ip4query prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return 1;
@@ -203,7 +221,11 @@
}
if (!dns_ip6query_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "select ip6,upd6time from hostip where hostname=LOWER(?)", -1, &dns_ip6query_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "select ip6,upd6time from hostip where hostname=LOWER(?)", -1, &dns_ip6query_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("ip6query prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return 1;
@@ -241,7 +263,11 @@
int dbres;
if (!dns_addrecord_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "insert into hostip(hostname,ip4,ip6,upd4time,upd6time) values (LOWER(?),'','',0,0)", -1, &dns_addrecord_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "insert into hostip(hostname,ip4,ip6,upd4time,upd6time) values (LOWER(?),'','',0,0)", -1, &dns_addrecord_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("addrecord prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return 1;
@@ -292,7 +317,11 @@
int dbres;
if (!nettest_query_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "select valid from testtimes where hostname=LOWER(?) and testspec=? and destination=?", -1, &nettest_query_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "select valid from testtimes where hostname=LOWER(?) and testspec=? and destination=?", -1, &nettest_query_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("nettest_query prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return;
@@ -300,7 +329,11 @@
}
if (!nettest_updaterecord_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "update testtimes set location=?,testtype=?,sourceip=?,timeout=?,interval=?,valid=1 where hostname=LOWER(?) and testspec=? and destination=?", -1, &nettest_updaterecord_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "update testtimes set location=?,testtype=?,sourceip=?,timeout=?,interval=?,valid=1 where hostname=LOWER(?) and testspec=? and destination=?", -1, &nettest_updaterecord_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("nettest_updaterecord prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return;
@@ -308,7 +341,11 @@
}
if (!nettest_addrecord_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "insert into testtimes(hostname,testspec,location,destination,testtype,sourceip,timeout,interval,timestamp,valid) values (LOWER(?),?,?,?,?,?,?,?,0,1)", -1, &nettest_addrecord_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "insert into testtimes(hostname,testspec,location,destination,testtype,sourceip,timeout,interval,timestamp,valid) values (LOWER(?),?,?,?,?,?,?,?,0,1)", -1, &nettest_addrecord_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("nettest_addrecord prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return;
@@ -364,7 +401,11 @@
time_t now = getcurrenttime(NULL);
if (!nettest_due_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "select hostname,testspec,destination,testtype,sourceip,timeout,interval from testtimes where location=LOWER(?) and (timestamp+interval)<?", -1, &nettest_due_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "select hostname,testspec,destination,testtype,sourceip,timeout,interval from testtimes where location=LOWER(?) and (timestamp+interval)<?", -1, &nettest_due_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("nettest_due prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return 0;
@@ -405,7 +446,11 @@
int dbres;
if (!nettest_forcetest_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "update testtimes set timestamp=0 where hostname=LOWER(?)", -1, &nettest_forcetest_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "update testtimes set timestamp=0 where hostname=LOWER(?)", -1, &nettest_forcetest_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("nettest_forcetest prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return;
@@ -424,7 +469,11 @@
int dbres;
if (!nettest_timestamp_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "update testtimes set timestamp=strftime('%s','now') where hostname=LOWER(?) and testspec=? and destination=?", -1, &nettest_timestamp_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "update testtimes set timestamp=strftime('%s','now') where hostname=LOWER(?) and testspec=? and destination=?", -1, &nettest_timestamp_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("nettest_timestamp prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return;
@@ -445,7 +494,11 @@
int dbres, result;
if (!nettest_secstonext_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "select distinct timestamp+interval-strftime('%s','now') from testtimes order by timestamp+interval limit 1", -1, &nettest_secstonext_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "select distinct timestamp+interval-strftime('%s','now') from testtimes order by timestamp+interval limit 1", -1, &nettest_secstonext_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("nettest_secstonext prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return 60;
@@ -487,7 +540,11 @@
int dbres;
if (!netmodule_additem_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "insert into moduletests(moduleid,location,hostname,destinationip,testspec,extras) values (LOWER(?),LOWER(?),LOWER(?),?,?,?)", -1, &netmodule_additem_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "insert into moduletests(moduleid,location,hostname,destinationip,testspec,extras) values (LOWER(?),LOWER(?),LOWER(?),?,?,?)", -1, &netmodule_additem_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("nettest_netmodule_additem prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return;
@@ -514,7 +571,11 @@
int dbres, result = 0;
if (!netmodule_due_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "select hostname,destinationip,testspec,extras from moduletests where moduleid=LOWER(?) and location=LOWER(?) limit ?", -1, &netmodule_due_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "select hostname,destinationip,testspec,extras from moduletests where moduleid=LOWER(?) and location=LOWER(?) limit ?", -1, &netmodule_due_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("netmodule_due prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return 0;
@@ -522,7 +583,11 @@
}
if (!netmodule_purge_sql) {
+#ifdef HAVE_SQLITE3_PREPARE_V2
dbres = sqlite3_prepare_v2(xymonsqldb, "delete from moduletests where moduleid=LOWER(?) and location=LOWER(?) and hostname=LOWER(?) and destinationip=? and testspec=?", -1, &netmodule_purge_sql, NULL);
+#else
+ dbres = sqlite3_prepare(xymonsqldb, "delete from moduletests where moduleid=LOWER(?) and location=LOWER(?) and hostname=LOWER(?) and destinationip=? and testspec=?", -1, &netmodule_purge_sql, NULL);
+#endif
if (dbres != SQLITE_OK) {
errprintf("netmodule_due prep failed: %s\n", sqlite3_errmsg(xymonsqldb));
return 0;