Ad Widget

Collapse

Populate Host Visible Name / Host Name from Inventory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dan_cytexone
    Member
    • Dec 2008
    • 61

    #1

    Populate Host Visible Name / Host Name from Inventory

    Hello

    Is there any way to automatically update a hosts visible name or host name from a value that shows up in Inventory?

    If so how would I accomplish this, as it will be incredible for us.

    Thanks!
  • dan_cytexone
    Member
    • Dec 2008
    • 61

    #2
    Hoping to see if anyone knows how to do this

    Thanks

    Comment

    • Linwood
      Senior Member
      • Dec 2013
      • 398

      #3
      The inventory fields are visible in the API, and you can set host fields from it, so yes, you could script API calls to do it, which would be the supported way.

      It's also pretty easy to do in SQL if prefer that area, though modifying the database from SQL is not supported and you can screw up your database. But in this case I've updated all those fields and it works OK, as far as I can see.

      The host fields are host and name, the inventory fields are things like name (which most people populate from sysName). There's a 1:1 (or more precisely 1 to optional 1) relationship so you can just join over hostid between hosts and hosts_inventory and update back to host.

      I won't post SQL because it varies with database back end a bit doing a joined update, but it's simple if you have a SQL background (or SQL programmer handy).

      Comment

      • dan_cytexone
        Member
        • Dec 2008
        • 61

        #4
        Thank you very much. I was considering doing it via the API, and was hoping to avoid that if there was a Native way to do it with Macros / Script / Etc.

        Setting the Host Name / Alias from an Item would be awesome feature. The API does seem like a pretty easy workaround.

        Comment

        • syntax53
          Member
          • Mar 2018
          • 40

          #5
          FYI, here is the script I wrote for updating the visible name from the inventory and a couple other things via the API and python: https://pastebin.com/DvcWyC5r

          Comment

          Working...