Input source: logging from MSSQL table

This support forum board is for support questions relating to Nagios Log Server, our solution for managing and monitoring critical log data.
Locked
ghostcat
Posts: 9
Joined: Mon Nov 24, 2014 2:54 pm

Input source: logging from MSSQL table

Post by ghostcat »

My Goal is to retrieve logging that is written to a table within an MS SQL database.

I'm asking here as i have not been able to set this up or find any info online, After some time spent researching and using some good old fashioned trial and error I believe the options are as follows

1. "MSSQL logs will automatically be sent through Windows event logs. Follow the configuration in the Windows Source Setup above and verify you are receiving logs."

A. Upon testing this does not include any sql table data however i assume this is working as desired as to not include any content from the tables and is only designed to monitor sql specific logging.

2. Setup Im_dbi through nxlog to interface with the sql server and read the data

A. Because MSSQL is on windows nxlog is also installed under windows, While attempting to use im_dbi i have found that it has not been implemented under the windows version of the nxlog install at this time.

Any help is greatly appreciated.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Input source: logging from MSSQL table

Post by tmcdonald »

Hmmm, this is a tough one. Depending on your coding skills you might be able to create a simple cron that queries your MSSQL box every minute or so and passes that info off through syslog.
Former Nagios employee
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Input source: logging from MSSQL table

Post by eloyd »

Trevor's idea is mine, as well, but I want to be clear about something:

You're not asking to grab logs that show what the database is doing, you want to grab data that's in the database, right?

If that's the case, then your best bet is a */X * * * * entry in crontab (X = number of minutes between runs, like 5) that grabs the appropriate rows and then passes them to syslog as Trevor said. I know of no other way to do what you are looking to do, assuming I got what you're looking to do correct.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Input source: logging from MSSQL table

Post by tmcdonald »

If there is an option to log all MSSQL inserts to file that might work as well, however that would essentially double the amount of data being written. I do not know if such a feature exists in MSSQL.
Former Nagios employee
ghostcat
Posts: 9
Joined: Mon Nov 24, 2014 2:54 pm

Re: Input source: logging from MSSQL table

Post by ghostcat »

Thanks for the thoughts on the matter,

It appears nxlog under Linux has some support for input via an sql source using the im_dbi module, However nxlog does not have support this module under windows.
Luckily i'm primarily a Linux admin so challenge accepted.

I am now running into "ERROR im_dbi couldn't initialize libdbi driver 'mysql'" which is leading me to dependencies not being in place, This is a nxlog based issue but I'll post back here if i have any further success to help anyone looking for a solution ike this in future.

eloyd: Exactly, I'm looking to gather logging that is written to a table on the sql db server, All im trying to do is systematically query that table gather any new entries in the table since last query.

Thanks All,
GC

Update: I've run into some issues under linux in getting the libdbi to run and query the SQL server link to my post on the nxlog forums is https://nxlog.co/question/559/imdbi-ms-sql - hope this helps
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Input source: logging from MSSQL table

Post by sreinhardt »

This is a nxlog based issue but I'll post back here if i have any further success to help anyone looking for a solution ike this in future.
Please do! We'd love to see what needs to be done, and who knows maybe we can help along the way.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked