I couldn’t figure out if there are a tool or a way to count the number of allocated max\min instances for all published services. See below
Best Regards,
Rawan
Good Morning Rawan,
Check and download the attached python file and try to run it.
No need to spend time on format this code.
https://community.esri.com/docs/DOC-9922-arcgis-server-map-service-properties
You can look into writing a python script to get the "minInstancesPerNode" and "maxInstancesPerNode" properties from the Admin API:
https://<server>.<domain>.com:6443/arcgis/admin/services/SampleWorldCities.MapServer?f=pjson
Dear Jonthan,
Thanks for you reply,I need this to be applied on all services.
How could I add a python script to get the "minInstancesPerNode" and "maxInstancesPerNode" properties from the Admin API:?
I opened this link, and logins as admin but I couldn’t made any changes, maybe I misunderstand this point.
You're at the Rest API, not the Admin API:
The bolded section is the URL to the Admin API. Log in with administrative credentials to make changes.
I would start with looking at the overview of scripting administration of your Server, and the specific examples of editing service properties and checking a folder for stopped services for pieces of code you can use.
Dear Jonathan,
Hi
Please try below link code and generate one output file with all details about services.
From this file you can calculate total instance assigned from one ArcGIS server.
Dear Avinash Kumar Patel,
Thanks for your reply,
Actually, I’m not sure where should I apply this code to get the required information.
Can you please tell me the path in Admin API where I could run this code?
Best,
Hi Rawan,
You need to copy the code in notepad and make the extension as .py like(avinash.py).
After that you need to double click it
Give inputs like:
Enter user name: avinashEnter password:Enter server name: avinashOutput File: \avinash.csvYou can get the output file on you save location.
Make sure system have python installed on it like where ArcGIS server or desktop installed on it.
Dear Avinash,
Thank you for your answer.
I tried to do what you are mention, but it doesn’t work for me.
When I double click on the “file py” it’s not open like the screenshot you provide.
And I make sure the python is installed. attached
What might be the issue here?
Try like thisIn Start menu>search python >select python GUI>then in GUI file>new file>past your code & save >run it
Are you able to execute this.
Thank you for your answer and prompt help.
I tried to follow the steps that you mentioned above, I’m able to run the model but it gives me the following error. Should I enhance on the code to make it work fine?
Thanks a lot for your effort, it’s working fine with me.
But I still need to enhance this code to sum the min/max instances automatically, is that possible?
It's possible by creating a token, getting the list of services, looping through each service, grabbing the min/max instances, adding them to a counter, and getting the list of folders, getting the list of services in each folder, looping through each service, and grabbing the min/max instances, and adding them to a counter as well:
<SPAN class="keyword token">import</SPAN> urllib2<SPAN class="punctuation token">,</SPAN> urllib<SPAN class="punctuation token">,</SPAN> json<SPAN class="punctuation token">,</SPAN> ssl <SPAN class="comment token">#Avoids self signed certificate errors</SPAN> ssl<SPAN class="punctuation token">.</SPAN>_create_default_https_context <SPAN class="operator token">=</SPAN> ssl<SPAN class="punctuation token">.</SPAN>_create_unverified_context baseURL <SPAN class="operator token">=</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F" target="_blank">https://</A><SPAN><machine>.<domain>.com:6443/arcgis'</SPAN></SPAN> psaUsername <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<username>'</SPAN> psaPassword <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<password>'</SPAN> <SPAN class="comment token">#Function to open URLS</SPAN> <SPAN class="keyword token">def</SPAN> <SPAN class="token function">openURL</SPAN><SPAN class="punctuation token">(</SPAN>url<SPAN class="punctuation token">,</SPAN>params<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> encodedParams <SPAN class="operator token">=</SPAN> urllib<SPAN class="punctuation token">.</SPAN>urlencode<SPAN class="punctuation token">(</SPAN>params<SPAN class="punctuation token">)</SPAN> response <SPAN class="operator token">=</SPAN> urllib2<SPAN class="punctuation token">.</SPAN>urlopen<SPAN class="punctuation token">(</SPAN>url<SPAN class="punctuation token">,</SPAN>encodedParams<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>read<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonResponse <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN>loads<SPAN class="punctuation token">(</SPAN>response<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">return</SPAN> jsonResponse serverAdminURL <SPAN class="operator token">=</SPAN> <SPAN class="string token">"{0}/admin"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>baseURL<SPAN class="punctuation token">)</SPAN> tokenURL <SPAN class="operator token">=</SPAN> <SPAN class="string token">'{0}/tokens/generateToken'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>baseURL<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Generates an admin token</SPAN> tokenParams <SPAN class="operator token">=</SPAN> dict<SPAN class="punctuation token">(</SPAN>username<SPAN class="operator token">=</SPAN>psaUsername<SPAN class="punctuation token">,</SPAN>password<SPAN class="operator token">=</SPAN>psaPassword<SPAN class="punctuation token">,</SPAN>client<SPAN class="operator token">=</SPAN><SPAN class="string token">'requestip'</SPAN><SPAN class="punctuation token">,</SPAN>f<SPAN class="operator token">=</SPAN><SPAN class="string token">'json'</SPAN><SPAN class="punctuation token">)</SPAN> token <SPAN class="operator token">=</SPAN> openURL<SPAN class="punctuation token">(</SPAN>tokenURL<SPAN class="punctuation token">,</SPAN>tokenParams<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'token'</SPAN><SPAN class="punctuation token">]</SPAN> rootServicesURL <SPAN class="operator token">=</SPAN> <SPAN class="string token">"{0}/services"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>serverAdminURL<SPAN class="punctuation token">)</SPAN> adminParams <SPAN class="operator token">=</SPAN> dict<SPAN class="punctuation token">(</SPAN>token<SPAN class="operator token">=</SPAN>token<SPAN class="punctuation token">,</SPAN>f<SPAN class="operator token">=</SPAN><SPAN class="string token">'json'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Starts the min/max counters</SPAN> totalMinInstances <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN> totalMaxInstances <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN> <SPAN class="comment token">#Gets services in the root directory</SPAN> rootServices <SPAN class="operator token">=</SPAN> openURL<SPAN class="punctuation token">(</SPAN>rootServicesURL<SPAN class="punctuation token">,</SPAN>adminParams<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'services'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token">#Loops through services</SPAN> <SPAN class="keyword token">for</SPAN> service <SPAN class="keyword token">in</SPAN> rootServices<SPAN class="punctuation token">:</SPAN> serviceName <SPAN class="operator token">=</SPAN> service<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'serviceName'</SPAN><SPAN class="punctuation token">]</SPAN> serviceType <SPAN class="operator token">=</SPAN> service<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'type'</SPAN><SPAN class="punctuation token">]</SPAN> serviceURL <SPAN class="operator token">=</SPAN> <SPAN class="string token">"{0}/{1}.{2}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>rootServicesURL<SPAN class="punctuation token">,</SPAN>serviceName<SPAN class="punctuation token">,</SPAN>serviceType<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Gets service information</SPAN> serviceInfo <SPAN class="operator token">=</SPAN> openURL<SPAN class="punctuation token">(</SPAN>serviceURL<SPAN class="punctuation token">,</SPAN>adminParams<SPAN class="punctuation token">)</SPAN> minInstances <SPAN class="operator token">=</SPAN> serviceInfo<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'minInstancesPerNode'</SPAN><SPAN class="punctuation token">]</SPAN> maxInstances <SPAN class="operator token">=</SPAN> serviceInfo<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'maxInstancesPerNode'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token">#Adds min/max instances to counters</SPAN> totalMinInstances <SPAN class="operator token">+=</SPAN> minInstances totalMaxInstances <SPAN class="operator token">+=</SPAN> maxInstances <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Service {0} is configured with {1} min instances and {2} max instances."</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>serviceName<SPAN class="punctuation token">,</SPAN>minInstances<SPAN class="punctuation token">,</SPAN> maxInstances<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Gets folders</SPAN> rootFolders <SPAN class="operator token">=</SPAN> openURL<SPAN class="punctuation token">(</SPAN>rootServicesURL<SPAN class="punctuation token">,</SPAN>adminParams<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'folders'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> folder <SPAN class="keyword token">in</SPAN> rootFolders<SPAN class="punctuation token">:</SPAN> <SPAN class="comment token">#Optionally go through System and Utilities folders, (you'll need to uncomment the line and fix the indentation)</SPAN> <SPAN class="comment token">#if not folder in ['System','Utilities']:</SPAN> folderURL <SPAN class="operator token">=</SPAN> <SPAN class="string token">"{0}/{1}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>rootServicesURL<SPAN class="punctuation token">,</SPAN>folder<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Gets services in folders</SPAN> servicesInFolders <SPAN class="operator token">=</SPAN> openURL<SPAN class="punctuation token">(</SPAN>folderURL<SPAN class="punctuation token">,</SPAN>adminParams<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'services'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token">#Loops through services in folders</SPAN> <SPAN class="keyword token">for</SPAN> service <SPAN class="keyword token">in</SPAN> servicesInFolders<SPAN class="punctuation token">:</SPAN> serviceName <SPAN class="operator token">=</SPAN> service<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'serviceName'</SPAN><SPAN class="punctuation token">]</SPAN> serviceType <SPAN class="operator token">=</SPAN> service<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'type'</SPAN><SPAN class="punctuation token">]</SPAN> serviceURL <SPAN class="operator token">=</SPAN> <SPAN class="string token">"{0}/{1}/{2}.{3}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>rootServicesURL<SPAN class="punctuation token">,</SPAN>folder<SPAN class="punctuation token">,</SPAN>serviceName<SPAN class="punctuation token">,</SPAN>serviceType<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Gets service information</SPAN> serviceInfo <SPAN class="operator token">=</SPAN> openURL<SPAN class="punctuation token">(</SPAN>serviceURL<SPAN class="punctuation token">,</SPAN>adminParams<SPAN class="punctuation token">)</SPAN> minInstances <SPAN class="operator token">=</SPAN> serviceInfo<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'minInstancesPerNode'</SPAN><SPAN class="punctuation token">]</SPAN> maxInstances <SPAN class="operator token">=</SPAN> serviceInfo<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'maxInstancesPerNode'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token">#Adds min/max instances to counters</SPAN> totalMinInstances <SPAN class="operator token">+=</SPAN> minInstances totalMaxInstances <SPAN class="operator token">+=</SPAN> maxInstances <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Service {0}/{1} is configured with {2} min instances and {3} max instances."</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN> serviceName<SPAN class="punctuation token">,</SPAN>minInstances<SPAN class="punctuation token">,</SPAN> maxInstances<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Returns min/max instances.</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Total minimum instances: {0}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>totalMinInstances<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Total maximum instances: {0}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>totalMaxInstances<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Thanks for your answer,
I tried to add the previous code in a python, but when I tried to open it it fails to work.
I couldn’t figure out what is the reason for that.
What do you think?
Without any information about the error, it's impossible to provide assistance.
Many thanks for your answer.
Kindly find the following screenshots.
The variables on line 6, 7, and 8 are simply place holders. Replace them with the appropriate information for your Server.
I got the same error even though I entered the specific variable
If you can reach what you entered for the baseURL in a browser on the machine you're running the script, there shouldn't be a reason why you see the getaddrinfo error in Python. That error simply means the host can't be found.
Jonathan Quinn script.
Find the out put like
Total minimum instances: ****---countTotal maximum instances: ***--count
https://community.esri.com/docs/DOC-9922/edit?draftID=328241
Jonathan_Avinash.zip
Are you able to execute this?
Thanks for your effort, actually I couldn’t access the above link. Attached
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.