Elias Winburne Posted May 3, 2023 Share Posted May 3, 2023 I want to find all objects that do not have any binding. Trying to do some clean up. Anyone know a way to find/list these objects. Link to comment Share on other sites More sharing options...
Swetha Garipally 2 Posted May 4, 2023 Share Posted May 4, 2023 Hi Elias, Can you please provide some details on the use-case you are trying to achieve? Are you planning to do the cleanup from CLI or from API? Link to comment Share on other sites More sharing options...
Elias Winburne Posted May 4, 2023 Author Share Posted May 4, 2023 I plan to use the CLI to remove the Objects that have no binding.I think I figured out a way to do it.Export the ns.conf fileOpen in Notepad++Search for "add service " with a space at the endCopy the results to Excel to column A in a tabNow you have all the services being added In Notepad++Search for "bind service " with a space at the endCopy the results to Excel in another tabNow you have all the services being boundIn Excel in the "add" data, use a formula in column B like =TEXTAFTER(A1,"add service ") notice the space at the end. Pull down formula.This will remove the text before the service nameCopy and paste column B to column C as valuesIn column D use a formula like =TEXTBEFORE(C1," ") notice the space at the end. Pull down formula.This will provide the service name and remove all text after itCopy and paste column D to column E as valuesNow you have all the adds and bindings identifiedIn the next column you use a formula to find any services that do have a bindings. IF(ISNA(MATCH(E1,C:C,0)),E1) Column E is bindings list and Column C is services. Pull down the formula to the longest list.This will bring out all the services that do not match the bindings.or you can get the results ready for the CLI with =CONCAT("Text ", IF(ISNA(MATCH(E1,C:C,0)),E1, ""), " some other text")I got some help from my Citrix Lead Technical Account Manager, Amy Devon, on the Excel manipulation.There may be an easier way... The CLI is wonderful and dangerous. Backup before you remove the services. Link to comment Share on other sites More sharing options...
Elias Winburne Posted May 4, 2023 Author Share Posted May 4, 2023 Hmmm. I see a flaw in my approach. "Search for "bind service " with a space at the end" will actually find services bound to monitors...Now working with CLI two commands: show svcbindings and show servicegroupbindingsIf I can find all the service names, I could use "show svcbindings <name of service> to see bindings or not? Link to comment Share on other sites More sharing options...
Swetha Garipally 2 Posted May 5, 2023 Share Posted May 5, 2023 Hi Elias, If I understand correctly, you are trying to collect list of services that are not bound to an lbvserver. if so - yes, you can use "show svcbindings" and run through every servicename. alternatively , you can use below steps to achieve the same - run below two command on ns.conf grep "add service " ns.conf | awk -F" " '{print $3}' > tmp_svcnames grep "bind lb vserver" ns.conf | grep -vi policyname | awk -F" " '{print $5}' > tmp_lb_bound_svcnamesexecute below python script to get the list of services that are not bound to any lbvserverwith open("tmp_svcnames") as file: svcnames = [line.rstrip() for line in file]with open("tmp_lb_bound_svcnames") as file: busy_svcs = [line.rstrip() for line in file]busy_svcs_set = set(busy_svcs)busy_svcs_lists = list(busy_svcs_set)for svc in svcnames: if svc not in busy_svcs_lists: print(svc) Link to comment Share on other sites More sharing options...
Morten Kallesøe Posted May 10, 2023 Share Posted May 10, 2023 you need to search for all the "add " statements in the ns.conf file,then search for each entity name, to see if there is a line with "bind"its not a 100% as certain objects are referenced differently, but the name should for sure be in a action or bind command.grep <server name> ns.conf | grep bindwill should you all the bindings of that server to any services/servicegroupIF none, there is only the add command. Link to comment Share on other sites More sharing options...
Allan Choiniere Posted October 25, 2023 Share Posted October 25, 2023 I'm attempting to do a clean-up of my NetScaler environment as well. Using PowerShell I can backup all my configurations to a folder. I process all the files in that folder. So far I have found all unbound "Service" objects. I'm here because "Netscaler ADNS" and "NetScaler ADNS_TCP" have no binding listed that are no references in the config files other than the creation of the service. Darn good thing I didn't delete them. They are refenced as a binding for ADNS in "GSLB Virtual Server". These must be hard coded and required names not to have bindings in the config files. This leads me to a bigger question what other objects are hard coded and static that I need to worry about??? Link to comment Share on other sites More sharing options...
Allan Choiniere Posted October 25, 2023 Share Posted October 25, 2023 The above was achieved by extracting the "Service" object name from all config lines for that VPX add them to a Hash Table. Creating another Hash Table for all Lines starting with "add *" and "set *'.If I had a Service objects name as String that was not on any add or set config lines then it was considered to be unbound.The "Netscaler ADNS" and "NetScaler ADNS_TCP" service objects are an exception to this.Rinsed and repeated for ServiceGroups which we primary use and the list was way to small. There are Monitor binds and SSL binds and Sets that needed to be excluded to get a better picture of unbound service groups. Link to comment Share on other sites More sharing options...
Allan Choiniere Posted October 25, 2023 Share Posted October 25, 2023 I also considered speeding up the clean up by deleting the object via the command line. But that is to dangerous for me to do.The GUI will stop you from deleting a object like a server that is still bound to a Service Group. From what I read if you deleted the server in the command line it will delete the Service Group too. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now