This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

NCM that is Ping-Only - any good way to update Node Name based on Cisco config hostname?

I've got several hundred ping-only NCM nodes that are not reachable via SNMP, so Orion does not know the systname/hostname. Are any of you aware of a fancy way to script getting this updated without doing it manually? I don't want to reinvent the wheel if someone has done the legwork already. Outside of that, I'm thinking that I could export the configs to files, then parse those files for the hostname, and then general a SQL query to update the DB. Doesn't seem too difficult but again, if I can save time via your previous hard labor then I will take advantage!

aTdHvAaNnKcSe!

-Eric

Parents
  • rednarb​ Having the nodes managed within NCM, being able to run scripts on them, you could probably run a script via NCM (show hostname, or whatever gives you the name you want), then save it to a custom property. Then you can run a quick script to replace the node names with the value in that custom property. I know I have used NCM to update node names based on values from a custom property.

    Let me see if I can find my thread where I did that, and I'll post it back here when I find it.

  • rednarb​ Here are a few links of a similar solution I had done a long while back. I know you don't have SNMP access, and you don't need to update the hostname on the devices, so this won't solve your issues immediately, but maybe it can give you an idea of another way... At least until the real help arrives.

    Clearing Interface Counters

    Script to remove characters out of host name

    Create custom variable for Cisco device and execute change using the custom variable

    The easiest way, if you already have a list of names to use, would probably be to export a list of nodes via the custom properties tool, then import it back in with the new names. Once you have that, you can run a simple PowerShell script to rename everything using the API. (It's the one way I know, and just barely...)

    The PowerShell script would go something like this, but there are likely tons more examples out there better than mine.

    $nodes = Get-SwisData $swis "
    SELECT
    n.Caption
    ,n.CustomProperties.NewCaption
    ,n.Uri
    FROM Orion.Nodes AS n
    WHERE n.CustomProperties.NewCaption IS NOT NULL
    "

    foreach ($node in $nodes) {
        Write-Host "   Updating Node: $($node.Caption) | Changing: Caption From $($node.Caption) To $($node.NewCaption)"
        #Set-SwisObject $swis ($node.Uri) @{Caption=$($node.NewCaption)} # Set new caption
    }

    There is a wild man somewhere out in THWACK who goes by mesverrum​, and he has pretty much seen it all. He's always talking about all the things NCM can do which usually go unused by the majority of users (myself included). Perhaps he can chime in when he has a moment or two.

    Otherwise, let us know if you still need help getting started.

    Thank you,

    -Will

Reply
  • rednarb​ Here are a few links of a similar solution I had done a long while back. I know you don't have SNMP access, and you don't need to update the hostname on the devices, so this won't solve your issues immediately, but maybe it can give you an idea of another way... At least until the real help arrives.

    Clearing Interface Counters

    Script to remove characters out of host name

    Create custom variable for Cisco device and execute change using the custom variable

    The easiest way, if you already have a list of names to use, would probably be to export a list of nodes via the custom properties tool, then import it back in with the new names. Once you have that, you can run a simple PowerShell script to rename everything using the API. (It's the one way I know, and just barely...)

    The PowerShell script would go something like this, but there are likely tons more examples out there better than mine.

    $nodes = Get-SwisData $swis "
    SELECT
    n.Caption
    ,n.CustomProperties.NewCaption
    ,n.Uri
    FROM Orion.Nodes AS n
    WHERE n.CustomProperties.NewCaption IS NOT NULL
    "

    foreach ($node in $nodes) {
        Write-Host "   Updating Node: $($node.Caption) | Changing: Caption From $($node.Caption) To $($node.NewCaption)"
        #Set-SwisObject $swis ($node.Uri) @{Caption=$($node.NewCaption)} # Set new caption
    }

    There is a wild man somewhere out in THWACK who goes by mesverrum​, and he has pretty much seen it all. He's always talking about all the things NCM can do which usually go unused by the majority of users (myself included). Perhaps he can chime in when he has a moment or two.

    Otherwise, let us know if you still need help getting started.

    Thank you,

    -Will

Children
  • Thank you for the info. While i was not able to follow the guidance closely, it did give me some insight. I am not skilled in PowerShell, and really not even sure about SWSQL either... so I used what I could figure out.

    1. Exported the latest config files to a separate working directory, using the current Caption as the file name.
    2. Scripted reading each config file and extracting the hostname, as well as extracting the current Caption from the file name.
    3. Script created two SQL statements, the first that copies the current Caption to a custom property I made called OldName. The second statement replaces the Caption with the extracted device hostname.
    4. Profit

    I'm sure this would have been easier for someone who knew SWSQL and PowerShell, but I know php and a little bit of SQL (and I have a contact who was better at the SQL part help me), so I made it work.