Create a new command in nagios

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
W.W.
Posts: 17
Joined: Wed Apr 05, 2017 3:18 am

Create a new command in nagios

Post by W.W. »

Hi

I am little new on nagios and I would like to create a new command. I already have to try but no result. I have defines the command in the file commands.cfg but every time I have an error message in nagios interface web which tells me unknown command.
For example I wanted to create a new command “checkfilesize” here is how I have to proceed
I have defines this command

Code: Select all

define command {
  command_name CheckFileSize
  command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a ShowAll MaxCrit=$ARG1$ File:$ARG2$=$ARG3$
}

Then I have defines the service in the file conf of the machine concerned

Code: Select all

define service{
      use                               generic-service
      host_name                    $HOSTNAME
      service_description        CheckFolder
      check_command           check_nrpe!CheckFileSize -H $HOSTADRRESS -p 5666 -c CheckFileSize -a ShowAll MaxCrit=!1G!Win!=C:\\CheckFolder
}
Restart nagios service and type the following command on nagios server

Code: Select all

check_nrpe!CheckFileSize -H $HOSTADRESS -p 5666 -c CheckFileSize -a ShowAll MaxCrit=1G File:Win=D:\\Folder\\To\\Check
I got this error

Code: Select all

-bash: !CheckFileSize: event not found

I am a little lost here, if somebody can help me that would be cool thank you in advance.
Here is my config I have an nsclient++ 0.5.62 configured on my remote machine (windows 7), and an nagios 4.1 installed on centos 6.8 and this topic show exactly what I want to do https: // forums.monitoring-fr.org / index.php? Topic=227.0
User avatar
tacolover101
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: Create a new command in nagios

Post by tacolover101 »

you seem to have your $ARG#$ variables mixed up.

Code: Select all

command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a ShowAll MaxCrit=$ARG1$ File:$ARG2$=$ARG3$
in this example you are passing $ARG1$, 2, and 3.

Code: Select all

 check_command           check_nrpe!CheckFileSize -H $HOSTADRRESS -p 5666 -c CheckFileSize -a ShowAll MaxCrit=!1G!Win!=C:\\CheckFolder
now on the service level, you have just told nagios that CheckFileSize -H $HOSTADRRESS -p 5666 -c CheckFileSize -a ShowAll MaxCrit=!1G!Win!=C:\\CheckFolder is $ARG1$. this will not work. you need to fix them accordingy. on a service level with the check_command, each section seperated by a ! represnets a new value. for example - check_nrpe!arg1!arg2!arg3!
W.W.
Posts: 17
Joined: Wed Apr 05, 2017 3:18 am

Re: Create a new command in nagios

Post by W.W. »

Thank u for the reply tacolover101

Ok, I undustand what you ask me to do but I don't see how to do it. Where should I put the ! in check_command ?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Create a new command in nagios

Post by mcapra »

W.W. wrote:I have defines the command in the file commands.cfg but every time I have an error message in nagios interface web which tells me unknown command.
Did you create the Command definition in the file itself, or did you use the Core Config Manager? Everything in Nagios XI is done through the Core Config Manager; You never need to touch flat files. If you modified commands.cfg only, that's why the GUI is complaining. The GUI only has a concept of what's been added/deleted/modified via the Core Config Manager.

If you still want to do things in flat files, there's specific ways to handle that in Nagios XI:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Former Nagios employee
https://www.mcapra.com/
W.W.
Posts: 17
Joined: Wed Apr 05, 2017 3:18 am

Re: Create a new command in nagios

Post by W.W. »

I create the command definition in the command.cfg file and only in this file. Do I have create it somewhere else ?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Create a new command in nagios

Post by mcapra »

Yup, you will need to create it through the Core Config Manager like so:
2017_04_12_11_25_48_CCM_Nagios_XI.png
You do not have the required permissions to view the files attached to this post.
Former Nagios employee
https://www.mcapra.com/
W.W.
Posts: 17
Joined: Wed Apr 05, 2017 3:18 am

Re: Create a new command in nagios

Post by W.W. »

Ok, I did it and it's work now thanks
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Create a new command in nagios

Post by cdienger »

Thanks for the update. Was there anything else we can help with or can the thread be closed?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
W.W.
Posts: 17
Joined: Wed Apr 05, 2017 3:18 am

Re: Create a new command in nagios

Post by W.W. »

Yep you can close it.
Locked