I want to include AGS memory use in System Monitor but the way each service spins up its own thread makes measuring it a bit tricky since the memory load is spread out. Currently on AGS 10.2.2 but will shortly be updating to 10.5 if that makes a difference.
You can run a .bat file that runs the TASKLIST command and provide a filter to find all ArcSOC.exe processes as well as javaw.exe processes:
Ex of ArcSOC.exe
TASKLIST /M /FI "Imagename eq ArcSOC.exe"
You can probably parse the output through the command prompt, or write the response to disk and parse it there.
JQuinn-esristaff , if I used the /M (or /m) it only returned the Image Name, Pid, and Modules (which showed N/A for all). If I left the /M off, it showed me memory used. Any simple way to tie this back to the service, as I assume Chris is asking? My apology that is not what is being asked...not trying hijack this thread, but this would be handy for me too. Any other admin tools for this??
I just finished writing a small script that lets me add the metric. I took the System Monitor help doc advice and instead of setting up a collector for this I'm grabbing the value with a python script and putting it into a table in a database which is queried like anything else from a database in SM. I made a table that isnt part of the geodatabase in our production environment and then execute the tasklist for ArcSOC and javaw on the two servers in our publication environment. That is returned as text so I broke it down to an integer to stick in the database. The table in the database is called SERVERMONITORMETRICS and has two columns, COUNTER and VALUE. pypyodbc updates the corresponding rows in the database and SM grabs those values. Windows Task Scheduler has the script run every 5 minutes. Might be an easier way to do it but this works for me.
<SPAN class="keyword token">import</SPAN> pypyodbc<SPAN class="punctuation token">,</SPAN> subprocess PUBAGSMEMORY <SPAN class="operator token">=</SPAN> sum<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>int<SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">' '</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="operator token">-</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>replace<SPAN class="punctuation token">(</SPAN><SPAN class="string token">','</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">''</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> subprocess<SPAN class="punctuation token">.</SPAN>check_output<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'TASKLIST /s xyz.xyz.xyz.xyz /FO LIST /FI "Imagename eq ArcSOC.exe"'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'\n'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'Mem Usage:'</SPAN> <SPAN class="keyword token">in</SPAN> i<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> sum<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>int<SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">' '</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="operator token">-</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>replace<SPAN class="punctuation token">(</SPAN><SPAN class="string token">','</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">''</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> subprocess<SPAN class="punctuation token">.</SPAN>check_output<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'TASKLIST /s xyz.xyz.xyz.xyz /FO LIST /FI "Imagename eq javaw.exe"'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'\n'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'Mem Usage:'</SPAN> <SPAN class="keyword token">in</SPAN> i<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> FOAGSMEMORY <SPAN class="operator token">=</SPAN> sum<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>int<SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">' '</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="operator token">-</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>replace<SPAN class="punctuation token">(</SPAN><SPAN class="string token">','</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">''</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> subprocess<SPAN class="punctuation token">.</SPAN>check_output<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'TASKLIST /s xyz.xyz.xyz.xyz /FO LIST /FI "Imagename eq ArcSOC.exe"'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'\n'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'Mem Usage:'</SPAN> <SPAN class="keyword token">in</SPAN> i<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> sum<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>int<SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">' '</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="operator token">-</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>replace<SPAN class="punctuation token">(</SPAN><SPAN class="string token">','</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">''</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> subprocess<SPAN class="punctuation token">.</SPAN>check_output<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'TASKLIST /s xyz.xyz.xyz.xyz /FO LIST /FI "Imagename eq javaw.exe"'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'\n'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'Mem Usage:'</SPAN> <SPAN class="keyword token">in</SPAN> i<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> db <SPAN class="operator token">=</SPAN> pypyodbc<SPAN class="punctuation token">.</SPAN>connect<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Driver={SQL Server}; Server=bay-arcgis-pro; Database=sde; Uid=*****; Pwd=*****;'</SPAN><SPAN class="punctuation token">)</SPAN> cursor <SPAN class="operator token">=</SPAN> db<SPAN class="punctuation token">.</SPAN>cursor<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> query <SPAN class="operator token">=</SPAN> <SPAN class="string token">''' UPDATE sde.SERVERMONITORMETRICS SET VALUE = %s WHERE COUNTER = 'PUB AGS MEMORY' UPDATE sde.SERVERMONITORMETRICS SET VALUE = %s WHERE COUNTER = 'FO AGS MEMORY' '''</SPAN><SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>PUBAGSMEMORY<SPAN class="punctuation token">,</SPAN> FOAGSMEMORY<SPAN class="punctuation token">)</SPAN> cursor<SPAN class="punctuation token">.</SPAN>execute<SPAN class="punctuation token">(</SPAN>query<SPAN class="punctuation token">)</SPAN> cursor<SPAN class="punctuation token">.</SPAN>commit<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">del</SPAN> cursor<SPAN class="punctuation token">,</SPAN> db <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>
That command appears to require elevevated privileges to return information you need:
Non-admin
Admin (not a great screenshot given the amount of stuff returned, but the idea is that it requires Admin privileges)
Nice sample, Chris!
ahh yes, I should have guessed. I ran into that on another command when trying to find file locks. Once I opened the command window as admin, I can now seethe addition info.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.