It’s been a while since the last post, but I wanted to share this pearl in RESAM I came across today with regard to the dispatcher discovery process. There are three settings which dictate the agent’s behaviour, but it is more involved than just three switches. As there is only a pdf “instant report” available from the RES console I went down the rabbit hole again to create something more useful.
The settings, and their possible options are:
Dispatcher Discovery
Autodetect
Use Dispatcher address list
Use Dispatcher address list but try autodetect first
Dispatcher locations
Retrieve complete Dispatcher list after discovery
Only use discovered dispatchers
Dispatcher recovery
Retry discovery
Revert to cached list of all known dispatchers
All of these can be set at the Agent, Team or Global level. The order of inheritance is, as with all settings and variables, Global -> Primary Team -> Agent. The only way to export this information from the console is by creating an instant report which looks like this:
As we are now used to, the settings are all stored in binary xml snippets and luckily with a bit of variety to keep it interesting. To sanitize the queries somewhat I use the following function to grab that xml out of the binary field(s):
Global settings are stored in the imgData1 column of the tblSettings WHERE lngSetting = 13 table/row. We can pull them out once and store them as a variable to use in our query later on. When global settings are not explicitly set, they are omitted from the xml which results in a default value. After you set them however and revert back to the default, there is something in there. A typical snippet looks like this:
So the first confusing thing is that all three settings (discovery, locations and recovery) are stored under a tag called “dispatcherlocation” while in the GUI it is called “Dispatcher Detection”. In the snippet above there is no <retrievecompletelist> element, meaning it has a default value in this case “yes”.
Team settings are stored in the imgSettings column of the tblTeams table. The XML is more or less the same, only containing values when explicitly set once, otherwise reverting to default. There is however an additional attribute “useglobalsettings” which indicates wether or not the setting is inherited from the Global value (the “Inherit from Global” checkbox in the GUI). This attribute is only used on the <retrievecompletelist> and <autodetect> elements, the <recovery> element can be either GLOBAL, RETRY or CACHEDLIST and if it is missing, it is GLOBAL by default. Which does not actually mean global, it means inherit. Got it?
For the agents we need to look at the imgProperties column in the tblAgents table. Same weirdness applies, and I noticed that the agents store certain values in CAPITALS where the team stores it in lowercase. So to recap:
3 settings in 4 fields
Inconsistent naming between GUI and DB
Inconsistent naming of db columns
NULL checking for default values
Inheritance setting by value OR by attribute
Inconsistent capitalization
So how do we get some usable data out of this? lots of horrible T-SQL that’s how! I cobbled this together - as always use at your own risk, or someone else’s for that matter as long as it is not mine :)
Now there is an awful lot of code duplication there. It might be possible to abstract some of it away, optimize it a bit but unfortunately I have to run this on an old version of SQL server which does not have fancy stuff like IIF. Besides I am glad this monster works and will gladly not look much longer at the RESAM innards. The query gives me the following results for my test environment:
Agent
Source-Discovery
Autodetect
Dispatchers
FirstTryAutoDetect
Source-Locations
RetrieveCompleteList
Source-Recovery
Recovery
OC6252136410
Global
no
W2K3-TEST-01;WIN-TTDNUBI9TNA
no
Global
yes
Global
RETRY
W2K3-TEST-01
Agent
yes
W2K3-TEST-01;WIN-TTDNUBI9TNA
NO
Global
yes
Global
RETRY
WIN-TTDNUBI9TNA
Agent
no
W2K3-TEST-01;WIN-TTDNUBI9TNA
yes
Agent
yes
Global
RETRY
I have purposefully split the “autodetect” and “dispatcher list” into separate fields so it is possible to filter and sort on them. To verify the results, this is the overview of the agent settings in the console:
Now why does it say Global as source in my query results where it says Team in the console? It was the final confusion of the day. It is because the console states the source as Team whenever there is a primary team set for an agent, even though that team is set to inherit the global value. Now that is not incorrect per se, it’s just incomplete. And stupid.