OnServer - See what feeds your map services.
OnServer shows you the MXD used to create each of the map services on an ArcGIS Server installation, and the data sources that feed them.
OnServer also allows you to pass a search term on the command line, narrowing the returned results.
onserver.py
usage: Find a featureclass, database, mxd, or service in ArcGIS Server
[-h] [-q] [-qq] [-cs] [-csv] [-md] [name]
positional arguments:
name string for which to search (blank returns info on all
services)
optional arguments:
-h, --help show this help message and exit
-q, --quiet only display service names and URLs
-qq, --veryquiet only display service URLs, comma delimited
-cs, --configstore specify a path path to a configuration store, such as \\server\share\directories\arcgissystem\arcgisinput
-csv, --tocsv display output as comma-separated values
-md, --markdown display output as Markdown
For search strings inlcuding spaces, enclose the query in double-quotes
For Example:
C:\>onserver.py noticeme
(find all map services, MXDs, or data sources / feature classes with noticeme as a substring)
C:\>onserver.py noticeme_layers
(get info about any map service(s) named noticeme_layers)
C:\>onserver.py council_nm
(find all map services that reference any copy of the council_nm feature class)
C:\>onserver.py noticeme_layers.gdb
(find all map services that use anything in a particular GDB)
OnServer has three primary use cases at the City of New Orleans: information, automation, and restoration.
The most common usage of OnServer is to find the data sources that feed a particular map service:
C:\>onserver.py noticeme_layers
NoticeMe_Layers (apps/NoticeMe_Layers)
--------------------------------------
D:\MXD\NoticeMe_Layers.mxd
- D:\data\geodatabase\NoticeMe_Layers.gdb
+ council_nm
+ srno_nm
etc.
OnServer gives you a pretty detailed run-down of the data sources and MXD used to create each map service it finds that matches your search term.
Sometimes, though, you want to run the reverse search; which map services use a particular feature class:
C:\>onserver.py council_nm
NoticeMe_Layers (Staging/NoticeMe_Layers)
-----------------------------------------
D:\MXD\NoticeMe_Layers.mxd
- D:\data\geodatabase\NoticeMe_Layers.gdb
+ council_nm
+ srno_nm
NoticeMe_Layers (apps/NoticeMe_Layers)
--------------------------------------
D:\MXD\NoticeMe_Layers.mxd
- D:\data\geodatabase\NoticeMe_Layers.gdb
+ council_nm
+ srno_nm
etc.
For commonly used feature classes (think parcels or addresses), this can give a pretty long list, so you can use the --quiet
option:
C:\>onserver.py --quiet council_nm
NoticeMe_Layers (apps/NoticeMe_Layers)
WhereYat (apps/WhereYat)
NoticeMe_Layers (Staging/NoticeMe_Layers)
WhereYatPresentation (dev/WhereYatPresentation)
to get a brief listing of the map services and the web path to the map services. You can then use repeated calls to OnServer to drill down into those map services and get the information you need.
OnServer output can very easily be piped to a file.
Pipe stdout to a text file:
C:\>onserver.py > output.txt
Pipe CSV output to a file:
C:\>onserver.py -csv > output.csv
Create Markdown output and pipe it to a file:
C:\>onserver.py -md > output.md
The second most common use case is automation. There are occasions where an often-updated file geodatabase needs to be compacted to prevent it from filling the hard drive on the server (most often when you update feature classes very frequently using truncate/append).
You can use the --veryquiet
option to list just the map service paths (one per line) that match the search term:
C:\>onserver.py --veryquiet NoticeMe_Layers.gdb
dev/WhereYatPresentation
Staging/NoticeMe_Layers
Staging/CEPMap
apps/NoticeMe_Layers
apps/CEPMap
apps/WhereYat
The included stop_services.cmd
and start_services.cmd
tools (discussed below) use this option. Using those tools, models saved as Python scripts, and some batch file magic, you can automate tasks that would otherwise be onerous to do by hand.
Sometimes, it's handy to be able to rebuild a bunch of map services automatically, whether due to upgrade, migration, or other less pleasant occurences.
The full listing of map services, MXDs and data sources generated by OnServer can be easily saved to a file for later use:
C:\>onserver.py > C:\data\map_services.txt
In fact, running this periodically and saving the output was really useful after a nasty server crash.
Using the included make_many
tools (discussed below) with an archived copy of the OnServer output you can quickly rebuild (most) of your map services automatically.
Coming Soon: Discussion of make_many
, stop_services.cmd
, and start_services.cmd
.
- ArcGIS for Server 10.1/10.2/10.3/10.4 (Windows only, currently)
- Python 2.7
Currently only works with the Windows version of ArcGIS Server, as I don't have a Linux install to test against.
Copyright 2016 City of New Orleans