Its well documented that the only way to configure syslog settings on NSX-v controllers is via the REST API. One of the things I find myself constantly doing over and over again on customer engagements is configuring syslog servers details on the NSX-v controllers, whether its because I am at a new client, or someone decides to change the destination for their syslog and we need to update them all.
As this seems to be something I keep repeating, I have had it on my TODO list for quite some time to create a nice script which will do the hard work for me.
As usual, the script I have created is written in Python and the only external module required is the Requests module. All others should be in a standard installation of Python.
Here you can see the main help for the script. Each time the script is run you need to provide the NSX Manager IP/FQDN and optionally a username, if no username is specified it will use the default admin account on the NSX Manager.
The script has 3 actions it can perform:
- add – This will add the syslog configuration to all the controllers in the system
- list – This will list the syslog configuration of all the controllers in the system
- del – This will delte the syslog configuration of all the controllers in the system
When running the list action, no further arguments are required.
When running the del action, no further arguments are required.However when invoking the add action, it requires additional arguments as shown below
The following are some examples showing how to run the script and also the output presented.
This one will list all the controller syslog configurations
When using the add actions, if you just specify the destination to send the syslog data to, it will use the default of UDP/514 and set the logging level to INFO. It will show you the details both before and after the new configuration occurs.
Or if you prefer, you can also specify the port, protocol and logging level if required. It will show you the details both before and after the new configuration occurs.
If you try and configure a controller which already has syslog configuration on it, it will throw an error.
And lastly if you want to delete the current syslog configuration on all controllers so that you can add new ones. It will show you the details both before and after the delete occurs.
As usual, the script is located on my GitHub site here