PRTG Manual: General use
Profile and query
You can execute the PRTG Database Observer console in 2 ways:
▪-profile: followed by a profile name defined in PRTG Database Observer UI
▪-query: followed by the name of the query
▫Or -queryfile: followed by the path to the query located on probe device
Manually specify parameters
Although profiles are the preferred way to execute sensors, it is possible to use sensors from the command line without providing a profile name. Instead of using the -profile and -name parameters, all mandatory connection parameters must be provided.
Profiles are a cleaner and better way to configure sensors in PRTG. When you want to change a connection parameter, you only need to adjust the profile in PRTG Database Observer instead of manually changing all the sensors in PRTG. If you specify parameters manually, all affected sensors need to be updated accordingly.
A password is mandatory for DB2, MYSQL, Oracle and SAPHANA database types and for MSSQL when WA is set to 0 or when it is not specified. To set a password, use -pwd or -pwdne. Do not use both at the same time.
Possible parameters for manual specification:
-host |
This parameter is mandatory. Followed by a host or IP address. |
|---|---|
-database |
This parameter is mandatory for DB2, Oracle, SAP ASE and SAP Hana. Followed by the name of a database. |
-sid |
This parameter is manadatory of Oracle databases. Followed by an SID. |
-port |
Followed by a port number
▪The default port for MYSQL is 3306. ▪The default port for Oracble is 1521. ▪The default port for DB2 is 5000. |
-wa |
Followed by 0 or 1. 0: SQL server authentication 1: Windows authentication
▪The default value is 0. ▪For MSSQL, use Windows authentication. In this case, your Windows user is used for execution in UI and PRTG Service account or Device Windows credentials are used when scanning the sensor from PRTG. ▪For DB2, MYSQL, Oracle, and SAP Hana database types, WA is set to 0 and cannot be modified. |
-user |
This parameter is mandatory for DB2, MYSQL, Oracle, SAP ASE and SAP Hana. This parameter is only mandatory for MSSQL and PostgreSQL when WA is set to 0 or is undefined. Followed by a username |
Followed by the encrypted password. You must use -encrypt first. PRTG_DB_Plugin.exe ‘-encrypt:clearS€curePassword()’ |
|
Followed by a plain text password. Use quotes around parameter when the password contains special characters. |
|
-type |
This parameter is mandatory. Followed by the DBMS type: ▪MSSQL ▪ORACLE ▪MySQL ▪SAPHana ▪IBMDB2 ▪MAXDB ▪IBMINFORMIX ▪SAPASE ▪PostgreSQL |
▪-queryFile: followed by the path to the query. (This parameter is mandatory)
If you want to execute a query with parameters, you can use -params.
▪-params: used with -query or -queryfile as seen below. The user can define maximum 9 parameters, which are separated by comma.
Example: -params:@param1:5000,@param2:1000.
Every parameter defined will be replaced in the query, meaning @param1 will be replaced with 5000 and @param2 will be replaced with 1000.
C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML>PRTG_DB_Plugin.exe -profile:MSSQL_Backup_Check_FULL -params:@param1=20
<prtg>
<result>
<channel>master</channel>
<value>9999</value>
<Float>1</Float>
<Unit>custom</Unit>
<CustomUnit>hrs</CustomUnit>
<LimitMode>1</LimitMode>
<LimitMaxError>20</LimitMaxError>
<LimitErrorMsg>Database master is not backed up</LimitErrorMsg>
</result>
<result>
<channel>model</channel>
<value>9999</value>
<Float>1</Float>
<Unit>custom</Unit>
<CustomUnit>hrs</CustomUnit>
<LimitMode>1</LimitMode>
<LimitMaxError>20</LimitMaxError>
<LimitErrorMsg>Database model is not backed up</LimitErrorMsg>
</result>
</prtg>
Parameters for Informix
-protocol |
Choose between various protocols: ▪drsocssl ▪drsoctcp ▪drtlitcp ▪onipcshm ▪onipcstr ▪ontlitcp ▪onsocssl ▪onsoctcp ▪onsocimc ▪ontliimc ▪onsqlmux |
|---|---|
-server |
The name of the server. |
-service |
The name of the TCP/IP service.
|
C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML>PRTG_DB_Plugin.exe -host:(local)\PRTGDBPLUGIN -database:PRTG_DB_Plugin -type:mssql -wa:1 -queryfile:C:\sqlfile.txt -params:@param1=70,@param2=5
<prtg>
<result>
<channel>C:\Program Files\Microsoft SQL Server\MSSQL11.PRTGDBPLUGIN\MSSQL\Binn\mssqlsystemresource.ldf</channel>
<value>64</value>
<Float>1</Float>
<Unit>custom</Unit>
<CustomUnit>hrs</CustomUnit>
</result>
<result>
<channel>C:\Program Files\Microsoft SQL Server\MSSQL11.PRTGDBPLUGIN\MSSQL\DATA\modellog.ldf</channel>
<value>64</value>
<Float>1</Float>
<Unit>custom</Unit>
<CustomUnit>hrs</CustomUnit>
</result>
</prtg>
Debug
You can use all parameters with -debug. That will display the query result without the XML transformation.
C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML>PRTG_DB_Plugin.exe -host:(local)\PRTGDBPLUGIN -database:PRTG_DB_Plugin -type:mssql -wa:1 -queryfile:C:\sqlfile.txt -params:@param1=70,@param2=5 -debug
---------------------------------------------------------------------------------------------
|Channel |Value|
---------------------------------------------------------------------------------------------
|C:\Program Files\Microsoft SQL Server\MSSQL11.PRTGDBPLUGIN\MSSQL\mssqlsystemresource.ldf |64|
---------------------------------------------------------------------------------------------
|C:\Program Files\Microsoft SQL Server\MSSQL11.PRTGDBPLUGIN\MSSQL\DATA\modellog.ldf |64|
---------------------------------------------------------------------------------------------
Count: 2