Local plugin windows batch with output to file

Hi,

On windows I’m trying to run a local script that outputs the result into a file. It checks the SQL server errorlog for specific errors and outputs it to a file.

The batch file is something like this

@ECHO off
:instance1
SET QRY1=sqlcmd -i C:\ProgramData\checkmk\agent\tmp\read_sqlerrorlog.sql -o C:\ProgramData\checkmk\agent\tmp\errors_sqlerrorlog.log -h -1 -W
for /F “usebackq delims=” %%i in (%QRY1%) do call :outputline %%i

:outputline
@echo 0 Check_SQL_errorlog Checks the SQL error log and outputs to xxxx

:eof

I’ve also tried plain sqlcmd


@echo off
sqlcmd -i C:\ProgramData\checkmk\agent\tmp\read_sqlerrorlog.sql -o C:\ProgramData\checkmk\agent\tmp\errors_sqlerrorlog.log -h -1 -W
echo 0 Check_SQL_errorlog Checks the SQL error log and outputs to xxxx

Both files can execute the sql-script and echo into Check with a name of the service so I know there is a service doing that but with no metrics.
What I plan to do is to use the logwatch plugin to capture the entries in the file here called “errors_sqlerrorlog.log”.

But the thing that doesn’t work is that the batch file when run with checkmk agent does not create the file.

Is possible to have a batch file running as a local check that also outputs the results to a file?

Any help in any direction would be appreciated.

/ricardo

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.