Bulk Host Cloning and Import - Additional Fields

Discuss new project and feature ideas here.
See labs.nagios.com for new projects under development.

Bulk Host Cloning and Import - Additional Fields

Postby jaimie.livingston » Tue Oct 23, 2018 8:19 pm

For large organizations with thousands of hosts, it would be really useful to have the ability to use the Bulk Host Cloning and Import wizard (or something like it) to populate/override any object field, including existing free variable values.

At the very least, being able to populate the host description, notes, notes url, and action url fields would streamline systems support operations.

Thanks

Jaimie Livingston
jaimie.livingston
 
Posts: 5
Joined: Wed Nov 23, 2016 10:41 am

Re: Bulk Host Cloning and Import - Additional Fields

Postby jaimie.livingston » Wed Oct 24, 2018 12:41 pm

I took some time and hacked together the attached PHP applet to replace the stock bulkhostimport.inc.php applet.
It's working well in my test environment.

This hack adds additional fields, including one free variable used to store an Amazon Instance ID that I use with the check_ec2 plugin.
Host Object Attributes that can be imported are:
host_name
address
alias
display_name
notes
notes_url
action_url
hostgroup
parenthost
_amazonid

There are probably opportunities for QA and some Polish.
Use at your own risk. Your Mileage May Vary.
This code is provided as an example only.
I take no responsibility for any harm that occurs from using this code.
Anyone reading this who cannot figure out how to use this text file to replace the stock bulkhostimport.inc.php applet probably shouldn't be making the attempt. Seriously. Wait for a packaged version from the good folks at Nagios.

Have Fun!

Jaimie L
Attachments
bulkhostimport_inc_php.txt
Alternate Code for Stock Bulk Clone & Import PHP
(41.99 KiB) Downloaded 15 times
jaimie.livingston
 
Posts: 5
Joined: Wed Nov 23, 2016 10:41 am

Re: Bulk Host Cloning and Import - Additional Fields

Postby scottwilkerson » Wed Oct 24, 2018 3:44 pm

Thanks for sharing your findings.

There are already some feature requests for some additional fields, but I do not see any easy way to add free variables as there are unlimited possibilities.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12308
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Bulk Host Cloning and Import - Additional Fields

Postby jaimie.livingston » Wed Oct 31, 2018 4:50 pm

Here's a suggestion, should anyone want to pursue it...

Provide a field that will parse the FV name and associated value as a delimited pair. Basically, a parsable 2 value array, inside of the imported csv. You would have to limit the number of allowed free variables, though.

For example:
Field Name = FreeVariable1
Field Value in CSV = "fv_name=fv_value"

It's beyond what I want to code, but I'm sure there is a PHP wizard somewhere up to the task. ;-)

Happy Coding!

~jaimie
jaimie.livingston
 
Posts: 5
Joined: Wed Nov 23, 2016 10:41 am

Re: Bulk Host Cloning and Import - Additional Fields

Postby scottwilkerson » Thu Nov 01, 2018 7:12 am

jaimie.livingston wrote:Here's a suggestion, should anyone want to pursue it...

Provide a field that will parse the FV name and associated value as a delimited pair. Basically, a parsable 2 value array, inside of the imported csv. You would have to limit the number of allowed free variables, though.

For example:
Field Name = FreeVariable1
Field Value in CSV = "fv_name=fv_value"

It's beyond what I want to code, but I'm sure there is a PHP wizard somewhere up to the task. ;-)

Happy Coding!

~jaimie


Thanks for the suggestion!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12308
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Bulk Host Cloning and Import - Additional Fields

Postby Maxwellb99 » Fri Nov 02, 2018 5:07 pm

Good Afternoon,

Please let me know if i'm missing something, but you're looking for the ability to add free variables to existing hosts? Or change variables within an existing nagios_host_object?

@Nagios please correct me if I'm wrong: A host is uniquely identified via its host_name similarly for a service being uniquely defined by the host & service_description? When I Post via the API the object ID stays the same as long as the unique keys of each Nagios object stay the same?

As long as Nagios confirms what I said holds, you can make these changes via the API. Because any legal variable is allowed in the API, for that object. Pass in the "_free_variable_key": "free_variable_value" free variable. Then, loop through your hosts with whatever host_object parameters you want to Post. Finally, apply the config & the hosts should change.

I wrote an example in this thread, using python.
viewtopic.php?f=16&t=50687

Similar warnings/caveats as jamie.livingston. if you want different stuff/multiple hosts read in the csv's from the csv lib then loop through the hosts.

Thanks,
Maxwell Ramirez
Maxwellb99
 
Posts: 28
Joined: Tue Jan 26, 2016 5:29 pm

Re: Bulk Host Cloning and Import - Additional Fields

Postby scottwilkerson » Fri Nov 02, 2018 5:39 pm

Maxwellb99 wrote:Good Afternoon,

Please let me know if i'm missing something, but you're looking for the ability to add free variables to existing hosts? Or change variables within an existing nagios_host_object?

@Nagios please correct me if I'm wrong: A host is uniquely identified via its host_name similarly for a service being uniquely defined by the host & service_description? When I Post via the API the object ID stays the same as long as the unique keys of each Nagios object stay the same?

As long as Nagios confirms what I said holds, you can make these changes via the API. Because any legal variable is allowed in the API, for that object. Pass in the "_free_variable_key": "free_variable_value" free variable. Then, loop through your hosts with whatever host_object parameters you want to Post. Finally, apply the config & the hosts should change.

I wrote an example in this thread, using python.
viewtopic.php?f=16&t=50687

Similar warnings/caveats as jamie.livingston. if you want different stuff/multiple hosts read in the csv's from the csv lib then loop through the hosts.

Thanks,
Maxwell Ramirez


This would work after the fact or if you were just creating the hosts through the API, but I believe the OP is looking to add the variables to the new host at the time of creation using the Bulk Host Cloning and Import wizard.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12308
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Bulk Host Cloning and Import - Additional Fields

Postby Maxwellb99 » Fri Nov 02, 2018 7:03 pm

Ahh, reading is fundamental. Good catch & thanks for the clarification.

Cheers,
Max
Maxwellb99
 
Posts: 28
Joined: Tue Jan 26, 2016 5:29 pm

Re: Bulk Host Cloning and Import - Additional Fields

Postby scottwilkerson » Mon Nov 05, 2018 8:19 am

Maxwellb99 wrote:Ahh, reading is fundamental. Good catch & thanks for the clarification.

Cheers,
Max

no problem
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12308
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Ideas

Who is online

Users browsing this forum: No registered users and 1 guest