Defining Host Custom Variables via the API

26 views
Skip to first unread message

William Pool

unread,
Oct 10, 2016, 12:23:00 PM10/10/16
to nagrestconf-users
I'm trying to define a custom host variable using the API, but looking at http://nagrestconf.smorg.co.uk/documentation/restreference.php it's not apparent to me how to do it.

Anyone have any nrcq snippets for doing it?

Thanks!

William Pool

unread,
Oct 10, 2016, 12:38:12 PM10/10/16
to nagrestconf-users
For example something like this:

        {{ nrcq_bin }} {{nagrestconf_url }} add/hosts -d name:{{ ansible_hostname }} \
         -d alias:{{ ansible_fqdn }} \
         -d ipaddress:{{ ansible_eth0.ipv4.address }} \
         -d template:host-{{ localhost_environment }} \
         -d hostgroup:hosts-{{ localhost_client }}-{{ localhost_environment }} \
         -d contact:sagroup-workhours \
         -d contactgroups:sa-page-workhours \
         -d activechecks:1 \
         -d servicesets:'{{ localhost_environment|upper }}{{ '-' }}LINUX' \
             -d customvars:'_jmxurl service:jmx:rmi://hostfqdn.com:10002/jndi/rmi://hostfqdn.com:10001/jmxrmi' \
        -d disable:0

Something along these lines . . . 

Mark Clarkson

unread,
Oct 11, 2016, 5:15:31 AM10/11/16
to nagrestc...@googlegroups.com
On Mon, 2016-10-10 at 09:38 -0700, William Pool wrote:
> -d customvars:'_jmxurl service:jmx:rmi://hostf
> qdn.com:10002/jndi/rmi://hostfqdn.com:10001/jmxrmi' \

 -d
customvars:'_jmxurl|service:jmx:rmi://hostfqdn.com:10002/jndi/rmi://hos
tfqdn.com:10001/jmxrmi' \

Google for: nagrestconf compound field

William Pool

unread,
Oct 12, 2016, 12:15:21 PM10/12/16
to nagrestconf-users
Thanks! I'll give that a shot!

William Pool

unread,
Oct 12, 2016, 12:30:21 PM10/12/16
to nagrestconf-users
Worked thanks!

William Pool

unread,
Oct 24, 2016, 2:09:44 PM10/24/16
to nagrestconf-users
I'm trying to add a second custom var, but I don't see it in the GUI. However, the command didn't fail when I ran via the CLI either.

Am I using the proper syntax for adding a second custom var?

        {{ nrcq_bin }} {{nagrestconf_url }} add/hosts -d name:{{ ansible_hostname }} \
         -d alias:{{ ansible_fqdn }} \
         -d ipaddress:{{ ansible_eth0.ipv4.address }} \
         -d template:host-{{ localhost_environment }} \
         -d hostgroup:hosts-{{ localhost_client }}-{{ localhost_environment }} \
         -d contact:sagroup-workhours \
         -d contactgroups:sa-page-workhours \
         -d activechecks:1 \
         -d servicesets:'{{ localhost_environment|upper }}{{ '-' }}LINUX' \
             -d customvars:'_jmxurlservice:jmx:rmi://hostfqdn.com:10002/jndi/rmi://hostfqdn.com:10001/jmxrmi' \
         -d customvars:'_hostcommunity|host:{{ snmp_community }}' \
        -d disable:0

Thanks,! 

On Tuesday, October 11, 2016 at 2:15:31 AM UTC-7, Mark Clarkson wrote:

William Pool

unread,
Oct 24, 2016, 2:14:38 PM10/24/16
to nagrestconf-users
Reply all
Reply to author
Forward
0 new messages