cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 10

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

0 Kudos
5 Replies

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.

0 Kudos

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

Level 10

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.

Level 10

I didn't realize I could save command output to a custom property! This would be really smooth and I would love to see how you did it once you find that! THANKS!

0 Kudos

rednarb​ Yeah, I think my brain was a bit crossed when I first replied. My examples will most likely not benefit you too much, at least not directly. However, I did post them just in case, and fired up the bat signal to bring help. My example was pretty much the opposite of what you are needing. I used NCM to read the custom properties, then push those back into the devices to standardize the naming. You already have your devices named, and are wanting to update just the way they are shown within Orion/NCM.

I'd venture to guess the API is going to be the easiest way to accomplish this, the most difficult part is getting the parsed command/hostname. If you already had a list of device names, it would be very easy to import that list into SolarWinds via the custom property editor/importer. After that, you just need to run the API to read those values and then write them back.

Do you have a list of device names elsewhere already? Preferably something with hostname and IPs already matched up.

0 Kudos