Monad (PowerShell) functions for simple monitoring of current TFVC server requests

This isn't exposed via our object model, but we have a couple of web methods exposed via VersionControl/v1.0/Administration.asmx that give you the current requests, optionally with the details of the request (QueryServerRequests, QueryServerRequestsWithDetails).

Using Monad's built-in xml adaptor, we can still leverage these calls.  Here's a few simple functions for monitoring what's currently going on with the TFVC server.

If you want to be able to run these against your TFVC server on a machine other than the server itself, you'll need to edit the file [TF Server Install Dir]\Web Services\web.config and in the webServices section change the 2 "remove" strings to "add" to allow post/get access (well, at least the HttpGet one).

In each of the functions, I used the full name to help make it clear what's going on (format-table instead of ft, clear-host instead of clear, start-sleep instead of sleep, etc.).

Caveat: there's likely a better way to do this - I just needed something quick.

function requests_raw
   param ([string]$server = "localhost")

   $wc = new-object System.Net.WebClient
   $wc.Credentials = [System.Net.CredentialCache]::DefaultCredentials
   $url = "http://$($server):8080/VersionControl/v1.0/administration.asmx/QueryServerRequests"
   $x = [xml]$wc.DownloadString($url)

function requests
   param ([string]$server = "localhost")

   requests_raw $server | sort -descending executiontime | format-table -auto user,webmethod,executiontime,serverprocessid

function watch_requests
   param ([string]$server = "localhost", [int]$sleep_time = 300)

   for (;;) { clear-host ; requests $server ; start-sleep $sleep_time }

Comments (5)

  1. RTerala says:


    You should try IronPython. Its way better than Monad for what you are trying to achieve. It is good enough to kill Monad. Let me know if you want to get started :).


  2. MSDN Archive says:


    I did - I started using IronPython once Jim put the bits out (I'd been using Jython for quite awhile - I wrote parts of a system at my last company in it and *really* liked it, so IronPython was logically worth checking out to access the .NET api since I hadn't really heard of IKVM at the time).  I really like it, but it's still a language first, shell second (at best, IMHO) - I even feel the same about Ruby, as much as I consider irb not to be bad at all.

    The deciding factor is Monad's provider API, which I found very approachable.  Along with the registry provider (and some others available internally), I now have the TFVC provider which makes it much simpler for me to interact with the TFVC tree in a shell-like manner without the restrictions of tf.exe's text output format, having to write C# apps for every little thing, or trying to click around the Source Control Explorer interface.

    It's always about the right tool for the job, of course.  If you want to post IronPython equivalents, I'd be happy to see it 🙂

  3. We already saw how we could use the QueryServerRequests web method to tell the calls that are actively...

Skip to main content