I have 80 services which are hardly used. I want to set the pooling parameter to Min=0 and Max=2 for all services using a batch script. Would anyone know how to do this?
You could edit this script to loop through your services. Example Edit Service Properties
This is exactly the script that I have been trying to adapt. I can't seem to find one which loops through an AGS Folder though.
Use the python API.
https://developers.arcgis.com/python/api-reference/arcgis.gis.server.html#service
Specifically an edit operation against the GIS admin service object. You would parse back the exact same JSON properties with your edits to minInstancePerNode and maxInstancePerNode.
https://developers.arcgis.com/python/guide/managing-your-gis-servers/#Administering-services
Here is the section of the guide that introduces the object.
Add a for loop like in this script. Example Stop or Start All Services in a folder
This is my script ...but the properties do not get changed. Anyone know why?
# For Http callsimport httplib, urllib, json
# For system toolsimport sys
# For reading passwords without echoingimport getpass
# Defines the entry point into the scriptdef main(argv=None):# Print some infoprintprint "This tool is a sample script"print# Ask for admin/publisher user name and passwordusername = "xyz"password = "xyz"# Ask for server nameserverName = "xyz"serverPort = 6080
folder = 'Geobasisdaten'# Get a tokentoken = getToken(username, password, serverName, serverPort)if token == "":print "Could not generate a token with the username and password provided."returnfolderURL = "/arcgis/admin/services/commandx/"# This request only needs the token and the response formatting parameterparams = urllib.urlencode({'token': token, 'f': 'json'})headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}# Connect to URL and post parametershttpConn = httplib.HTTPConnection(serverName, serverPort)httpConn.request("POST", folderURL, params, headers)# Read responseresponse = httpConn.getresponse()if (response.status != 200):httpConn.close()print "Could not read folder information."returnelse:data = response.read()# Check that data returned is not an error objectif not assertJsonSuccess(data):print "Error when reading folder information. " + str(data)else:print "Processed folder information successfully. Now processing services..."
# Deserialize response into Python objectdataObj = json.loads(data)httpConn.close()
# Loop through each service in the folder and stop or start itfor item in dataObj['services']:
# Edit desired properties of the servicedataObj["minInstancesPerNode"] = 0dataObj["maxInstancesPerNode"] = 2
# Serialize back into JSONupdatedSvcJson = json.dumps(dataObj)
# Call the edit operation on the service. Pass in modified JSON.editSvcURL = folderURL + str(item["serviceName"])+ ".MapServer" + "/edit"print editSvcURLparams = urllib.urlencode({'token': token, 'f': 'json', 'service': updatedSvcJson})httpConn.request("POST", editSvcURL, params, headers)# Read service edit responseeditResponse = httpConn.getresponse()if (editResponse.status != 200):httpConn.close()print "Error while executing edit."returnelse:editData = editResponse.read()# Check that data returned is not an error objectif not assertJsonSuccess(editData):print "Error returned while editing service" + str(editData)else:print "Service edited successfully."
httpConn.close()return
# A function to generate a token given username, password and the adminURL.def getToken(username, password, serverName, serverPort):# Token URL is typically http://server[:port]/arcgis/admin/generateTokentokenURL = "/arcgis/admin/generateToken"params = urllib.urlencode({'username': username, 'password': password, 'client': 'requestip', 'f': 'json'})headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}# Connect to URL and post parametershttpConn = httplib.HTTPConnection(serverName, serverPort)httpConn.request("POST", tokenURL, params, headers)# Read responseresponse = httpConn.getresponse()if (response.status != 200):httpConn.close()print "Error while fetching tokens from admin URL. Please check the URL and try again."returnelse:data = response.read()httpConn.close()# Check that data returned is not an error objectif not assertJsonSuccess(data):return# Extract the token from ittoken = json.loads(data)return token['token']
# A function that checks that the input JSON object# is not an error object.def assertJsonSuccess(data):obj = json.loads(data)if 'status' in obj and obj['status'] == "error":print "Error: JSON object returns an error. " + str(obj)return Falseelse:return True# Script startif __name__ == "__main__":sys.exit(main(sys.argv[1:]))
Hello,
Somewhat off topic but I'll share for your consideration anyway. If your version of ArcGIS Enterprise supports shared instances, suggest changing all your infrequently used services from dedicated to shared pool. In our Enterprise this has improved overall computing resource utilization at the cost of supporting a few ArcSOC processes that are fairly large resource consumers. The major benefit has been an overall reduction in the number of ArcSOC processes running and the ability to host more services without running up against heap space limits in the Windows OS.
Now a question: Who has a script to change existing dedicated service to shared pool.
Todd
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.