Folks,
the way ntop handles DB is suboptimal: so bear in mind that in future
versions this code will be totally rewritten and (hopefully) moved out of
the ntop core.
Cheers, Luca
On Fri, 28 Jun 2002, Juan Ramon Duarte wrote:
>
> Burton,
>
> I'll try adding some debug info to see if the problem can be narrowed down
> to something more specific.
>
> Thanks for the ideas ...
>
> JRD
>
>
>
> On Fri, 28 Jun 2002, Burton M. Strauss III wrote:
>
> > Not really ... I've cleaned up the debug flags that are there and moved them
> > into ntop.h (I'm still working on the major routines, but I've backed off
> > until 2.1 ships), but I haven't touched sql. (When I get to sql/mysql, I
> > guess sqlSocket moves into myGlobals!)
> >
> > It's not hard to add... especially since I *know* you can code...
> >
> > Just create a SQL_DEBUG flag in ntop.h like the others
> > and then put #ifdef SQL_DEBUG / traceEvent() / #endif where it seems
> > important...
> >
> > What you need to look for is code in sql.c that looks like this:
> >
> > if(sqlSocket != -1) {
> > ...postgres stuff goes here...
> > }
> >
> > #ifdef HAVE_MYSQL
> > mySQLupdateHostNameInfo(numeric, symbolic);
> > #endif
> >
> > That's the separation between the -b (postgres) and -v (mySQL) options. For
> > each postgres routine, there is a matching routine in mySQL.
> >
> > Typically, I log entry/exit into routines, rc's from key statements... for
> > sql, you might add logging the generated sql statements, e.g.:
> >
> > sendto(sqlSocket, sqlBuf, strlen(sqlBuf), 0, (struct sockaddr *)&dest,
> > sizeof(dest));
> >
> > becomes:
> >
> > #ifdef SQL_DEBUG
> > traceEvent(TRACE_INFO, "SQLDEBUG: routine() exec sql %s\n", sqlBuf);
> > #endif
> > rc = sendto(sqlSocket, sqlBuf, strlen(sqlBuf), 0, (struct sockaddr
> > *)&dest, sizeof(dest));
> > if (rc != 0) {
> > traceEvent(TRACE_ERROR, "SQLERROR: rc=%d from routine() exec sql
> > %s\n", rc, sqlBuf);
> > #ifdef SQL_DEBUG
> > } else {
> > traceEvent(TRACE_ERROR, "SQLDEBUG: rc=0\n");
> > #endif
> > }
> >
> >
> >
> > -----Burton
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf
> > Of Juan Ramon Duarte
> > Sent: Friday, June 28, 2002 7:00 AM
> > To: [EMAIL PROTECTED]
> > Subject: RE: [Ntop-dev] Database (mysql) support in NTop for Windows
> >
> >
> >
> > Burton,
> >
> > Thanks for your reply.
> >
> > Are there any Debug flags that I can activate that would give us some
> > insight as to what is causing the problems?
> >
> > JRD
> >
> >
> >
> > On Fri, 28 Jun 2002, Burton Strauss wrote:
> >
> > > Actually one idea:
> > >
> > > INSERT INTO TCPsessions (Client, Server,
> > > ClientPort, ServerPort, DataSent, DataRcvd, FirstSeen, LastSeen)
> > > VALUES ('10.10.80.83', '10.10.1.181', '1248', '80', '0',
> > > '1078198272', '(null)', '(null)')
> > >
> > > Check the data types in the table - '1078198272' might be too large (32bit
> > ints??)
> > >
> > > Otherwise, not a clue... I'm guessing that the multi-threaded nature of a
> > DBMS will make a MinGW port unlikely!
> > >
> > > But, now you know why test pilots sit in ejection seats...
> > >
> > > ------Burton
> > >
> > >
> > > ---------- Original Message ----------------------------------
> > > From: Juan Ramon Duarte <[EMAIL PROTECTED]>
> > > Reply-To: [EMAIL PROTECTED]
> > > Date: Fri, 28 Jun 2002 11:46:05 +0100 (BST)
> > >
> > > >
> > > >Hi,
> > > >
> > > >I've managed to include mySQL support into a Windows compile of NTop.
> > > >But I have two problems:
> > > >
> > > >1. It crashes even more frequently (sometimes within 5 seconds of
> > > > starting) than without database support.
> > > > This is not very consistent but many times it crashes just after
> > > > this line in the console:
> > > >
> > > >
> > > > 28/Jun/2002 11:22:33 INSERT INTO TCPsessions (Client, Server,
> > > > ClientPort, ServerPort, DataSent, DataRcvd, FirstSeen, LastSeen)
> > > > VALUES ('10.10.80.83', '10.10.1.181', '1248', '80', '0',
> > > > '1078198272', '(null)', '(null)')
> > > >
> > > >
> > > >I can see that the Access database is being populated. All tables
> > > >except 'TCPSessions' now contain data. This seems consistent with
> > > >NTop crashing every time it tries to insert into TCPSessions.
> > > >
> > > >
> > > >I have only seen one error in the mySQLServer.pl console:
> > > >
> > > > INSERT INTO TCPsessions (Client, Server, ClientPort, ServerPort,
> > > > DataSent, DataRcvd, FirstSeen, LastSeen) VALUES ('10.10.80.83',
> > > > '10.10.1.181', '1248', '80', '0', '1078198272', '(null)', '(null)')
> > > > DBD::ODBC::db do failed: [Microsoft][ODBC Microsoft Access Driver]
> > > > Data type mismatch in criteria expression. (SQL-22005)(DBD:
> > > > st_execute/SQLExecute err=-1) at mysqlserver.pl line 61.
> > > >
> > > >Again, consistent in being related to 'TCPSessions'.
> > > >
> > > >
> > > >2. I would like to compile NTop using MinGW but haven't been able
> > > >for lack of the mysql libraries.
> > > >The closest I've come is by using the 'libmysqlclient MinGW port'
> > > >found at http://www.johnydog.cz/projects.php
> > > >
> > > >Any pointers?
> > > >
> > > >
> > > >
> > > >My current configuration is:
> > > >
> > > >- Win 2000
> > > >
> > > >- NTop compiled with VC++ 6.0
> > > >
> > > >- mySQL support added through compiling against include files
> > > > and the DLL provided in the mysql++ API package (downloaded
> > > > from www.mysql.com)
> > > >
> > > >- mySQLSever.pl, modified to connect via ODBC
> > > >
> > > >- ntop -> mySQLServer.pl -> ODBC -> ntop.mdb
> > > >
> > > >
> > > >Regards,
> > > >
> > > >JRD
> > > >
> > > >_______________________________________________
> > > >Ntop-dev mailing list
> > > >[EMAIL PROTECTED]
> > > >http://lists.ntop.org/mailman/listinfo/ntop-dev
> > > >
> > >
> > >
> > > __________________________________________________
> > > D O T E A S Y - "Join the web hosting revolution!"
> > > http://www.doteasy.com
> > > _______________________________________________
> > > Ntop-dev mailing list
> > > [EMAIL PROTECTED]
> > > http://lists.ntop.org/mailman/listinfo/ntop-dev
> > >
> >
> > _______________________________________________
> > Ntop-dev mailing list
> > [EMAIL PROTECTED]
> > http://lists.ntop.org/mailman/listinfo/ntop-dev
> >
>
> _______________________________________________
> Ntop-dev mailing list
> [EMAIL PROTECTED]
> http://lists.ntop.org/mailman/listinfo/ntop-dev
>
_______________________________________________
Ntop-dev mailing list
[EMAIL PROTECTED]
http://lists.ntop.org/mailman/listinfo/ntop-dev