Is there a limitation on how many free variables can be set for a host/service config from CCM Misc Settings/Manage Free Variables?
Can I use Nagios API to get the defined free variables for host or service?
Thanks
Joseph
Host or Service using Manage Free Variables
-
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Host or Service using Manage Free Variables
HI Joseph,
Also, I looked over the database info, and I don't believe there's any defined limitation on free variables, what kind of numbers are you thinking about?
Ben
If you add the customvars=1 value to the API call for returning host data it will include any custom variables. Take a look at the API documentation by going to Help > API Docs > Objects Reference for sample commands and examples. Let me know if that would work for you.Can I use Nagios API to get the defined free variables for host or service?
Also, I looked over the database info, and I don't believe there's any defined limitation on free variables, what kind of numbers are you thinking about?
Ben
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Host or Service using Manage Free Variables
Hi Ben,
Yes, I can get the free variable by adding customvars=1 to the API.
As for the number of free variables, currently not many, maybe around 10.
On the other hand, can I set the free variables through API?
Thank you very much!
Joseph
Yes, I can get the free variable by adding customvars=1 to the API.
As for the number of free variables, currently not many, maybe around 10.
On the other hand, can I set the free variables through API?
Thank you very much!
Joseph
Re: Host or Service using Manage Free Variables
Yes, you can modify or create new free variables via the API. Here is an example of creating a new free variable. If this free variable had existed, it would have updated the free variable.
First I get the host configuration to show that _newvar does not exist. Then I use he put command to create and set _newvar. And finally I get the host configuration again to show that _newvar exists and is set to what I wanted.
There is a lot of information to parse there. Definitely give us a shout if you need any additional help with this.
Code: Select all
[root@nagiosxi1 ~]# curl -XGET "http://192.168.14.11/nagiosxi/api/v1/config/host?apikey=9uRkM667AHJQMjCKmVaHpnTjS7l0tYoVtffvEkWbiV04eSODNehsEq6tRqNEJbAc&host_name=Server%20-%20NagiosLS1&pretty=1"
[
{
"host_name": "Server - NagiosLS1",
"use": [
"FD NCPA Any OS",
"linux-server"
],
"alias": "Demo Log Server 1",
"address": "192.168.14.12",
"hostgroups": [
"FD Tier 1 NCPA Any OS",
"FD Tier 1 NCPA Linux"
],
"notes": "41.884919, -87.653877",
"_ncpa_token": "5ea1e0c382bbe3.26670467",
"register": "1"
}
]
[root@nagiosxi1 ~]# curl -XPUT "http://192.168.14.11/nagiosxi/api/v1/config/host/Server%20-%20NagiosLs1?apikey=9uRkM667AHJQMjCKmVaHpnTjS7l0tYoVtffvEkWbiV04eSODNehsEq6tRqNEJbAc&pretty=1&_newvar=MyNewVariable&applyconfig=1"
{
"success": "Updated Server - NagiosLs1 in the system. Config applied, Nagios Core was restarted."
}
[root@nagiosxi1 ~]# curl -XGET "http://192.168.14.11/nagiosxi/api/v1/config/host?apikey=9uRkM667AHJQMjCKmVaHpnTjS7l0tYoVtffvEkWbiV04eSODNehsEq6tRqNEJbAc&host_name=Server%20-%20NagiosLS1&pretty=1"
[
{
"host_name": "Server - NagiosLs1",
"use": [
"FD NCPA Any OS",
"linux-server"
],
"alias": "Demo Log Server 1",
"address": "192.168.14.12",
"hostgroups": [
"FD Tier 1 NCPA Any OS",
"FD Tier 1 NCPA Linux"
],
"notes": "41.884919, -87.653877",
"_ncpa_token": "5ea1e0c382bbe3.26670467",
"_newvar": "MyNewVariable",
"register": "1"
}
]
There is a lot of information to parse there. Definitely give us a shout if you need any additional help with this.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!