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")
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 = "http://UAGServer02.contoso.com:50002/SessionMonitorDataBuilder.asp"
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"
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”.