BMC Atrium Discovery Community Forum

forgot password?
   
1 of 2
1
SYNC only hostname instead of FQDN
Posted: 28 March 2011 11:25 AM   [ Ignore ]  
RankRank
Member
Total Posts:  15
Joined:  2009-11-03

Hey guys,

Got a bit of oddball here. I have the need to sync computersystem CI’s to the Atrium CMDB, this works wonderful from within ADDM. However ADDM syncs it with the FQDN name, i only want the hostname in the CI name field.

If I look at the mapping:

// Name
154 
155         candidates 
:= [[host.local_fqdn"DNS"]];
156 
157         
list.append(candidates[host.name"HostName"]);
158 
159         
if host.__all_dns_names then
160             
list.append(candidates[host.__all_dns_names[0]"DNS"]);
161         end if;
162 
163         
if host.__all_ip_addrs then
164             
list.append(candidates[host.__all_ip_addrs[0]"IP"]);
165         end if;
166 
167         
for item in candidates do
168             if item[0] and item[0] <> "localhost" and item[0] <> "localhost.localdomain" then
169                 cdm_name 
:= item[0];
170                 cdm_nameformat := item[1];
171                 break;
172             end if;
173         end for;
174 
175         log
.debug("%host.name%: CDM name = �m_name%");
176 
177 

If i change this line:

155         candidates := [[host.local_fqdn"DNS"]]

to

155         candidates := [[host.name"DNS"]]

Would that solve my issue?

Thanks!

Marco

(added code tags to make more readable – Charles)

[ Edited: 28 March 2011 02:21 PM by Charles Oldham]
Profile
 
 
Posted: 28 March 2011 12:31 PM   [ Ignore ]   [ # 1 ]  
BMC ADDM Staff
RankRankRankRank
Administrator
Total Posts:  127
Joined:  2008-02-14

Hi Marco,

What you suggest will work, but it is best practice to avoid changing the default mapping definitions if you possibly can, so you have an easier time during upgrades. You can change the BMC_ComputerSystem Name attribute in an extension mapping, like this:

tpl 1.5 module CMDB.NonStandard.Host_Name_Override;

from CMDB.Host_ComputerSystem import Host_ComputerSystem 1.0;

syncmapping Host_Name_Override 1.0
    
"""
    Override the default ComputerSystem Name to contain just the HostName.
    """
    
overview
        tags CMDB
NonStandard;
    
end overview;

    
mapping from Host_ComputerSystem.host as host
        
// No additional structure -- we are just modifying the
        // existing ComputerSystem CI.
    
end mapping;

    
body
        computersystem 
:= Host_ComputerSystem.computersystem;

        
computersystem.Name := computersystem.HostName;
    
end body;

end syncmapping

Hope that helps.

Duncan.

Profile
 
 
Posted: 28 March 2011 12:45 PM   [ Ignore ]   [ # 2 ]  
RankRank
Member
Total Posts:  15
Joined:  2009-11-03

That would help a lot ;-)))

Thanks!!

Marco.

Profile
 
 
Posted: 29 March 2011 06:55 AM   [ Ignore ]   [ # 3 ]  
RankRank
Member
Total Posts:  15
Joined:  2009-11-03

MMmmzzz.. it does work for some hosts…. but not all of them.

Look at this one taken from the file: tw_svc_cmdbsync_transformer

11025882242011-03-29 07:30:16,871syncmapping.CMDB.Host_Processor.Host_ProcessorINFOConstruct Processor details for host-number.domain.com
1102588224
2011-03-29 07:30:16,910cmdb_sync.handlerINFOTarget subgraph has 28 nodes53 relationships.
11025882242011-03-29 07:30:16,918cmdb_sync.handlerINFOSync to CMDB...
12219456642011-03-29 07:31:33,344cmdb_sync.handlerINFOHost node 7203c770df0d4d4b0865454c6e486f7374 synced with CMDB.
12219456642011-03-29 07:31:33,345cmdb_sync.servantsINFOQueue status0 high priority99 normal priority.
12219456642011-03-29 07:31:33,347cmdb_sync.handlerINFOSync Host node 72068563df0d4d4b0865454c6e486f7374
1221945664
2011-03-29 07:31:33,349cmdb_sync.handlerINFOBuild source subgraph
1221945664
2011-03-29 07:31:33,452cmdb_sync.handlerINFOSource subgraph has 24 nodes23 relationships.
12219456642011-03-29 07:31:33,453cmdb_sync.handlerINFOTransform subgraph with syncmapping CMDB.Host_ComputerSystem.Host_ComputerSystem 

How could i solve this with ADDM? I could create a remedy filter for this, but i rather not…

Kind regards,

Marco.

Profile
 
 
Posted: 29 March 2011 11:08 AM   [ Ignore ]   [ # 4 ]  
BMC ADDM Staff
RankRankRankRank
Administrator
Total Posts:  127
Joined:  2008-02-14

What about it doesn’t work? The log you’ve posted doesn’t say anything about it either way.

Is is that the HostName attribute is a fully qualified name? Sometimes hosts really do have a fully qualified name as their hostname. If you want to strip that off, you can use a regular expression. Something like this

if computersystem.Name has substring "." then
    
// Modify the HostName to only include content up to the first dot
    
computersystem.Name := regex.extract(computersystem.Nameregex "^[^.]*");
end if; 
Profile
 
 
Posted: 29 March 2011 02:02 PM   [ Ignore ]   [ # 5 ]  
RankRank
Member
Total Posts:  15
Joined:  2009-11-03

Thanks, that was it…

Our unix administrator did have some comments on the standard AIX platform script (since it is a AIX environment).

He states if you want the hostname command to fetch the hostname, one should always use the -s option to make sure you dont get a FQDN.

Maybe that would be a good idea to take into account with one of the next TKU’s? Updates

Thank again, your solution worked for me.

Marco

[ Edited: 30 March 2011 06:28 AM by Marco Spanhaak]
Profile
 
 
Posted: 29 March 2011 04:44 PM   [ Ignore ]   [ # 6 ]  
RankRankRankRank
Guru
Total Posts:  2740
Joined:  2008-01-25

Thanks for the feedback Marco I’ll make sure it’s passed on. Platform scripts can’t currently be updated during a TKU, they are a core release only today.

Can I ask a favour, could you ask your AIX guru if that option is available across all version of AIX? I’d hate to end up getting an error and no hostname at all.

Profile
 
 
Posted: 30 March 2011 06:54 AM   [ Ignore ]   [ # 7 ]  
RankRank
Member
Total Posts:  15
Joined:  2009-11-03

Hey Charles,

Here is the feedback from our AIX guru:

Hi,

I have checked the following AIX versions (which span the last 10-15 years) :-
6.1
5.3
4.3

and all support the hostname -s command, so I expect that it will work everywhere, I don’t have access to AIX7, but don’t expect it will have changed

Thanks!

Marco

Profile
 
 
Posted: 30 March 2011 10:22 AM   [ Ignore ]   [ # 8 ]  
BMC ADDM Staff
RankRankRankRank
Administrator
Total Posts:  127
Joined:  2008-02-14

Unfortunately, some of our customers have machines where the unqualified part of the name overlaps with other machines, and the full name from hostname is required. There’s no easy way out that copes with those situations, and gives a simple name where it would be preferred. That’s why our discovery scripts do not use hostname -s or equivalent.

What we have contemplated doing is stripping the trailing parts of the hostname if it exactly matches the domain name. Would that work for you?

Profile
 
 
Posted: 30 March 2011 10:56 AM   [ Ignore ]   [ # 9 ]  
RankRank
Member
Total Posts:  15
Joined:  2009-11-03

Hi Duncan,

Yes, that would work us as well.

Thanks for giving it some thought.

Marco.

Profile
 
 
Posted: 08 April 2011 02:35 PM   [ Ignore ]   [ # 10 ]  
RankRankRank
Contributor
Total Posts:  39
Joined:  2011-04-01

Duncan,

The Host_Name_Override example was very helpful to me to. Just for me to be clear in understanding,

Where, you use

computersystem.Name := computersystem.HostName;

I am correct in thinking that a similar effect could be acheived by writing this (with a possible perfomance hit)?

computersystem.Name := host.hostname;

The difference appears to be that it would be reading the value from the original Host node, rather than reading the mapped value previously set in the Host_ComputerSystem module. So this way I could just use a completely different variable like host.acme_custom_host_identity, and that would override the mapping created by the original module.

Profile
 
 
Posted: 08 April 2011 02:40 PM   [ Ignore ]   [ # 11 ]  
RankRankRankRank
Guru
Total Posts:  2740
Joined:  2008-01-25

Rob I suspect this is related to your thread here, I’m working on example to help that thread if you can give me a bit of time. I’d rather check that it worked before I post it and let you find out ;)

Profile
 
 
Posted: 19 July 2011 10:05 AM   [ Ignore ]   [ # 12 ]  
RankRank
Member
Total Posts:  33
Joined:  2010-01-18

ADDM 8.1 platform scripts ensured that the hostname is short (on most platforms by cutting away everything after the first dot, ie: ihn=`hostname 2>/dev/null | cut -f1 -d.`)

ADDM 8.2 platform scripts just take what is configured to be the hostname. On Debian, it is clearly stated that this must be the short hosname. On Redhat, it may be the short hostname or the local fqdn. Other OSs have other guidelines.

As a result, ADDM 8.2 displays (and even worse: syncs to cmdb) inconsistant host names.

We fixed this by stripping the domain part in the platform script, not the sync-mapping. This ensures that not only in Atrium CMDB, but also in ADDM, the names are consistantly displayed as short names. If they should happen to not be unique, you can just combine the hostname with dns_domain or domain or take local_fqdn.

@Duncan: why are overlapping hostnames a problem for some of your customers? I think the new platform scripts are not fixing whatever problem they might have because the scripts do not ensure the hostname to be either long or short. However, they definitely broke our recon rules (we use {hostname, domain} as key for ComputerSystems from various sources).

Profile
 
 
Posted: 25 July 2011 06:55 PM   [ Ignore ]   [ # 13 ]  
RankRankRankRank
Guru
Total Posts:  2740
Joined:  2008-01-25

They are only inconsistent in how you want to use ADDM and CMDB. If a client was trying to use the same to pick up RedHat machines that had been configured with the hostname as local fqdn against their policies then your approach with platform scripts (and the one we did briefly in one of the 8.1 release) prevents them from doing this and hides a misconfiguration. That’s an undesirable thing in a discovery tool.

Many clients also expect the name in the CMDB to be wholly unique and don’t have your approach.

Rather than edit the platform scripts more stable customisation for you would be to update the syncmappings via an override to change the name we sync to be the “name – domain name” as Duncan suggests. That will mean you don’t have to customise the platform scripts on every upgrade or risk missing an important change to them.

Profile
 
 
Posted: 27 September 2011 08:06 PM   [ Ignore ]   [ # 14 ]  
RankRank
Member
Total Posts:  25
Joined:  2010-07-27

.

[ Edited: 03 October 2011 02:39 AM by ..]
Profile
 
 
Posted: 27 September 2011 10:32 PM   [ Ignore ]   [ # 15 ]  
RankRankRankRank
Guru
Total Posts:  2740
Joined:  2008-01-25

You should be able to do just as the example but use text.upper() just as you would in any other pattern.

Profile
 
 
   
1 of 2
1