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
Add comment