My first overview of a syncmap pattern is at (Six Location SyncMap Patterns) https://communities.bmc.com/docs/DOC-111501.
I will focus on the Traversal of this pattern, so maybe consider this Lesson #2.
The explanation for Traversal (section B) is longer than I expected.
A. This is more of the same, but with a little variation.
// This pattern is in the public domain.
tpl 1.5 module CMDB.Extension.Host_UpTime;
origin := "COMPANY";
tree_path := "COMPANY", "CMDB Sync", "Host", "UpTime";
from CMDB.Host_ComputerSystem import Host_ComputerSystem 2.0;
syncmapping Host_UpTime 1.0
Add one or more new attributes to the BMC_ComputerSystem CI, based
on attributes in the BMC Discovery Host node.
tags CMDB, Extension, BootTime, UpTime;
B. The traversal.
First, we create two aliases that are used in section C.
“host” is an alias for a module that we imported in section A. (from A import B x.y)
“hostinfo” is an alias for the traversal, but how do we know this is what we need?
Now we get to the second point of section B, we identify the necessary traversal.
Someone asked for boot time and/or uptime for hosts, and this seems like a reasonable thing to discover. Go to Administration > Taxonomy and search for “boot time,” “uptime,” and variations of these in the page. I found “uptime,” but not “boot time.” (More on boot time later.)
For now, “uptime” is an attribute under HostInfo. (1st screenshot.)
Next step is to create a temporary report. Go to Explore > Data > Hosts & Containers > Hosts, then select the +Customize button. Our report label says “Host List” and we want attributes from HostInfo.
The default customization tab is Customize Columns, and this is what we want. Scroll down until you see Relationships. HostInfo is hidden by default, so choose “show all.” (2nd screenshot.)
Scroll down, find “Host Info: HostInfo of this Host”, select it, and choose “show all.” (3rd screenshot.)
The default list of attributes seems to be in order of popularity or relative importance. Choosing “select all” changes the list to alphabetical. (4th screenshot.) We see that Boot Time is available, even though it is missing from the Taxonomy page. Select this column so it is added to the report.
Select the columns Uptime Days and Uptime Seconds (5th screenshot) and select “Refresh results.”
Here is my Raw Query (the 3rd tab when you customize a report) ...
search Host show name, os,
#InferredElement:Inference:Primary:HostInfo.boot_time as 'Boot Time',
#InferredElement:Inference:Primary:HostInfo.uptime as 'Uptime Days',
#InferredElement:Inference:Primary:HostInfo.uptimeSeconds as 'Uptime Seconds'
Here is the traversal that we need ... #InferredElement:Inference:Primary:HostInfo
The traversed HostInfo has three attributes. Pay attention to correct spelling and the only time an attribute contains an upper-case letter ... uptimeSeconds.
mapping from Host_ComputerSystem.host as host
traverse InferredElement:Inference:Primary:HostInfo as hostinfo
activity -> BMC_Activity;
computersystem := Host_ComputerSystem.computersystem;
for each hostinfo do
if host.key then
key := host.key;
key := host.name;
// End of traversal explanation. //
C. Sending info to Remedy.
We use both aliases (host and hostinfo) that we created in section B.
We can send attributes, strings, and combinations of these to Remedy.
I’ll use the Name entry for examples.
attribute Name := host.name
string Name := "uptime"
string & attribute Name := "uptime on %host.name%"
Windows servers provide both uptime and boot time. Unix/Linux servers only provide uptime. Uptime days is available, but I chose uptime seconds instead.
Feel free to change Category, Type, Item and Model. You can also omit Model if you want.
I looked through all the BMC_* classes and BMC_Activity seemed the best choice.
activity := sync.BMC_Activity(
key := key,
Name := "uptime on %host.name%",
Description := "uptime seconds is %hostinfo.uptimeSeconds%",
ShortDescription := "boot time is %hostinfo.boot_time%",
Category := "Hardware",
Type := "Host",
Item := "UpTime",
Model := "Host UpTime"
Source := computersystem,
Destination := activity,
Name := "UPTIME"