What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Sensor Custom EXE/Script VBA Query MS SQL

Votes:

0

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

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



3 Replies

Votes:

7

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



Votes:

0

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



Votes:

0

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]




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.