What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Send notifications in database

Votes:

0

Your Vote:

Up

Down

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

custom-notification notification-delivery prtg14

Created on Nov 4, 2014 9:06:48 AM by  ypr (0) 2



Best Answer

Accepted Answer

Votes:

1

Your Vote:

Up

Down

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

Created on Nov 6, 2014 2:42:54 PM by  PRTG Tools Family [prtgtoolsfamily.com] (13,263) 3 4



16 Replies

Votes:

0

Your Vote:

Up

Down

Hi

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

Created on Nov 5, 2014 11:54:55 AM by  Volkan (52) 1 1



Votes:

0

Your Vote:

Up

Down

Hi,

Can you post an example of your batch file here?

Created on Nov 5, 2014 12:41:50 PM by  PRTG Tools Family [prtgtoolsfamily.com] (13,263) 3 4



Votes:

0

Your Vote:

Up

Down

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

Created on Nov 5, 2014 3:18:22 PM by  ypr (0) 2

Last change on Nov 5, 2014 3:51:31 PM by  Torsten Lindner [Paessler Support]



Votes:

1

Your Vote:

Up

Down

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.

Created on Nov 5, 2014 3:35:05 PM by  PRTG Tools Family [prtgtoolsfamily.com] (13,263) 3 4



Votes:

0

Your Vote:

Up

Down

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

Thanks by advance,

Created on Nov 5, 2014 4:53:44 PM by  ypr (0) 2



Votes:

0

Your Vote:

Up

Down

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

Created on Nov 6, 2014 7:31:47 AM by  Aurelio Lombardi [Paessler Support]



Votes:

0

Your Vote:

Up

Down

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

Created on Nov 6, 2014 10:30:54 AM by  ypr (0) 2



Accepted Answer

Votes:

1

Your Vote:

Up

Down

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

Created on Nov 6, 2014 2:42:54 PM by  PRTG Tools Family [prtgtoolsfamily.com] (13,263) 3 4



Votes:

0

Your Vote:

Up

Down

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

Created on Nov 6, 2014 4:16:48 PM by  ypr (0) 2



Votes:

0

Your Vote:

Up

Down

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://kb.paessler.com/en/topic/2543-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

Created on Nov 12, 2014 5:05:33 PM by  ypr (0) 2



Votes:

0

Your Vote:

Up

Down

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.

Created on Nov 13, 2014 8:16:04 AM by  PRTG Tools Family [prtgtoolsfamily.com] (13,263) 3 4



Votes:

0

Your Vote:

Up

Down

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.

Created on Nov 13, 2014 9:59:54 AM by  ypr (0) 2

Last change on Nov 13, 2014 10:19:26 AM by  Konstantin Wolff [Paessler Support]



Votes:

1

Your Vote:

Up

Down

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

Created on Nov 13, 2014 10:31:20 AM by  PRTG Tools Family [prtgtoolsfamily.com] (13,263) 3 4



Votes:

0

Your Vote:

Up

Down

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.

Created on Nov 13, 2014 12:33:52 PM by  ypr (0) 2



Votes:

0

Your Vote:

Up

Down

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.

Created on Nov 13, 2014 1:40:00 PM by  PRTG Tools Family [prtgtoolsfamily.com] (13,263) 3 4



Votes:

0

Your Vote:

Up

Down

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

Best regards,

Created on Nov 14, 2014 9:54:03 AM by  ypr (0) 2



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.