Here is a little script i wrote some time ago in Python3.
It simply runs through a NetScaler config file looking for loadbalancing VServers and their bindings. It creats a more readable MarkDown file on it.
Helpfull for a quick inventory on big implementations:
Just try it, you might like it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#!python3 fn = input('Filename:') vscount = 0 try: fw = open (fn + '_vs.md', 'w') for l1 in open(fn): if "add lb vserver" in l1: vscount += 1 sline = l1.split(' ') lbvserver = sline[3] fw.write ('##' + lbvserver + '\r\n') fw.write ('\t' + l1) for l2 in open(fn): if "bind lb vserver " + lbvserver + ' ' in l2: fw.write ('\t' + l2) fw.write('#' * 20 + '\r\n') print ('LB VServers Added: ' , vscount) fw.close() except: print('file not found') |
This one does the same, on ServiceGroups:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#!python3 fn = input('Filename:') sgcount=0 try: fw = open (fn + '_sg.md', 'w') for l1 in open(fn): if "add serviceGroup" in l1: sgcount += 1 sline = l1.split(' ') lbSG = sline[2] fw.write ('##' + lbSG + '\r\n') fw.write ('\t' + l1) for l2 in open(fn): if "bind serviceGroup " + lbSG + ' ' in l2: fw.write ('\t' + l2) fw.write('#' * 20 + '\r\n') print ('Service Groups Added: ' , sgcount) fw.close() except: print('file not found') |
Have fun with it!
I haven’t touched code in a quarter century. Could you tell me how to use this code to get a report on my instance? For that matter, how do you feed it? NS.conf?
Thanks!