I'm taking over our Nagios set up and changing the way we were adding Hosts by utilizing API instead of using script, all seems like working as design however there are some differences in hostname.cfg files (please see attached). Is it due to upgrade to a new version XI offering API options or may missing something constructing API call?
curl -XPOST "http://xxxxxx/nagiosxi/api/v1/config/ho ... r&pretty=1" -d "host_name=CVTK4162909&use=xiwizard_windowsdesktop_host&alias=CVT&address=CVTK4162909&hostgroups=DRT_CVT,MCY-006-EST&check_command=mst_check_snmp_name&max_check_attempts=25&check_interval=60&retry_interval=60&check_period=24x7¬ification_interval=60¬ification_period=24x7&force=1"
Thanks!
Adding Hosts by API vs Bash Script/Template.cfg
-
nagwindmon
- Posts: 92
- Joined: Mon Dec 01, 2014 3:39 pm
Adding Hosts by API vs Bash Script/Template.cfg
You do not have the required permissions to view the files attached to this post.
-
dwhitfield
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Adding Hosts by API vs Bash Script/Template.cfg
Could you clarify how you want it to look from the API?
I see the following two are missing from the API
However, those aren't in your API call. The xiwizard is also not there, but if you aren't using a wizard, I'm not sure why you would want that there.
Also, xi_timeperiod_24x7 could be used in the API if that's how you'd prefer it to look. As long as those two timeperiods are defined the same, it won't matter which you use.
I see the following two are missing from the API
Code: Select all
icon_image windowsxp.png
statusmap_image windowsxp.png
Also, xi_timeperiod_24x7 could be used in the API if that's how you'd prefer it to look. As long as those two timeperiods are defined the same, it won't matter which you use.
-
nagwindmon
- Posts: 92
- Joined: Mon Dec 01, 2014 3:39 pm
Re: Adding Hosts by API vs Bash Script/Template.cfg
Code: Select all
icon_image windowsxp.png
statusmap_image windowsxp.png
Also there are few a (!) marks showing next to command name but none in .cfg file generated by API?
Here the command itself:
define command {
command_name mst_check_snmp_name
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -o sysName.0 -C public -P 2c -l "name" -r $HOSTNAME$
}
Re: Adding Hosts by API vs Bash Script/Template.cfg
The icon_image and statusmap_image are not required, but you can add them if you wish by adding this to your API command:
Here's an explanation on what they do:
As far as the extra "!" signs in the command, these are delimiters added by the CCM. You don't actually need them, unless they separate arguments. They won't hurt anything, either (if they are present). The API command won't be adding these at the end.
Hope this helps.
Code: Select all
&icon_image=windowsxp.png&statusmap_image=windowsxp.pngHost - icon image
This variable is used to define the name of a GIF, PNG, or JPG image that should be associated with this host. This image will be displayed in the various places in the CGIs. The image will look best if it is 40x40 pixels in size. Images for hosts are assumed to be in the logos/ subdirectory in your HTML images directory (i.e. /usr/local/nagios/share/images/logos).
Parameter name: icon_image
Required: no
Here's an example of the same icon in the GUI (under Host Detail & Status Map):Host - statusmap image
This variable is used to define the name of an image that should be associated with this host in the statusmap CGI. You can specify a JPEG, PNG, and GIF image if you want, although I would strongly suggest using a GD2 format image, as other image formats will result in a lot of wasted CPU time when the statusmap image is generated.
GD2 images can be created from PNG images by using the pngtogd2 utility supplied with Thomas Boutell's gd library . The GD2 images should be created in uncompressed format in order to minimize CPU load when the statusmap CGI is generating the network map image.
The image will look best if it is 40x40 pixels in size. You can leave these option blank if you are not using the statusmap CGI. Images for hosts are assumed to be in the logos/ subdirectory in your HTML images directory (i.e. /usr/local/nagios/share/images/logos).
Parameter name: statusmap_image
Required: no
As far as the extra "!" signs in the command, these are delimiters added by the CCM. You don't actually need them, unless they separate arguments. They won't hurt anything, either (if they are present). The API command won't be adding these at the end.
Hope this helps.
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
nagwindmon
- Posts: 92
- Joined: Mon Dec 01, 2014 3:39 pm
Re: Adding Hosts by API vs Bash Script/Template.cfg
Yes it did, thanks for detail explanation! I think I'm good for now.
You can lock this thread if you like.
You can lock this thread if you like.