Occasionally, but all too often unfortunately, my AGS services just stop for no reason. I don't usually notice this until the users call me and ask why their maps have no data.

Is there any way (I was thinking Python) that I can get a response from AGS when services stop? How do other AGS users deal with this problem?

  • This is possible using ArcPy for ArcGIS Server (version 10.1). I am working on this issue on my side .For more help please check resources.arcgis.com/en/help/main/10.1/index.html#//… and let you know when the things will be perfect on my side : ) – Sunil Jun 21 '13 at 11:10
  • + 1 Do you need this for all services or specific services ? + Download ArcGIS Admin API for more details – Sunil Jun 21 '13 at 11:11
  • I need it for all services really...but some are more important than others because some services deliver data to clients, and others are for internal use. – Robert Buckley Jun 21 '13 at 17:56
  • In such situation, what will be the purpose of Recycling or health check setting of any service? – Deep Oct 1 '15 at 15:07

I have solved the same problem and I have this solution. I writed in Python this code below ("localhost" in URL change to name of your AGS server):

# -*- coding: cp1250 -*-
import smtplib, urllib

from email import Encoders
from email.MIMEBase import MIMEBase
from email.MIMEMultipart import MIMEMultipart
from email.Utils import formatdate
from email.MIMEText import MIMEText
from email.MIMEMessage import MIMEMessage

SERVER = "IP adresss of post server"
FROM = "email adress from"
TO = ['1.email adress to','2.email adress to']

SUBJECT = "Some services on ArcGIS Server are down"

ServicesDown = []
TEXT="No problem"

# 1. Service - mapservice1
print "Test of service - mapservice1"
opener = urllib.FancyURLopener({})

f = opener.open("http://"localhost"/arcgis/rest/services/mapservice1/MapServer?wsdl")
code = urllib.urlopen("http://"localhost"/arcgis/rest/services/mapservice1/MapServer?wsdl"?wsdl").getcode()

if code is not 200:
    print "code: ", code
    print "mapservice1 is down"
    print "service is OK"

# 2. Service - mapservice2
print "Test of service - mapservice2"
opener = urllib.FancyURLopener({})

f = opener.open("http://"localhost"/arcgis/rest/services/mapservice2/MapServer?wsdl")
code = urllib.urlopen("http://"localhost"/arcgis/rest/services/mapservice2/MapServer?wsdl"?wsdl").getcode()

if code is not 200:
    print "code: ", code
    print "mapservice1 is down"
    print "service is OK"

print "\r\n"+"ServicesDown: ",ServicesDown
print "CountOfServicesDown= ",CountOfServicesDown

if CountOfServicesDown > 0:
    TEXT = "There are down this services: "+str(ServicesDown[:CountOfServicesDown])
    print "TEXT: ", TEXT

    # Prepare actual message

    message = """\
From: %s
To: %s
Subject: %s

""" % (FROM, ", ".join(TO), SUBJECT, TEXT)

    server = smtplib.SMTP(SERVER)
    server.sendmail(FROM, TO, message)
    print "\r\n"+"Email was send"

    print "\r\n"+"There is no problem on AGS services" 
  • Hi- Will it be possible to add the final log for the stopped service? – Deep Oct 1 '15 at 16:41

I would take a look at the ArcGIS Server Admin REST API for this.

It looks like you could write a python script that runs on and schedule it to run periodically. The script would get all services in a cluster, then to see if the service of interest is present, and if so check its status.

Otherwise, email a notification.

The script could also (re)start the service, if you wanted.

I'm not sure, but the ArcPy admin package admin might provide a way to work with this API.

  • Thanks Kirk....I´ll have a look at that. That seems like a logical way to go about it. – Robert Buckley Jun 29 '13 at 12:46

We currently use this ServiceMonitor batch script, which does email notifications. We set it up as a Windows scheduled task so it runs every morning.

The only downside is that it takes quite a while to run since we have a large number of services, so we can't run it as often as we'd like. Maybe the Admin REST API or ArcPy would be quicker.

  • It seems as this works only on 10.0? Just curious if you use 10.1/10.2 and made it work for you. – Alex Tereshenkov Nov 17 '13 at 7:49
  • 1
    I ran it briefly on 10.2 and it seemed to work okay, but we ran into other issues with our 10.2 server so I haven't tested it very extensively. I haven't tested it with 10.1 at all, but it should work on any version since it's basically just checking to see that the WSDL for each service is reachable. – mrohlf Nov 18 '13 at 4:19
  • I see, thank you for the info. If you ever get a chance to try Esri's Service Monitor (released just some months ago), I think it would suit your needs really well (arcgis.com/home/item.html?id=848f48b0f88e4de7a036377197453efe). Here are some other useful resources - gis.stackexchange.com/questions/73863/… – Alex Tereshenkov Nov 18 '13 at 7:56
  • Wow, that looks really useful -- thanks! The dynamic service discovery and monitoring sounds perfect for what we need. – mrohlf Nov 18 '13 at 19:37

In free time I worked on a Python script that generates a web request to the ArcGIS server REST url and evaluates the response of the service. If the answer is negative will be sent an email alert to a specific e-mail address.

I think it is simple but useful for monitoring individual services of ArcGIS Server. I hope that is helpful for someone.

All info in our blog: http://oneteamgis.wordpress.com/2014/03/24/uno-script-python-che-monitora-i-servizi-di-arcgis-server/


  • The blog post is no longer online, unfortunately. – Erica Jan 21 '19 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.