Welcome to ESRI Blogs

Monitoring your services with a script

Paul Dodd of ESRI Technical Marketing recently posted a utility on ArcScripts that monitors your critical services and will e-mail you if a service goes offline.

The Service Monitor script uses a combination of public-domain/freeware utilities and a configuration file in which you list the services you want to be monitored. With minimal effort, you can schedule the Service Monitor to run using the Windows Scheduler.

You can:

  • Specify the URL for a service WSDL or web site to monitor (even include user authentication if needed)
  • Specify a day of the week or time window for maintenance of a service
  • Specify days of the week that you don't want the service to be monitored
  • Specify e-mail recipients for each service or a group of services

Optionally you can override other script defaults like:

  • Retry limits, retry delay, and send e-mail limits
  • E-mail Subject line and From origin
  • E-mail server
  • Log file location
Published Thursday, November 29, 2007 9:04 AM by sterlingdq

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Monitoring your services with a script

Can this work if the email server needs credentials?
Thursday, November 29, 2007 1:43 PM by Steve

# re: Monitoring your services with a script

Is this trying to send mail on port 25? Email sending isn't working for me. The log is empty also so... not sure where to begin.
Thursday, November 29, 2007 2:03 PM by steve

# re: Monitoring your services with a script

Some comments from Paul on the e-mail questions:

I haven't specifically provided a parameter setting for this, but you could do the following:

- Alter the 'set EmailServer=<mySMTPserverName> -u <myUserName> -pw <myPassword>'

The above would add the optional Blat '-u' (user) and '-pw' (password) parameters to the call of the Blat.exe e-mail utility. See 'Blat -h' for full details and usage.

Version 1.2 includes an E-mail specific log file that records the e-mail transfer attempts. The default filename for this is ServiceMonitor_Email_Log.txt. Check this file for any details.

Thursday, November 29, 2007 3:28 PM by sterlingdq

# re: Monitoring your services with a script

I don't get it work very well. In my log:(Is it normal? Or I have not set the parameter correctly. Waiting for your help!) Service Monitor v1.2 Started: 2007-11-30 Friday 14:31:53.29 --------------------------------------------------------- * ERROR: Service 1 inaccessible after 3 Retries! 'http://grace/' * Error: Failed to access Service 'http://grace/'! * Reached Daily limit, E-mail process skipped! Processed 3 Services, Excluded 0, 1 errors!
Thursday, November 29, 2007 10:37 PM by Grace

# re: Monitoring your services with a script

Ours is working also. Grace you need to change this setting set EmailLimitToday=3 set EmailLimitConsecutive=1
Friday, November 30, 2007 9:18 AM by steve

# re: Monitoring your services with a script

Can this check ArcGIS Server Mapservices? When I shutdown ArcGIS Server Object Manager service, no errors are reported. The web page reports an error, but the monitor indicates all is well.
Tuesday, December 04, 2007 12:47 PM by tim

# re: Monitoring your services with a script

The error from the web page is expected. When the ArcGIS Server Object Manager Service is shut down, it should in turn, kill all ArcGIS Server SOCs, rendering the WSDL end-points inaccessible.You should receive a "404 Not Found" error on the URL.

If you in fact received a 404 not found message, check the logs and configuration of the ServiceMonitor. Do you have a MaintWindows or MaintTimes setting affecting this?

Wednesday, December 05, 2007 9:30 AM by sterlingdq

# re: Monitoring your services with a script

I guess I'm not clear on the WSDL. If I had a map service called RealProperty, my WSDL service URL would like "http://server01/arcgis/services/RealProperty?wsdl"? I'm not receiving 404 errors...
Wednesday, December 05, 2007 1:31 PM by tim

# re: Monitoring your services with a script

Tim- The URL would be http://server01/arcgis/services/RealProperty/MapServer?wsdl

Entering this in a browser should normally return some XML showing what methods could be called on the map service. If you see that, you know that your service is running.

-Sterling

Wednesday, December 05, 2007 1:41 PM by sterlingdq

# re: Monitoring your services with a script

I get user authentication errors. Is there a way to use Windows credentials rather than clear text passwords?
Wednesday, December 05, 2007 1:57 PM by tim

# re: Monitoring your services with a script

Tim, Unfortunately, not out of the box. The 'web get' utility used by this script must be provided with a user and password in order to respond to BASIC and DIGEST authentication challenges from HTTP sites (which are sent in clear text format). 'Web get' cannot directly respond to NTLM authentication requests, but if this is a requirement, consider using a NTLM Authentication Proxy to handle this for 'web get'. Ref: http://www.webhackingexposed.com/ntlm-aps.html.

If you want to simply hide the user and password from prying eyes, you could:

- Create a text password file in a secure location on your system that includes:
'user = <my user name>'
'password = <my user password>'

Note * make sure that the user launching the Windows Scheduled Task has access to this file as well.

- Include the following parameter in the ServiceMonitor service configuration file:
'set WGETRC= <path and name of password file>'

Note * you can use a different file for each URL if needed. Just add a 'set WGETRC...' entry with the appropriate file before the URL (or group of URLs) to be checked in the service configuration file.

This will cause 'web get' to read the configuration file and apply the user and password provided when an authentication challenge is presented.

Paul

Friday, December 07, 2007 11:23 AM by Paul Dodd

# re: Monitoring your services with a script

I keep getting an error from blat regarding the sender's address/name being incorrect. I have tried to modify the set From= setting but it doesn't seem to help. The error is below. Any ideas what I need to configure?

2008.01.10 15:13:35 (Thu)------------Start of Session-----------------

Blat v2.6.2 w/GSS encryption (build : Feb 25 2007 12:06:19)

2008.01.10 15:13:38 (Thu): Sending ServiceMonitor.bdy to dbutz@davisdemographics.com

2008.01.10 15:13:38 (Thu): Subject: Alert: Service Monitor - Service Failure Detected!

2008.01.10 15:13:38 (Thu): Login name is davidbutz.net@gmail.com

2008.01.10 15:13:38 (Thu): Attached text file: Log1.txt

2008.01.10 15:13:38 (Thu): The SMTP server does not like the sender name.

Have you set your mail address correctly?

2008.01.10 15:13:38 (Thu)-------------End of Session------------------

Thursday, January 10, 2008 3:29 PM by ddp_developer

# re: Monitoring your services with a script

The 'From' setting in Blat normally requires a "Known" e-mail address, one that is known to the SMTP server. Some SMTP don't require it, but this is a nice way to block Spam programs from using your e-mail servers to send e-mails. Have you tried an e-mail address known to your server? Paul
Friday, January 11, 2008 7:30 AM by Paul Dodd

# re: Monitoring your services with a script

Thanks for getting back to me Paul. Yes, actually I am using a gmail account that should be known to gmail's smtp server. I am successfully using gmail in a .Net application to send mail. I tried using the -u and -pw to authenticate with the server also but blat reported back that the server did not support such authentication so I took it out. Here is my script configuration... rem * Default E-Mail settings set FatalSubject="Alert: Service Monitor encountered problems!" set ServiceSubject="Alert: Service Monitor - Service Failure Detected!" set EmailServer=smtp.gmail.com set From=davidbutz.net@gmail.com set Recipient=dbutz@davisdemographics.com set EmailLimitToday=3 set EmailLimitConsecutive=4
Friday, January 11, 2008 9:50 AM by David

# re: Monitoring your services with a script

David, Does Gmail require a SSL connection for e-mail? Searching, I find information that using Blat with Gmail will require SSL, but Blat does not directly support SSL. You will likely require a Secure Tunnel component that provides this. Blat can then use this SSL client to access the e-mail server. This would explain why your .NET app works using the same e-mail settings. Stunnel (http://www.stunnel.org/) is a good choice for providing SSL support. Paul
Tuesday, January 15, 2008 2:01 PM by Paul Dodd

# re: Monitoring your services with a script

Hi Paul Thanks for providing the ServiceMonitor script, it has been very helpful. However, I've found that sometimes it doesn't pick up problems with some ArcGIS Server map services. More specifically, I have a web application built on the web mapping application adf template, and sometimes when one of the map services it uses fails to return a map it displays a 'Map service unavailable' message in grey. When this happens, the service monitor script reports that the map service is running OK. Can you think of a way of picking up this type of service 'unavailability'? Thanks in advance, Andrew
Thursday, May 22, 2008 9:33 PM by Andrew

# re: Monitoring your services with a script

Hi Andrew,

Looking closely at the issue you described, I see that retrieving a Map image from an ArcGIS Server MapService requires sending a Serialized object to the Service in order to provide the details required to generate the map. Currently, the ServiceMonitor is not capable of doing this without assistance from an external routine.

So, I recently released an update, ServiceMonitor v1.4, that allows for external User defined routines. If the external routine were to request a map and then receive an empty image, it could set the exit flag to reflect a value greater than zero. The ServiceMonitor can respond to this error exit and report the failure. Keep in mind that this external routine still needs to be created, but this should open the door for a detection method.

Along with this enhancement, the new ServiceMonitor supports nested If-Else-Endif conditions, parameter value stacks using PUSH and POP functions, a new User’s Guide build with MHTML, and many more features.

I hope this helps, Paul

Friday, July 11, 2008 11:26 AM by paul2221

# re: Monitoring your services with a script

I came up with a script that may also help to monitor ArcGIS services. I'd be interested in some feedback.

MapServerMonitor-0.1:

http://arcscripts.esri.com/details.asp?dbid=16602

Thanks,

Allan Adair

Monday, October 05, 2009 12:23 PM by ama054000

Leave a Comment

(required) 
required 
(required)