How to monitor UAG sessions in real-time with a script.

To track the status of a UAG server, UAG provides us with the terrific Web Monitor. A common need by many companies is to be able to track various things within UAG using an external tool or script. UAGs various Web Monitor ASP pages query UAG’s COM objects to retrieve various pieces of info, and then display them onscreen for your use. However, you can query the code directly to retrieve the data by external tools.

For example, the page that displays the number of current sessions on UAG (SessionMonitor.asp) queries an ASP page called SessionMonitorDataBuilder.asp, and we can query it directly as well. In fact, you can do so from the browser itself, and it would look like this:


The value that you see above is a list of the sessions for the two existing trunks (Portal1 and Portal2ADFS), and for each we can see the number of sessions of each type. To read this value via a script and act on it, you can feed the URL directly into monitoring software, and you can also use a VBScript to read it, like this:

set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
url = http://localhost:50002/SessionMonitorDataBuilder.asp
do "GET", url, false
xmlhttp.send ""
sPage = xmlhttp.responseText
sUnauthStart = instr(sPage,"<END_AUTH>")+10
sUnautnEnd = instr(sUnauthStart,sPage,"<")
sUnauthNum = mid(sPage,sUnauthStart, sUnautnEnd –sUnauthStart
if sUnAuthnum > 10000 then
            ‘perform action
end if
wscript.sleep 5000

The above script runs in a loop, every 5 seconds (5000 Milliseconds) and extracts the number of unauthenticated sessions. If that number is above 10,000, it can perform a certain action. Note, though, that like the Web Monitor page, this queries only one specific UAG server, so if you have an array, you need to query each of them separately. To do so, simply change the URL to point to another UAG, like this:

url = ""

What action you perform is up to you, of course. You can use wscript.echo to simply show some text on-screen. You can also use the CDO.Message COM object to send an email or SMS. Another option is to use the FileSystemObject COM object to store this in some file. You can even run a function to restart the UAG UserMgrCom service (which would kill all sessions):

strServiceName = "UserMgrCom"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name ='" & strServiceName & "'")
For Each objService in colListOfServices

The possibilities are endless, of course. Just make sure to properly test whatever conditions you specify in your script, so that you don’t jeopardize the stability of your UAG by your own “action”.

Comments (1)

  1. showbox says:

    Thanks for the great info. I really loved this. I would like to apprentice at the same time as you amend your web site, how could i subscribe for a blog site?
    For more info on showbox please refer below sites:
    Latest version of Showbox App download for all android smart phones and tablets. – It’s just 2 MB file you can easily get it on your android device without much trouble. Showbox app was well designed application for android to watch movies and TV shows, Cartoons and many more such things on your smartphone.
    For showbox on iOS (iPhone/iPad), please read below articles:
    Showbox for PC articles:
    There are countless for PC clients as it is essentially easy to understand, simple to introduce, gives continuous administration, effectively reasonable. it is accessible at completely free of expense i.e., there will be no establishment charges and after establishment
    it doesn’t charge cash for watching films and recordings. Not simply watching, it likewise offers alternative to download recordings and motion pictures. The accompanying are the strides that are to be taken after to introduce Showbox application on Android.
    The above all else thing to be done is, go to the Security Settings on your Android telephone, Scroll down and tap on ‘Obscure sources’.

Skip to main content