Logging to Database

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
zzzthump
Posts: 5
Joined: Thu Mar 15, 2007 1:13 am

Logging to Database

Post by zzzthump »

Hi

We are using Host Monitor to log to text files as default. Problem is some of these are getting rather large and impossible to analyse due to the time.

Ive seen other completing software....****Winds for example that uses an MSDE database.

Does anyone know how to make this software log to a DB and not to the textfiles by default?

I was thinking along the lines of SQLExpress since it replaces MSDE now?

Thanks

Michael
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Quote from the manual
Common log is a file or database that is shared by all test items defined in the working test list. All events that are subject to logging (according to test's configuration) get recorded in the common log.
You may specify Primary and Backup common logs. For each log you may choose defferent log type (ODBC or File), file format (HTML, Text or DBF) and logging mode (Full, Brief, Midnight or Reply). E.g. you may use Full logging mode for primary ODBC log managed by your SQL server and use Brief logging mode for backup HTML log stored on local hard drive.
HostMonitor can switch from primary to backup log when necessary or use both logs at the same time.

...

ODBC
Starting with version 3.0, HostMonitor can write log information into database using any ODBC driver installed on your system (e.g Oracle, MS SQL or MySQL database). It’s a very flexible solution - you may define table structure and choose type of the fields to fit your needs. However you must be sure that ODBC driver (provided by 3rd party) works reliable and will not cause HostMonitor to crash.
E.g. Microsoft dBase Driver v 4.00 causes resource leakage; Oracle driver v8 may crash application.

...

If you have chosen “ODBC” log type, then you should specify data source and SQL query for the logging.

ODBC data source
Choose one of ODBC data sources available on your system.
Note: Windows provides system data source names and user data source names (System DSN and User DSN). User data sources are local to a user and accessible only by the specified user.
If you start HostMonitor as service, it will not be able to use User DSN. So, if you are planning to start HostMonitor as service and as regular application, select "System DSN" option (that is located on Misc page in the Options dialog) and choose system ODBC data source for the logging. In this case HostMonitor will work equally in both modes.

Login
Specify user identifier, if necessary

Password
Specify password, if necessary

Timeout
Specify the number of seconds to wait for a login request to complete. If value is 0, the timeout is disabled and a connection attempt will wait indefinitely.

SQL Query
Specify SQL query to logging test data. Format of the query is entirely up to you, use the macro variables to put in as much detail as you want. For instance, SQL command might look like this:
INSERT INTO HMLOG (EVENTTIME, TESTNAME, STATUS, REPLY, TESTID, TESTMETHOD) VALUES (‘%DateTime%', '%TestName%', '%Status%', ‘%Reply%', %TestID%, ‘%TestMethod%’)
Of course an appropriate database table has to be created before you start using the ODBC logging.
Note #1: Maximum length of the query: 4096 symbols.
Regards
Alex
zzzthump
Posts: 5
Joined: Thu Mar 15, 2007 1:13 am

Post by zzzthump »

Thanks Alex

I have already read the manual before I posted.....but im a little lost in the DB side of things...ie whats the story with creating the table structure in the first place.

I was hoping someone else may have done this to help me :)

Thanks
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

zzzthump wrote:I have already read the manual before I posted.....but im a little lost in the DB side of things...ie whats the story with creating the table structure in the first place.
I was hoping someone else may have done this to help me :)
Creating table is a pretty sipmle thing, however, it depends on SQL server are you going to use. For instance, you may use following structure for the MS SQL Server:

Code: Select all

CREATE TABLE HMLOG (
  EventTime datetime,
  TestName varchar (100),
  Status varchar (24),
  Reply varchar(100),
  TestID int,
  TestMethod varchar(100)
);
For MySQL create script should be a bit different.

Of course it is an simplified example, so you should use datatypes and field length appropriate to your Hostmonitor's configuration.

You may use following Query to record log into that table:

Code: Select all

INSERT INTO HMLOG (EVENTTIME, TESTNAME, STATUS, REPLY, TESTID, TESTMETHOD) VALUES (‘%DateTime%', '%TestName%', '%Status%', ‘%Reply%', %TestID%, ‘%TestMethod%’) 
HostMonitor offers many useful macro variables ( http://www.ks-soft.net/hostmon.eng/mfra ... .htm#macro ), so you may create additional fields in tale to store more information.
http://www.ks-soft.net/hostmon.eng/mfra ... tm#odbclog

Regards,
Max
Post Reply