Leverage API to add/remove/update devices
Leverage API to add/remove/update devices
We are using the router/switch wizard to load in devices for SNMP V3 monitoring. I am fairly sure that the Wizard also sets up mrtg as well. If I use the API to set up the router/switch, how can I also set up mrtg to get the graphs? Can I use PUT instead of POST to create the initial instance? I would prefer to do this as we are using Ansible and it would be easier and cleaner to only have to consider a single API call in the playbook.
Re: Leverage API to add/remove/update devices
You are correct that running the switch wizard does create mrtg files as well as the host/service definitions. In order to add these special checks without running the wizard, you would have to manually make those mrtg files and then add the hosts/services afterwards. Currently there is no way to run the wizard or set up mrtg-specific checks from the API.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Leverage API to add/remove/update devices
So I know we can create the hosts/services from the API but is there any documentation or information you can send on how exactly to make the mrtg files? That may be easy for us by using the template engine but I have to be able to understand all of the steps involved to be sure.
Re: Leverage API to add/remove/update devices
As @jomann stated clearly:
Currently there is no way to run the wizard or set up mrtg-specific checks from the API.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Leverage API to add/remove/update devices
I think you misunderstood my comments....
The API will not work for setting up MRTG and I can't run the wizard from the CLI so both of those options are off the table.
What I am trying to acquire is documentation on how MRTG would be set up MANUALLY if I was not using the wizard OR API. That way I can leverage ansible to MANUALLY make the changes that are currently made by the wizard when it is run.
For example:
The wizard creates a file 1.2.3.4.cfg and runs an mrtg command to start processing data......I would set up ansible to create that file and run the mrtg commands via ansible so that the end result is the same.
Does that help?
The API will not work for setting up MRTG and I can't run the wizard from the CLI so both of those options are off the table.
What I am trying to acquire is documentation on how MRTG would be set up MANUALLY if I was not using the wizard OR API. That way I can leverage ansible to MANUALLY make the changes that are currently made by the wizard when it is run.
For example:
The wizard creates a file 1.2.3.4.cfg and runs an mrtg command to start processing data......I would set up ansible to create that file and run the mrtg commands via ansible so that the end result is the same.
Does that help?
Re: Leverage API to add/remove/update devices
You could run the "Network Switch / Router" wizard, entering some "fake" data. This way, the wizard would show you a command that you could execute manually, for example:
Modify it by correcting the "fake" values, and run it from the CLI, redirecting it to a config file.
Example:
Modify permissions on the newly created file.
Note:
BTW, if you wanted to add bunch of switches in bulk, the latest "Network Switch / Router" wizard (ver. 2.5.1) already provides this functionality.
I am not sure if you knew that. If you however wanted to add switches from the CLI, then you could disregard this note. Thank you!
Hope this helps.
Code: Select all
/usr/bin/cfgmaker --show-op-down --noreversedns --zero-speed '100000000' --enablesnmpv3 --snmp-options=:::::3 --username='username' --authprotocol='md5' --authpassword='authpassword' --privprotocol='des' --privpassword='privpassword' --contextengineid=0 '1.2.3.4'Example:
Code: Select all
/usr/bin/cfgmaker --show-op-down --noreversedns --zero-speed '100000000' --enablesnmpv3 --snmp-options=:::::3 --username='username' --authprotocol='md5' --authpassword='authpassword' --privprotocol='des' --privpassword='privpassword' --contextengineid=0 '1.2.3.4' > /etc/mrtg/conf.d/1.2.3.4.cfgCode: Select all
chown apache.nagios /etc/mrtg/conf.d/1.2.3.4.cfg
chmod 775 /etc/mrtg/conf.d/1.2.3.4.cfgBTW, if you wanted to add bunch of switches in bulk, the latest "Network Switch / Router" wizard (ver. 2.5.1) already provides this functionality.
I am not sure if you knew that. If you however wanted to add switches from the CLI, then you could disregard this note. Thank you!
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!
Re: Leverage API to add/remove/update devices
BRILLIANT! Thanks!
That is EXACTLY what I was looking for! So were do I see the commands that the wizard is sending? I don't think I have ever noticed that before. Is it on the GUI or in a log file perhaps?
My guess is that I could use the above method to capture any and all commands generated by a wizard which would be gold for what I am trying to do!
I had NO IDEA that there was a bulk add now. That may be a great interim solution. I will set this up in our test environment and see if that may also be a solution.
That is EXACTLY what I was looking for! So were do I see the commands that the wizard is sending? I don't think I have ever noticed that before. Is it on the GUI or in a log file perhaps?
My guess is that I could use the above method to capture any and all commands generated by a wizard which would be gold for what I am trying to do!
I had NO IDEA that there was a bulk add now. That may be a great interim solution. I will set this up in our test environment and see if that may also be a solution.
Re: Leverage API to add/remove/update devices
You will see it in the GUI, provided the command fails (caused by a wrong data, e.g. wrong IP, community string, protocol, password, etc.)So were do I see the commands that the wizard is sending?
Example:
Sure, let us know if you have any further questions. Thanks!I had NO IDEA that there was a bulk add now. That may be a great interim solution. I will set this up in our test environment and see if that may also be a solution.
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!