4 Replies Latest reply on Jul 20, 2015 11:14 PM by wlipford

    Renaming nodes to match DNS

    mikkokok

      Currently we have quite many nodes with their IP on SAM. What would be the easiest way to rename those on what the hostname is? I know how to fetch these nodes from SAM with the SDK but my skills with powershell pretty much ends in here and I have no clue which way to go.

        • Re: Renaming nodes to match DNS
          bluefunelemental

          Travel day so pardon the short response.

          So when adding a node Orion uses DNS name if it can get one. If you have a bunch of IP's for caption then did you add DNS after adding into Orion or are there no DNS at all?

           

          I would query through SDK nodes whose caption <> DNS.

          Let this fill DNS and URI variables. Start there.

           

          Then you can write a ForEach($item in $URI) { "insert sdk verb to update caption with DNS"}

          Test this manually before trying inside a ForEach.

           

          I know you said hostname vs DNS but string manipulation can handle that.

          • Re: Renaming nodes to match DNS
            tony.johnson

            Hello mikkok,

            I would use SQL for this task,

            UPDATE NodeData set Caption=DNS where DNS !=''

             

            This would update the caption for all nodes to the value in the DNS field where the DNS field has a value

             

            To preview the changes you could run

            select dns,caption from NodesData where DNS !=''

             

            Thanks,

            Tony

            • Re: Renaming nodes to match DNS
              wlipford

              Too ironic, I just did this in my system. Except I didn't want the FQDN, We wanted to use the short name. I went with the SQL update path.

               

              ## First let's see how many results we have that look like an IP Address

              SELECT   SUBSTRING(DNS, 1, (CHARINDEX('.', DNS, 0)-1))

                FROM    [SolarWindsOrionNA].[dbo].[Nodes]

                WHERE Caption like '10.%'

                AND       (DNS is not null OR DNS != '')

                AND       DNS like '%.%'

               

                ## Now let's run update on the previous result set

                UPDATE  [SolarWindsOrionNA].[dbo].[Nodes]

                SET         Caption = SUBSTRING(DNS, 1, (CHARINDEX('.', DNS, 0)-1))

                WHERE  Caption like '10.%'

                AND        (DNS is not null OR DNS != '')

                AND        DNS like '%.%'