Jump to content
Welcome to our new Citrix community!

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.


Recommended Posts

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 file

Open in Notepad++

Search for "add service " with a space at the end

Copy the results to Excel to column A in a tab

Now you have all the services being added

In Notepad++

Search for "bind service " with a space at the end

Copy the results to Excel in another tab

Now you have all the services being bound

In 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 name

Copy and paste column B to column C as values

In 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 it

Copy and paste column D to column E as values

Now you have all the adds and bindings identified

In 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

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 servicegroupbindings

If 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

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 -

  1. 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_svcnames

  1. execute below python script to get the list of services that are not bound to any lbvserver

with 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

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 bind

will should you all the bindings of that server to any services/servicegroup

IF none, there is only the add command.

Link to comment
Share on other sites

  • 5 months later...

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...