I would like send some notifications in an external database. what solution can you offer me ?

i tried to create batch file with custom notification, but it doesn't work.

Can you help me ?

Thanks by avance,

Best Regards


Article Comments

Hi

What for a database is it (MSSQL, MySQL)?


Nov, 2014 - Permalink

Hi,

Can you post an example of your batch file here?


Nov, 2014 - Permalink

Hello,

Thanks for your answer, the database is (MSSQL).

My script just contain "echo" and this parameters ("[%sitename]" "%device" "%name" "%status" "%down" "(%message)")

Thanks for your help


Nov, 2014 - Permalink

I would suggest having a look at the sqlcmd Utility.

Calling this from your batch file, you should be able to insert records into your database.


Nov, 2014 - Permalink

Thanks for your answer, but how i send data from PRTG ?

Thanks by advance,


Nov, 2014 - Permalink

Hello,

use notifications.

with the notifications you can not only send mail or short messages but you can also trigger to execute scripts or batch files.

see

https://www.paessler.com/manuals/prtg/notifications.htm


Nov, 2014 - Permalink

Hello,

Thanks for your answer, but what data must contain my batch script ?

This is my script :

@echo off echo sitename:%1 ; device:%2 ; name:%3 ; status:%4 ; down:%5 ; message:%6 > c:\temp\test_export.txt

The file is create, but data are approximate.

Thanks by advance,

Best regards


Nov, 2014 - Permalink

Your batch file will have to look something like this:

@Echo off
sqlcmd -S [YourSqlServerName] -U [SqlUsername] -P [SqlPassword] -d [Database] -x -Q "INSERT INTO tblError VALUES %1, %2, %3"

Please note that sqlcmd switches are case sensitive. The placeholders between the square brackets must be replaced by their real values, removing the brackets.

All switches are documented at http://msdn.microsoft.com/en-us/library/ms162773.aspx


Nov, 2014 - Permalink

Thanks you very much!!!!!! I try this and i post the result as soon as possible.


Nov, 2014 - Permalink

Hello, It does not works. If i execute a simple script (example echo test >c:\test.txt), it's ok but if i try to execute the script with sqlcmd, it's not work. The script is ok if i lauch manually.

At this link (https://helpdesk.paessler.com/en/support/solutions/articles/76000065185-how-can-i-execute-a-batch-file-as-notification) i found this: The notification script cannot open any windowed application and cannot be a windowed application itself. This is not possible because PRTG runs as a service.

sqlcmd open a window. I tried to lauch the script with another call script but it's the same thing.

Any other idea ?

Thanks by advance,

Best regards


Nov, 2014 - Permalink

Hi,

As far a I have tested this, sqlcmd with the parameters as in the example does NOT open a window.

Can you please post your COMPLETE script here.


Nov, 2014 - Permalink

Hello,

This is my script :

@echo off
sqlcmd -S servername\instance -U userbdd -P password -d database -x -q "INSERT INTO tablename ([column1], [column2], [column3], [column4], [column5], [column6]) VALUES (6 ,7 ,8, 9, 10, 11)" -o c:\temp\result_batch.txt

Thanks for your help.


Nov, 2014 - Permalink

Hi,

You need to replace the -q with -Q (capital) as in the example above.

   -q "cmdline query" 
   -Q "cmdline query" (and exit)

Please take a close look at the parameters at http://msdn.microsoft.com/en-us/library/ms162773.aspx


Nov, 2014 - Permalink

Hi,

Thanks for your precision, but it's the same thing PRTG doesn't execute the script. It's ok when i lauch it manually and when i lauch a simple script....

Thanks you for your help.


Nov, 2014 - Permalink

Hi,

There seems to be a problem with executing scripts from the notification system in the current PRTG version.

From what I understood, they are working hard in solving this.


Nov, 2014 - Permalink

Thanks for your help, if i find a solution, i will post here. Hoping, they find a solution before.

Best regards,


Nov, 2014 - Permalink