---------------------------------------------------------------------------------------*
| ASP_NET_check_db_oracle |
*--------------------------------------------------------------------------------------*
| |
| Author: Alan Pipitone |
| |
| http://www.alan-pipitone.com/ |
| |
---------------------------------------------------------------------------------------*
----------------------------------------------------------------------
HOW IT WORKS
----------------------------------------------------------------------
The plug-in has its own configuration file. Into the configuration file You have to insert
the path of the web.config of your Asp .NET application(s), You have also to insert the
connection string name that is present in the web.config.
In this way the plug-in will automatically connect to the database with the connection string
stored into the web.config. Into the configuration file you have also to put the query
(for security reasons you can put only select) that the plug-in must execute to check the connectivity.
This is the bad part. Infact you have to ask to the developer which query you can use or You
have to analyze the tables in the DataBase.
----------------------------------------------------------------------
HOW TO INSTALL THE PLUG-IN
----------------------------------------------------------------------
This plug-in runs on the IIS Web Server that hosts your applications. I used NSClient++ but i think
that you can also use check_mk.
To print the help use the following command:
ASP_NET_check_db_oracle.exe /h
If you use NSClient++ you have to copy ASP_NET_check_db_oracle.exe (and its configuration file ASP_NET_check_db_oracle.xml)
into the scripts subfolder and then add the following lines into the NSC.ini file:
[NRPE Handlers]
check_ExecCustScript= scripts\$ARG1$ $ARG2$
If the lines above do not work then you probably need to edit them according to the version of NSClient that you are using.
On Nagios server you have to define a new command:
define command {
command_name ASP_NET_check_db_oracle
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_execcustscript -a "ASP_NET_check_db_oracle.exe" "/a $ARG1$ /w $ARG2$ /c $ARG3$"
}
Now you have to define the service (see also the example section below) as follow:
define service{
use your_service_template
host_name your_IIS_server
service_description check myApp
check_command ASP_NET_check_db_oracle!ApplicationName!4!10
}
----------------------------------------------------------------------
AN EXAMPLE
----------------------------------------------------------------------
For this example assume to have two Asp .NET applications hosted by our IIS Web Server. One application is myApp1
which is located into C:\inetpub\wwwroot\myApp1, the second application is myApp2 which is located into
C:\inetpub\wwwroot\myApp2.
We want to monitor both applications. Our NSClient++ is located into c:\Program Files\NSClient++
Now We have to copy ASP_NET_check_db_oracle.exe into c:\Program Files\NSClient++\scripts.
In that folder we have to create ASP_NET_check_db_oracle.xml as follow:
C:\inetpub\wwwroot\myApp1\Web.config
connStringNameApp1
SELECT * FROM App1Table
C:\inetpub\wwwroot\myApp2\Web.config
connStringNameApp2
SELECT * FROM App2Table
The above parameters are quite clear. The connection.string contains the connaction string name of your Asp. NET
application (the connection string is into the web.config).
For example, into the web.config of myApp1 you can find the following section that contains our connection string:
..
...
...
..
Now We have to add the following lines into the c:\Program Files\NSClient++\NSC.ini file:
[NRPE Handlers]
check_ExecCustScript= scripts\$ARG1$ $ARG2$
On Nagios server you have to define a new command:
define command {
command_name ASP_NET_check_db_oracle
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_execcustscript -a "ASP_NET_check_db_oracle.exe" "/a $ARG1$ /w $ARG2$ /c $ARG3$"
}
Then you have to define two service as follow:
define service{
use your_service_template
host_name your_IIS_server
service_description check DB myApp1
check_command ASP_NET_check_db_oracle!myApp1!4!10
}
define service{
use your_service_template
host_name your_IIS_server
service_description check DB myApp2
check_command ASP_NET_check_db_oracle!myApp2!4!10
}
---------------------------------------------------------------------
ONE LAST NOTE
----------------------------------------------------------------------
I defined this command on NSClient:
check_ExecCustScript= scripts$ARG1$ $ARG2$
This allows you to define several commands on Nagios without edit NSC.ini of your servers.
For example, you can put (on the NSClient++ scripts subfolder of your windows server) a.exe, b.exe, c.bat and
then define the following commands on Nagios:
define command {
command_name check_a
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_execcustscript -a "a.exe" "$ARG1$"
}
define command {
command_name check_b
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_execcustscript -a "b.exe" "$ARG1$"
}
define command {
command_name check_c
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_execcustscript -a "c.bat" "$ARG1$"
}