Smarts NCM: Device name of Cisco IOSXR devices are wrongly updated
search cancel

Smarts NCM: Device name of Cisco IOSXR devices are wrongly updated

book

Article ID: 331253

calendar_today

Updated On:

Products

VMware Smart Assurance

Issue/Introduction

Symptoms:


Cisco IOSXR devices are getting discovered with devicename as System but Hostname is correct.
SNMP is not in use for these devices communication, only SSH/Telnet credentials are in use. 

Ex: 
DEV 1142 "System" UID="FOC" HOSTNAME="p-05.test.com" DOMAINNAME="test.com" SYSOBJECTID="NCS5500" ADDR="10.0.x.x" COMMUNITY="" RWCOMMUNITY="" PACKAGE="1265" PACKAGE_IS_SET="0" CM_MANAGED="-1" CREATE_DATE=1522698708 AUTO_DISCOVERED=1

Environment

VMware Smart Assurance - NCM

Cause

NCM fetches Hostname with below function via SSH/Telnet for Cisco IOSXR devices:
From file $VOYENCE_HOME/package/cisco/iosxr/stdfuncs.inc
ciscoTermGetHostName(var session)
{
    if(m_showVer==0||m_showVer==""){
        m_showVer=getShowVer(session);
    }
    var hostName = trim(chomp(stdGetMatchedStrings(m_showVer,"(.*) uptime")));
    var hosts  = ciscoSendCommand(session,"show hosts"+stdEOL);
    var domain = trim(chomp(stdGetMatchedStrings(hosts,"Default domain is (.*)")));
    if( strlen(domain) > 0  &&  strfind(domain,"not set")==-1 )
        hostName += "."+domain;
    retVal = hostName;
    LOG="ciscoGetTermHostName =" + hostName;
}


NCM considers string before uptime in "show version" command output as hostname. 

Cisco IOSXR devices sometimes doesn't have devicename in "show version" command output.

Ex:
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002>
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002>Cisco IOS XR Software, Version 6.2.3
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002>Copyright (c) 2013-2017 by Cisco Systems, Inc.
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002>
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002>Build Information:
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002> Built By     : ahoang
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002> Built On     : Thu Dec 21 19:01:41 PST 2017
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002> Build Host   : iox-lnx-064
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002> Workspace    : /auto/srcarchive11/production/6.2.3/ncs5500/workspace
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002> Version      : 6.2.3
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002> Location     : /opt/cisco/XR/packages/
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002>
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002>cisco NCS-5500 () processor 
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002>System uptime is 5 weeks, 6 days, 17 hours, 7 minutes
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002>
Apr 02 14:53:27 2143282944/ssh#1: RCV-1002>RP/0/RP0/CPU0:p-05#

Resolution

Implement the below workaround in your environment:

In DS, follow the first 3 steps(a,b,c) if you don t have $VOYENCE_HOME/custompackage/cisco/iosxr directory.
If you already have the directory structure and stdfuncs.inc file at that path, take a backup of the file and skip to step d. 

a. Make a cisco directory in the custompackage directory as follows:
source /etc/voyence.conf
mkdir $VOYENCE_HOME/custompackage/cisco


b. Make a iosxr directory in the $VOYENCE_HOME/custompackage/cisco directory as follows:
mkdir $VOYENCE_HOME/custompackage/cisco/iosxr

c. Copy the stdfuncs.inc file from the package/cisco/ios directory to the custompackage/cisco/ios directory as follows:
cp $VOYENCE_HOME/package/cisco/iosxr/stdfuncs.inc $VOYENCE_HOME/custompackage/cisco/iosxr/stdfuncs.inc

d. Open stdfuncs.inc file at $VOYENCE_HOME/custompackage/cisco/iosxr directory:

Edit the below highlighted section from:
ciscoTermGetHostName(var session)
{
    if(m_showVer==0||m_showVer==""){
        m_showVer=getShowVer(session);
    }
    var hostName = trim(chomp(stdGetMatchedStrings(m_showVer,"(.*) uptime")));

    var hosts  = ciscoSendCommand(session,"show hosts"+stdEOL);
    var domain = trim(chomp(stdGetMatchedStrings(hosts,"Default domain is (.*)")));
    if( strlen(domain) > 0  &&  strfind(domain,"not set")==-1 )
        hostName += "."+domain;
    retVal = hostName;
    LOG="ciscoGetTermHostName =" + hostName;
}


To:
ciscoTermGetHostName(var session)
{
    // if(m_showVer==0||m_showVer==""){
   // m_showVer = ciscoSendCommand(session,"show version"+stdEOL);
   // }
   // var hostName = trim(chomp(stdGetMatchedStrings(m_showVer,"(.*) uptime")));
    if(m_config=="") {
        m_config=ciscoSendCommand(session,"show run"+stdEOL);
   }
    var hostName = trim(chomp(stdGetMatchedStrings(m_config,"hostname (.*)")));

    var hosts  = ciscoSendCommand(session,"show hosts"+stdEOL);
    var domain = trim(chomp(stdGetMatchedStrings(hosts,"Default domain is (.*)")));
    if( strlen(domain) > 0  &&  strfind(domain,"not set")==-1 )
        hostName += "."+domain;
    retVal = hostName;
    LOG="ciscoGetTermHostName =" + hostName;
}


Save and close the file.

e) Execute  service voyence restart .
f) Clear device cache and pull All on the device. (or)
Navigate to $VOYENCE_HOME/data/devserver/cm/cache/<deviceIDX>, delete the files SystemProperties.xml and Identity.xml and run pull selected of SystemProperties, Identity on the device. 

With this workaround, NCM is making use of entry after  hostname  string in  show run  command output of device, to retrieve the hostname.