rkennedy wrote:You'll want to define a command like so -
Code: Select all
define command {
command_name check_mssql_job
command_line $USER1$/check_mssql_job_history.py -H $HOSTADDRESS$ $ARG1$
}
The service definition would use this as the check command -
Code: Select all
check_command check_mssql_job! -U mssqlUser -P mssqlPassword
That should work for you, let us know if you run into any issues.
bmurtha wrote:I'm assuming $User1$ expands to /usr/local/nagios/libexec
-H $HostAddress$ expands to my IP or I have to replace it?
-A $Args1$ is going to expand to what is in command_name? I'm new to this so please forgive me if my questions are stupid.
No problem. you got it! $USER1$ will expand to that directory. It pulls the reference from /usr/local/nagios/etc/resource.cfg. You could also define other $USER#$ variables in that file, to masquerade a password for example.
$HOSTADDRESS$ will be pulled from the the address part under your host definition.
$ARG1$ will pull from anything after the ! in our check command. Once another ! is present, $ARG2$ will exist. For example -
Code: Select all
check_command check_mssql_job! -U mssqlUser -P mssqlPassword!second!third
Code: Select all
$ARG1$ = ' -U mssqlUser -P mssqlPassword'
$ARG2$ = 'second'
$ARG3$ = 'third'
bmurtha wrote:This looks great but where do I put it? In /usr/local/nagios/libexec ? Should it use a file extension? Sorry I'm new to Nagios.
The standardization that Core deploys with, is all of your commands located in /usr/local/nagios/etc/commands.cfg. From there, you can create any file to hold your host / service definitions. The one key part, is making sure it's referenced in the /usr/local/nagios/etc/nagios.cfg file.
For example, you should see this part in your nagios.cfg -
Code: Select all
# OBJECT CONFIGURATION FILE(S)
# These are the object configuration files in which you define hosts,
# host groups, contacts, contact groups, services, etc.
# You can split your object definitions across several config files
# if you wish (as shown below), or keep them all in a single config file.
# You can specify individual object config files as shown below:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
# Definitions for monitoring the local (Linux) host
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
# Definitions for monitoring a Windows machine
#cfg_file=/usr/local/nagios/etc/objects/windows.cfg
# You can specify individual object config files as shown below:
#cfg_dir=/usr/local/nagios/etc/servers
You are free to organize this in any way that you want. The two important things here are cfg_file, and cfg_dir. This is how you include a file to work with Nagios Core. I recommend creating a /usr/local/nagios/etc/servers folder, and uncommenting the line above
#cfg_dir=/usr/local/nagios/etc/servers.
At this point, you can place any configuration files into that servers folder, and they will be picked up by Core.
Once you uncomment the servers folder, and have created it - you can now create a configuration file to use. Call this
hostname.cfg for example. Something like this should suffice -
Code: Select all
define host {
use linux-server
host_name hostnamehere
alias alias for this host
address 1.2.3.4
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}
define service {
use generic-service
host_name hostnamehere
service_description MSSQLJOB
check_command check_mssql_job! -U mssqlUser -P mssqlPassword
}
Then, make sure to add to the bottom of your /usr/local/nagios/etc/objects/commands.cfg -
Code: Select all
define command {
command_name check_mssql_job
command_line $USER1$/check_mssql_job_history.py -H $HOSTADDRESS$ $ARG1$
}
Run a
service nagios restart, and if no errors were detected you should now have the command check_mssql_job with a host / service corresponding to it.
I tried to explain this pretty thorough -- let me know if you have any further questions. None are stupid.
