ODBC Logging to SQL Server

General chat about HostMonitor (all messages posted before March 07, 2003 available here).
Locked
cbraatz
Posts: 4
Joined: Wed Apr 03, 2002 6:00 pm
Location: Buena Park, CA
Contact:

Post by cbraatz »

What are the details of the database needed to log all activity to sql. Do you have a db for us to load. How about the specs so I can create my own. Thanks Alex!
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

cbraatz,

Format of database table is entirely up to you. You can specify SQL query to insert record to the log. So, format of table must be corresponding to your SQL query.

Just for example you can create table (hmlog) with 1 date field (named date1), and 4 string fields (named: date1, time1, testname, status, reply). To insert records use SQL query like:
Insert into hmlog (date1, time1, testname, status, reply) VALUES (%Date%, '%Time%', '%TestName%', '%Status%', '%Reply%')

Regards
Alex
simonl
Posts: 49
Joined: Wed Apr 03, 2002 6:00 pm
Contact:

Post by simonl »

Hi Alex, I try to specify more fields to my sql query, but it only except that field which you provide on example. I want to save in table all field from log. It's possible or not?.
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Yes, its possible, but its depend on your database, table, query.
You can try to use "Test" button on "Advanced Logs" page in the Options dialog. When some error occurs, HostMonitor will display error message from your ODBC driver. So, you will know where is mistake.

Regards
Alex
cbraatz
Posts: 4
Joined: Wed Apr 03, 2002 6:00 pm
Location: Buena Park, CA
Contact:

Post by cbraatz »

When logging to sql server the date amd time field show up with the date as 1900-01-01. The time however is correct.
Thanks for your fast responses.
Craig
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

As I understand you have one field in database which represented date&time?
What macro variable for this field do you use in SQL query?
%DateTime%? Or %Time%? Must be %DateTime%

Regards
Alex
cbraatz
Posts: 4
Joined: Wed Apr 03, 2002 6:00 pm
Location: Buena Park, CA
Contact:

Post by cbraatz »

Thanks Alex. I used the following for the sql query:
Insert into hmlog (time, testname, status, reply) VALUES ('%DateTime%', '%TestName%', '%Status%', '%Reply%')
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

By default HostMonitor uses your system date format. Perhaps your SQL server (or ODBC driver) doesn't like this format?
I see two ways to test this:
- change type of "time" field to string.
- set "Use fixed date&time formats" option (on Miscellaneous page in the Options dialog) and specify date format supported by your SQL server.

Regards
Alex
simonl
Posts: 49
Joined: Wed Apr 03, 2002 6:00 pm
Contact:

Post by simonl »

Alex

I understand that output from Host Monitor to odbc database connections depend of which table structure I specify in query, but I have to know how I can specify field name from Host Monitor log for example: %date%, %testname%, %status%, %reply% are working find but when I use %lasttesttime% or %comment% or all other columns from log file I got zero output to the my table. Please, provide the right syntax for all columns name from Host Monitor log file.
Thank you. I
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Old macro variables (supported by HostMonitor 1.xx and 3xx): http://www.ks-soft.net/hostmon.eng/actions.htm#macro
New macro variables (version 3.xx only): http://www.ks-soft.net/hostmon.eng/news.htm#NewCol

But if the program does not insert any records into your table, it means you SQL server doesn't like SQL query. Use "Test" button (beside SQL query field in the Options dialog) to see answer from SQL server.
Also make sure you use ('') for text fields like '%TaskComment%', '%Status%'.

Regards
Alex
simonl
Posts: 49
Joined: Wed Apr 03, 2002 6:00 pm
Contact:

Post by simonl »

Alex,
Thank you very much.:wink:
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

You are welcome
Locked