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

Monitor SQL Query result using only ports 22, 80 or 443

Votes:

0

Hi there,

is it possible to connect to a mysql database via ssh with the mysqlv2 sensor? The server and database is behind a firewall and only accessible via port 80, 443, 22 - so the connection should be via ssh.

Regards Simon

api http monitoring mysql sql ssh

Created on Feb 16, 2017 12:55:06 PM

Last change on Mar 1, 2017 8:18:29 AM by  Luciano Lingnau [Paessler]



1 Reply

Accepted Answer

Votes:

0

Hi Pupp3tm4st3r,


Important: Please note that Paessler does not provide in-depth support for custom script solutions.


While this cannot be achieved with the MySQLv2 Sensors (they require the SQL-specific ports to be open), there are still a different couple of ways you can get this data into PRTG:

Initially, create a bash script that will poll data from the MySQL Instance. Once this is working, it's a matter of getting the data into PRTG. There are several approaches that you can use:

SSH Script Advanced Sensor

You can create an SSH Script Advanced Sensor to connect to the server via SSH (Port 22) and run your "SQL query" from the bash. The output can be sent back to PRTG within the SSH connection.

HTTP Push Data Advanced Sensor

You can also use HTTP Push Data Advanced Sensor. The way it works is, you first deploy the sensor in PRTG, select a socket from the probe on which it should listen. Then, you can use cron job to run the SQL query via bash, and effectively "push" the data into the PRTG Probe (on any desired/configured port). You can use curl for this.

HTTP Data Advanced Sensor

Lastly but not least, you can use the HTTP Data Advanced Sensor for this. The way it works is: You create a specific webpage on your webserver (/prtgstatistics) which does the bash SQL query, and provide the result as an XML or JSON document. PRTG will connect like any HTTP client would and will parse the output as the sensor's result. Beware of security if you chose this approach, since you need to make sure that only authorized people can access the URL and that it's not an entry point for code injection.

API Data Format

The format of the data in all three sensor approaches is the same, XML or JSON. You can see another example of it here:

This is the "minimum" code to deploy a single sensor channel:

            <prtg>
            <result>
            <channel>First channel</channel>
            <value>10</value>
            </result>
            </prtg>

You can however have multiple channels, use lookups and all other sort of "cool things" can be done. PRTG's API for custom sensors is documented within PRTG under Setup > PRTG API on the Custom Sensors tab.

This will allow you to use non standard ports to access the MySQL server. This would also be applicable to monitor "anything else" and not just SQL on the server.



Best regards,
Felix

Created on Feb 17, 2017 1:15:34 PM by  Felix Saure [Paessler Support]

Last change on Apr 20, 2018 8:33:00 AM by  Luciano Lingnau [Paessler]




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.