Ad Widget

Collapse

Automatic host inventory - only for Linux?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tchjts1
    Senior Member
    • May 2008
    • 1605

    #1

    Automatic host inventory - only for Linux?

    Unless I am missing something,the automatic host inventory functionality only works on the Linux platform?

    I say that based on these:
    http://www.zabbix.com/documentation/...osts/inventory

    Code:
    Automatic mode
    
    Host inventory can also be populated automatically. For that to work, 
    when configuring a host the inventory mode in the Host inventory tab 
    must be set to Automatic.
    
    Then you can configure host items to populate any host inventory field with
    their value, indicating the destination field with the respective attribute
    (called Item will populate host inventory field) in item configuration.
    
    Items that are especially useful for automated inventory data collection:
    
        system.hw.chassis[full|type|vendor|model|serial] - default is [full], root permissions needed
        system.hw.cpu[all|cpunum,full|maxfreq|vendor|model|curfreq] - default is [all,full]
        system.hw.devices[pci|usb] - default is [pci]
        system.hw.macaddr[interface,short|full] - default is [all,full], interface is regex
        system.sw.arch
        system.sw.os[name|short|full] - default is [name]
        system.sw.packages[package,manager,short|full] - default is [all,all,full], package is regex
    And in conjunction with the "supported items per platform" table:
    http://www.zabbix.com/documentation/...ed_by_platform

    Which basically shows the above items are only supported on Linux:
    Columns 2 & 3
    Attached Files
  • leelilijian
    Junior Member
    • Jun 2012
    • 15

    #2
    Hi ,how can you configure this automic inventory?

    Comment

    • HullZabbix
      Senior Member
      • Feb 2011
      • 104

      #3
      I've just setup automatic inventory for Linux and Windows hosts.

      For windows hardware, I've created a .vbs script which returns all the hardware info I want to know.

      Code:
      On Error Resume Next
      
      strComputer = "."
      Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      Set colCPUItems = objWMIService.ExecQuery("Select * from Win32_Processor")
      set colMEMItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory")
      Set colMEMAItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemoryArray")
      Set colHDItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive")
      Set colGFXItems = objWMIService.ExecQuery("Select * from Win32_VideoController")
      Set colMBItems = objWMIService.ExecQuery("Select * from Win32_BaseBoard")
      Set colBIOSItems = objWMIService.ExecQuery("Select * from Win32_BIOS")
      
      
      For Each objItem in colCPUItems
      	StringCPU = "CPU: "& objItem.Name
      	Next
      	
      memType = array("Unknown","Other","DRAM","Synchronous DRAM","Cache DRAM","EDO","EDRAM","VRAM","SRAM","RAM","ROM","Flash","EEPROM","FEPROM","EPROM","CDRAM","3DRAM","SDRAM","SGRAM","RDRAM","DDR","DDR-2")
      memForm = array("Unknown","Other","SIP","DIP","ZIP","SOJ","Proprietary","SIMM","DIMM","TSOP","PGA","RIMM","SODIMM","SRIMM","SMD","SSMP","QFP","TQFP","SOIC","LCC","PLCC","BGA", "FPBGA","LGA")
      
      For Each objItem In colMEMItems
      	memoryType = memType(objItem.MemoryType)
      	memoryTotal = memoryTotal + (objItem.Capacity / 1048576)
      	Next
      
      For Each objItem in colMEMAItems
      	totalSlots = objItem.MemoryDevices
      	stringMEM = "RAM: " & memoryTotal & "MB " & memoryType
      	Next
      
      numberOfDisks = -1
      For Each objItem in ColHDItems
      	numberOfDisks = numberOfDisks + 1
      	Next
      Dim myArray()
      reDim myArray(numberOfDisks)
      j = 0
      
      For Each objItem in colHDItems
      	myArray(j) = "HD" & j & ": " & objItem.Model & " " & FormatNumber((objItem.Size/1000000000), 0) & "GB" & " " & objItem.InterfaceType & " "
      	j = j + 1
      	Next
      	
      For Each objItem in colGFXItems
      	stringGFX = "GFX: " & objItem.Description
      	Next
      	
      For Each objItem in colMBItems
      	stringMB = "MB: " & objItem.Manufacturer & " " & objItem.Product
      	Next
      
      For Each objItem in colBIOSItems
      	stringBIOS = "BIOS: " & objItem.Manufacturer & " " & objItem.Name
      	Next
      
      Wscript.Echo stringOS & vbcrlf & stringCPU & vbcrlf & stringMEM & vbcrlf & Join(myArray,vbcrfl) & vbcrlf & stringGFX & vbcrlf & stringMB & vbcrlf & stringBIOS
      I've added this as a user parameter in the hosts zabbix agent config:
      Code:
      UserParameter=specHWShort,cscript.exe /nologo "\\192.168.x.x\MachineSpec\specHWShort.vbs"
      Then added the items in the zabbix interface:



      I've circled the important part - this allows it to automatically fill in the inventory.

      As you can see it gets added to the automatic tab:



      Inventory sorted:

      Comment

      • leelilijian
        Junior Member
        • Jun 2012
        • 15

        #4
        good idea,thanks very much!

        Comment

        • tchjts1
          Senior Member
          • May 2008
          • 1605

          #5
          Axida - thank you for sharing!

          Jeff

          Comment

          • simpleton
            Junior Member
            • Dec 2012
            • 9

            #6
            Perfect! Just what I was looking for.
            Where do you keep the .vbs script?
            Do you create a file-share on each host, or in one central location?

            \\192.168.x.x\MachineSpec\specHWShort.vbs


            This should be in the Zabbix documentation, for sure!

            Comment

            • HullZabbix
              Senior Member
              • Feb 2011
              • 104

              #7
              Good to know it's useful for some people

              I've created the single file share on the zabbix server which is 192.168.x.x (our local domain). This contains all the .vbs scripts. But for servers in the DMZ I have the local zabbix configs set to reference a local copy. I don't want file transfer through the DMZ!

              Comment

              • lagorue
                Member
                • Jul 2011
                • 36

                #8
                Perfect, Thanks!

                Comment

                • vhan
                  Junior Member
                  • Apr 2013
                  • 1

                  #9
                  Host not auto populate HW info

                  Hi HullZabbix.

                  I configure as you guide but the configure item is different with yours. I changed host to automatic but it does not populate data as you mention

                  Here is my steps:
                  - Copy your file specHWShort to C:\Program Files\Zabbix\
                  - Change UserParameter=specHWShort,cscript.exe "C:\Program Files\Zabbix\specHWShort.vbs"
                  - Link Host to Template with Item specHWShort
                  - Version: Zabbix Agent 2.0.4 (revision 31980). Zabbix server 2.0.5

                  I don't know which steps are missing. Please help. Thanks so much
                  Attached Files

                  Comment

                  • HullZabbix
                    Senior Member
                    • Feb 2011
                    • 104

                    #10
                    Have you checked the latest data for the host?

                    Make sure your specHWShort item is getting populated in there first (Monitoring-->Latest Data)

                    check https://www.zabbix.com/forum/showthread.php?t=26862 to see if you can pick up anything there.

                    *edit* also, I haven't tested this with templates. I have it as just an item.
                    Last edited by HullZabbix; 23-04-2013, 17:34.

                    Comment

                    • akiraexe
                      Junior Member
                      • Aug 2013
                      • 2

                      #11
                      ZBX_NOTSUPPORTED sometimes

                      Hello!

                      I tried sucessufully thes scripts with minor changes but sometimes on some servers I get the message of ZBX_NOTSUPPORTED and in the monitoring panel shows that Items is "Not Supported"

                      You experienced something like that?

                      Grettings!

                      Comment

                      • HullZabbix
                        Senior Member
                        • Feb 2011
                        • 104

                        #12
                        That just means the script is failing to return anything. Whether that's a timeout or just an error.

                        Have you tried running the .vbs script locally on the server?

                        Comment

                        • akiraexe
                          Junior Member
                          • Aug 2013
                          • 2

                          #13
                          Yes, you are right, the fact is that works local but when I tried to get data, shows this message. I don't know if is to hard o take too much to display data.

                          You can give me a tip for make it a bit light and fast? I'll send you a copy of my script.

                          Greetings!

                          Comment

                          • killout
                            Junior Member
                            • Dec 2013
                            • 10

                            #14
                            Hello.

                            Does anybody know if analog script for collecting linux hardware info exists?
                            I want to populate it into inventory field/

                            Comment

                            • killout
                              Junior Member
                              • Dec 2013
                              • 10

                              #15
                              facter from puppet do the work good.

                              Comment

                              Working...