New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

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

Free PRTG
Download >>

 

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

 

Top Tags


View all Tags


Sensor Custom EXE/Script VBA Query MS SQL

Votes:

0

Your Vote:

Up

Down

I wrote VBasic the query to MSSQL gives out a mistake in job - "Response not wellformed: "(C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\Demo VBScript.vbs(10, 30) Microsoft VBScript compilation error: Expected end of statement )" (code: PE132)"

Imports System
Imports System.Data.OleDb
Imports System.Data.SqlClient

Module Module1

    Sub Main()

Dim ConnectionString As String = "Persist Security Info=True;Data Source=10.1.0.142;Initial Catalog=master;Trusted_Connection=true;"
        Using Connection As New SqlConnection(ConnectionString)
            Connection.ConnectionString = ConnectionString
            Connection.Open()

            Dim sSQL As String = "select sum(s_mf.size)*8/1024 " _
                   & "FROM sys.master_files s_mf " _
                   & "WHERE db_name(s_mf.database_id) IN ('prtg');"
            Dim objCmd As New SqlCommand(sSQL, Connection)
            objCmd.ExecuteNonQuery()
            Connection.Close()
        End Using
    End Sub

End Module

As it is correct to write inquiry to SQL to VBA-job?

custom-script-exe custom-sensor mssql query

Created on Feb 4, 2015 9:01:44 AM by  Specialistika (0) 1

Last change on Mar 19, 2015 3:50:07 PM by  Martina Wittmann [Paessler Support]



3 Replies

Votes:

7

Your Vote:

Up

Down

The query might be correct, but nothing is reported back to PRTG.

What is missing is a value and message plus exit code. Something like:

System.Console.WriteLine("0:Ok")
Environment.Exit(0)

In your case, this would probably read

System.Console.WriteLine(sSQL & ":Ok")
Environment.Exit(0)

See also the "/api.htm?tabid=7" page of your PRTG installation

Created on Feb 16, 2015 11:14:53 AM by  PRTG Tools Family [prtgtoolsfamily.com] (13,135) 3 4



Votes:

0

Your Vote:

Up

Down

I read API, your answer doesn't answer a question - connectingstring to base and data acquisition from procedure or from query!

Created on Feb 19, 2015 7:30:37 AM by  Specialistika (0) 1



Votes:

0

Your Vote:

Up

Down

First, your script has to create an output in the format

value:message
Exit Code

so something like, as mentioned in the post before: System.Console.WriteLine(sSQL & ":Ok") Environment.Exit(0) Does the script run from the commandline? If so, what are the outputs there?

Created on Feb 23, 2015 9:57:44 AM by  Konstantin Wolff [Paessler Support]



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.