1. Introduction
I've develped my own Nagios CheckByJdbc plugin allows you to check a SQL query from a script file on database ( Oracle, Microsoft SqlServer, Mysql ) by a JDBC connection.2. Download Plugin
Download plugin here:- https://bitbucket.org/josemarsilva/checkbyjdbc
3. Installing Plugin
Unzip CheckByJdbc.zip and follow 'read-me.txt' instructions
Your command.cfg should be like this
# 'check_by_jdbc' command definition
define command{
command_name check_by_jdbc
command_line java -cp $USER1$/CheckByJdbc/.:$USER1$/CheckByJdbc/$ARG1$ CheckByJdbc -d $ARG2$ -H $ARG3$ -p $ARG4$ -s $ARG5$ -l $ARG6$ -x $ARG7$ -m $ARG8$ -f $USER1$/CheckByJdbc/$ARG9$ -R "$ARG10$" -w $ARG11$ -c $ARG12$ -M "$ARG13$" -v $ARG14$
}
# define a service to be checked by CheckByJdbc
define service{
use local-service
host_name vmwsrv01
service_description CheckByJdbc Oracle Tablespaces
check_command check_by_jdbc!classes12.jar!orcl!192.168.133.2!1521!orcl!nagios!nagios!f!sqlfile1.sql!!80!90!CheckByJdbcTablespaces!0
check_interval 1
retry_interval 1
}
define service{
use local-service
host_name vmwsrv01
service_description CheckByJdbc Oracle Invalid Objects
check_command check_by_jdbc!classes12.jar!orcl!192.168.133.2!1521!orcl!nagios!nagios!f!sqlfile2.sql!&OWNERLIST='MANAGER','RM'!0!0!CheckByJdbc Invalid Objects!0
check_interval 1
retry_interval 1
}
define service{
use local-service
host_name vmwsrv01
service_description CheckByJdbc Oracle LongTimeUserQuery
check_command check_by_jdbc!classes12.jar!orcl!192.168.133.2!1521!orcl!nagios!nagios!f!sqlfile3.sql!!300!900!CheckByJdbc OrclLongTimeUserQuery!0
check_interval 15
retry_interval 15
}
Hi, It's not possible to download the plugin from nagios exchange..Can you please post the files in your blog?
ResponderExcluirThank you very much
Sorry! I don't know what happend. I've uploaded the file but it's not possible to download! It's available in the following url
ResponderExcluirhttp://www.drivehq.com/web/josemarsilva/download/CheckByJdbc.zip
Hi I'm so sorry..but the new url in drivehq has expired, so not possible to download.
ExcluirThank you very much :D
Here it is!
Excluirhttps://docs.google.com/open?id=0Bw01CdQwHqwIdTB0MGtwYTJuT2c
I've updated NagiosExchange documentantion too!
Este comentário foi removido pelo autor.
ResponderExcluirHi Norman,
ResponderExcluirAs you see in source code, the first column must be numeric, and plugin validate this.
When you select a constant from MYSQL JDBC getColumnType() returns -5 /* BIGINT */.
Sorry, this was a unnexpected value for plugin. It's a bug! to solve is very simple: Add to source and validation with type -5. Patch code follows.
PS:
https://www.google.com.br/search?q=java+doc+getColumnType+jdbc+constant+values&oq=java+doc+getColumnType+jdbc+constant+values&aqs=chrome.0.57j62l2.6869&sugexp=chrome,mod=6&sourceid=chrome&ie=UTF-8#q=jdbc+getColumnType+constant+
Source Code version 1.0.c
:
469: fieldType[i] = rsmd.getColumnType(i); :
:
487: if ( fieldType[1] != 2 /* number */ //°A SEBGUE 20130227
488: && fieldType[1] != 4 /* integer */ ) //°A SEBGUE 20130227
Source code patch version "future 1.0.d"
487: if ( fieldType[1] != 2 /* number */ //°A SEBGUE 20130227
488: && fieldType[1] != 4 /* integer */
489: && fieldType[1] != -5 /* bigint */ )
[]'s
De: Norman van Wijnen
Para: "josemarsilva@yahoo.com.br"
Enviadas: Quinta-feira, 3 de Outubro de 2013 10:45
Assunto: CheckByJDBC
Hi,
I am working on setup CheckByJDBC for working with Centura SQLBase databases.
The communication at this point is working , but I fall continuous in the same problems.
Testing your tool with mysql in combination with the mysql examples I get
[root@oramon02 CheckByJdbc]# java -cp /usr/local/nagios/libexec/CheckByJdbc/.:/usr/local/nagios/libexec/CheckByJdbc/mysql-connector-java-5.1.18-bin.jar CheckByJdbc -d mysql -H 145.44.17.185 -p 3306 -s mysql -l nagios -x nagios -m f -f sqlfile4.sql -w 2 -c 3 -M "CheckByJdbc MySql Sample" -v 2
Debug(2): Check parameter consistency ...
Debug(2): dbtype: mysql
Debug(2): ip: 145.44.17.185
Debug(2): port: 3306
Debug(2): sid: mysql
Debug(2): username: nagios
Debug(2): password: nagios
Debug(2): mode: f
Debug(2): sqlfile: sqlfile4.sql
Debug(2): stored_proc: null
Debug(2): addparam: null
Debug(2): warning: 2
Debug(2): critical: 3
Debug(2): msgstatus: CheckByJdbc MySql Sample
Debug(2): verbose: 2
Debug(2): jdbcdriver: null
Debug(2): Build Sql Statement ...
Debug(2): getQueryFromSQLFile() BufferedReader() ...
Debug(2): getQueryFromSQLFile() Replacement ...
Debug(2): sqlstmt: select 0 nagios_return, user from user order by user
Debug(2): Execute check by JDBC connection ...
Debug(2): executeCheckByJdbc() url: jdbc:mysql://145.44.17.185:3306/mysql
Debug(2): executeCheckByJdbc() jdbcdriver: com.mysql.jdbc.Driver
Debug(2): executeCheckByJdbc() Class.forName() ...
Debug(2): executeCheckByJdbc() DriverManager.getConnection() ...
Debug(2): executeCheckByJdbc() conn.createStatement() ...
Debug(2): executeCheckByJdbc() ps.executeQuery() ...
Debug(2): executeCheckByJdbc() rs.getMetaData() ...
Debug(2): executeCheckByJdbc() fieldType[1]: -5
Debug(2): executeCheckByJdbc() fieldType[2]: 1
Debug(2): executeCheckByJdbc() rs.next()
Debug(2): executeCheckByJdbc() Number of rows: 13
Debug(2): executeCheckByJdbc() nCountStatusOK: 0
Debug(2): executeCheckByJdbc() nCountStatusWARNING: 0
Debug(2): executeCheckByJdbc() nCountStatusCRITICAL: 0
Debug(2): executeCheckByJdbc() nCountStatusUNKNOWN: 13
Debug(2): executeCheckByJdbc() sMsgStatusOK:
Debug(2): executeCheckByJdbc() sMsgStatusWARNING:
Debug(2): executeCheckByJdbc() sMsgStatusCRITICAL:
Debug(2): executeCheckByJdbc() sMsgStatusUNKNOWN: Plugin message error: First Column must be Nagios number status
Debug(2): executeCheckByJdbc() ps.close() ...
Debug(2): executeCheckByJdbc() conn.close() ...
UNKNOWN - CheckByJdbc MySql Sample: Plugin message error: First Column must be Nagios number status
Debug(2): Nagios Plugin required return ...
Debug(2): retStatus: 3
The problem is the First Column must be Nagios number status.
Do you know how to solve?
The oracle examples are working great.
Best regards
Norman
CheckByJdbc Plugin is now hosted on the following url:
ResponderExcluirhttps://bitbucket.org/josemarsilva/checkbyjdbc