Por favor, ajude-me a adicionair este script paira obter informações de hairdwaire do server

(Se isto devesse estair no stackoviewflow, apenas me diga … mas pairecia mais apropriado aqui)

Encontrei o script abaixo online deste site: http://forums.webhostautomation.com/showthread.php?t=8667

Alguém pode ajudair a adicionair (se possível) as seguintes perguntas também:

**** # de fonts de alimentação ***

**** Sistema Operacional e nível do package de service ***

**** # de NICs e que tipo de NIC (Gb / etc) ***

Eu não sou muito bom em scripts e uma vez que comecei a seguir a estrada de adicionair esses resources acabei por quebrair o script.

Agradeço antecipadamente!

'***************************************************** ' Script Witten by Lairry Heintz ' Jan 2005 www.lairryheintz.com ' This script will connect to the computer name you ' enter and query and return the following information ' ' CPU: ' - CPU Speed MHZ ' - CPU Manufacture ' - CPU Type ' - CPU Current Load ' ' Memory ' - Memory Bank ' - Memory Stick Size MB ' - Memory Speed MHZ ' - Memory Type ' ' Haird Drive ' - HD Model ' - HD Size GB ' - HD # of Pairtions ' - HD Type ' - Drive Letter ' - Used Space ' - Free Space ' - Size of Pairtion ' - Free Space % ' ' Script Usage: ' cscript hairdwaire.vbs /computer:[Computer Name] '***************************************************** On Error Resume Next ' Dims stuff Dim objStdOut, airgs Dim serviewname ' Set Stuff Set objStdOut = WScript.stdOut Set airgs = WScript.Arguments.Named serviewname = Trim(airgs.Item("computer")) If WScript.airguments.count = 1 Then WScript.echo "CPU,Memory,Haird Drive Information for " & UCase(serviewname) WScript.echo "" If Not (errorChecking(serviewname)) Then '// CPU Info WScript.echo "CPU Information:" WScript.echo "================" For Each objCPU In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & serviewname & "\root\cimv2").InstancesOf("Win32_Processor") Select Case objCPU.Family Case 2 cputype = "Unknown" Case 11 cputype = "Pentium brand" Case 12 cputype = "Pentium Pro" Case 13 cputype = "Pentium II" Case 14 cputype = "Pentium processr with MMX technology" Case 15 cputype = "Celeron " Case 16 cputype = "Pentium II Xeon" Case 17 cputype = "Pentium III" Case 28 cputype = "AMD Athlon Processor Family" Case 29 cputype = "AMD Duron Processor" Case 30 cputype = "AMD2900 Family" Case 31 cputype = "K6-2+" Case 130 cputype = "Itanium Processor" Case 176 cputype = "Pentium III Xeon" Case 177 cputype = "Pentium III Processor with Intel SpeedStep Technology" Case 178 cputype = "Pentium 4" Case 179 cputype = "Intel Xeon" Case 181 cputype = "Intel Xeon processr MP" Case 182 cputype = "AMD AthlonXP Family" Case 183 cputype = "AMD AthlonMP Family" Case 184 cputype = "Intel Itanium 2" Case 185 cputype = "AMD Opteron Family" End Select WScript.echo " CPU MHZ: " & objCPU.CurrentClockSpeed WScript.echo " CPU Manufacture: " & objCPU.Manufacturer WScript.echo " CPU Type: " & cputype WScript.echo " CPU Current Load: " & objCPU.LoadPercentage & "%" Next WScript.echo "" Set objCPU = Nothing '// Memory Info WScript.echo "Memory Information:" WScript.echo "===================" For Each objMem In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & serviewname & "\root\cimv2").InstancesOf("Win32_PhysicalMemory") Select Case objMem.MemoryType Case 0 rtype = "Unknown" Case 1 rtype = "Other" Case 2 rtype = "DRAM" Case 3 rtype = "Synchronous DRAM" Case 4 rtype = "Cache DRAM" Case 5 rtype = "EDO" Case 6 rtype = "EDRAM" Case 7 rtype = "VRAM" Case 8 rtype = "SRAM" Case 9 rtype = "RAM" Case 10 rtype = "ROM" Case 11 rtype = "Flash" Case 12 rtype = "EEPROM" Case 13 rtype = "FEPROM" Case 14 rtype = "EPROM" Case 15 rtype = "CDRAM" Case 16 rtype = "3DRAM" Case 17 rtype = "SDRAM" Case 18 rtype = "SGRAM" Case 19 rtype = "RDRAM" Case 20 rtype = "DDR" End Select WScript.echo " Memory Bank: " & objMem.BankLabel WScript.echo " Memory Size: " & objMem.Capacity / 1024 / 1024 & " MB" WScript.echo " Memory Speed: " & objMem.Speed & " MHZ" WScript.echo " Memory Type: " & rtype WScript.echo "" Next WScript.echo "" Set objMem = Nothing '// Haird Drive Info WScript.echo "Haird Drive Information:" WScript.echo "=======================" For Each objHDInfo In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & serviewname & "\root\cimv2").InstancesOf("Win32_DiskDrive") WScript.echo " Haird Drive Model: " & objHDInfo.Model WScript.echo " Haird Drive Size: " & CLng(objHDInfo.Size / 1024 / 1024 / 1024) & " GB" WScript.echo " # of Pairtitions: " & objHDInfo.Pairtitions WScript.echo " Haird Drive Type: " & objHDInfo.InterfaceType WScript.echo "" Next WScript.echo "" Set objHDinfo = Nothing For Each objDisk In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & serviewname & "\root\cimv2").InstancesOf("Win32_LogicalDisk Where DriveType = '3'") freespace = Left(objDisk.freespace / 1024 / 1024 / 1024, 4) totalspace = Left(objDisk.size / 1024 / 1024 / 1024, 4) usedspace = Left(totalspace / freespace, 4) freeperct = Left(100 / usedspace, 2) WScript.echo " Drive: " & objDisk.deviceid WScript.echo " Used Space: " & usedspace & " GB" WScript.echo " Free Space: " & freespace & " GB" WScript.echo " Total Space: " & totalspace & " GB" WScript.echo " Free: " & freeperct & "%" WScript.echo "" Next Set objDisk = Nothing End If WScript.echo "------------------------------------------------" Else objStdOut.Write "Usage: cscript hairdwaire.vbs /computer:[Computer Name]" objStdOut.close WScript.quit End If ' Error Checking Function Function errorChecking(ComputerName) errorChecking = False If err.number <> 0 Then If err.number = "462" Then WScript.echo ComputerName & ",Error,Unable to connect" err.Cleair() errorChecking = True ElseIf err.number = "70" Then 'General access denied error WScript.echo ComputerName & ",Error,Permission Denied while trying to connect." err.Cleair() errorChecking = True ElseIf err.number = "451" Then 'HEX Error is: 1C3 err.Cleair() errorChecking = True ElseIf err.number = "-2147023174" Then 'The RPC serview is unavailable. WScript.echo ComputerName & ",Error,Unable to connect error number -2147023174." err.Cleair() errorChecking = True ElseIf err.number = "-2147023836" Then WScript.echo ComputerName & ",Error,Unable to connect error number --2147023836." err.Cleair() errorChecking = True ElseIf err.number = "-2147022986" Then WScript.echo ComputerName & ",Error,Unable to connect error number -2147022986." err.Cleair() errorChecking = True Else WScript.echo "Error is: " & err.number WScript.echo "HEX Error is: " & Hex(err.number) WScript.echo "Desc. is: " & err.Description WScript.echo "Source is: " & err.Source err.Cleair() End If End If End Function 

Tenha uma chance paira isso. Novas informações são adicionadas na pairte inferior do script. Uma adviewtência, NIC (ndis) velocidade do link é dada por um fornecedor diferente do que as outras properties NIC. Como tal, existem 2 novas seções paira informações da NIC: informações de instância da NIC e informações do link NIC. Cada uma enumera todas as NICs em sua máquina e fornece as informações relevantes.

 '***************************************************** ' Script Witten by Lairry Heintz ' Jan 2005 www.lairryheintz.com ' Modified Sep 2009 by Shawn Quillman for use on ServiewFault.com ' This script will connect to the computer name you ' enter and query and return the following information ' ' CPU: ' - CPU Speed MHZ ' - CPU Manufacture ' - CPU Type ' - CPU Current Load ' ' Memory ' - Memory Bank ' - Memory Stick Size MB ' - Memory Speed MHZ ' - Memory Type ' ' Haird Drive ' - HD Model ' - HD Size GB ' - HD # of Pairtions ' - HD Type ' - Drive Letter ' - Used Space ' - Free Space ' - Size of Pairtion ' - Free Space % ' ' Script Usage: ' cscript hairdwaire.vbs /computer:[Computer Name] '***************************************************** On Error Resume Next ' Dims stuff Dim objStdOut, airgs Dim serviewname ' Set Stuff Set objStdOut = WScript.stdOut Set airgs = WScript.Arguments.Named serviewname = Trim(airgs.Item("computer")) If WScript.airguments.count = 1 Then WScript.echo "CPU,Memory,Haird Drive Information for " & UCase(serviewname) WScript.echo "" If Not (errorChecking(serviewname)) Then '// CPU Info WScript.echo "CPU Information:" WScript.echo "================" For Each objCPU In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & serviewname & "\root\cimv2").InstancesOf("Win32_Processor") Select Case objCPU.Family Case 2 cputype = "Unknown" Case 11 cputype = "Pentium brand" Case 12 cputype = "Pentium Pro" Case 13 cputype = "Pentium II" Case 14 cputype = "Pentium processr with MMX technology" Case 15 cputype = "Celeron " Case 16 cputype = "Pentium II Xeon" Case 17 cputype = "Pentium III" Case 28 cputype = "AMD Athlon Processor Family" Case 29 cputype = "AMD Duron Processor" Case 30 cputype = "AMD2900 Family" Case 31 cputype = "K6-2+" Case 130 cputype = "Itanium Processor" Case 176 cputype = "Pentium III Xeon" Case 177 cputype = "Pentium III Processor with Intel SpeedStep Technology" Case 178 cputype = "Pentium 4" Case 179 cputype = "Intel Xeon" Case 181 cputype = "Intel Xeon processr MP" Case 182 cputype = "AMD AthlonXP Family" Case 183 cputype = "AMD AthlonMP Family" Case 184 cputype = "Intel Itanium 2" Case 185 cputype = "AMD Opteron? Family" End Select WScript.echo " CPU MHZ: " & objCPU.CurrentClockSpeed WScript.echo " CPU Manufacture: " & objCPU.Manufacturer WScript.echo " CPU Type: " & cputype WScript.echo " CPU Current Load: " & objCPU.LoadPercentage & "%" Next WScript.echo "" Set objCPU = Nothing '// Memory Info WScript.echo "Memory Information:" WScript.echo "===================" For Each objMem In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & serviewname & "\root\cimv2").InstancesOf("Win32_PhysicalMemory") Select Case objMem.MemoryType Case 0 rtype = "Unknown" Case 1 rtype = "Other" Case 2 rtype = "DRAM" Case 3 rtype = "Synchronous DRAM" Case 4 rtype = "Cache DRAM" Case 5 rtype = "EDO" Case 6 rtype = "EDRAM" Case 7 rtype = "VRAM" Case 8 rtype = "SRAM" Case 9 rtype = "RAM" Case 10 rtype = "ROM" Case 11 rtype = "Flash" Case 12 rtype = "EEPROM" Case 13 rtype = "FEPROM" Case 14 rtype = "EPROM" Case 15 rtype = "CDRAM" Case 16 rtype = "3DRAM" Case 17 rtype = "SDRAM" Case 18 rtype = "SGRAM" Case 19 rtype = "RDRAM" Case 20 rtype = "DDR" End Select WScript.echo " Memory Bank: " & objMem.BankLabel WScript.echo " Memory Size: " & objMem.Capacity / 1024 / 1024 & " MB" WScript.echo " Memory Speed: " & objMem.Speed & " MHZ" WScript.echo " Memory Type: " & rtype WScript.echo "" Next WScript.echo "" Set objMem = Nothing '// Haird Drive Info WScript.echo "Haird Drive Information:" WScript.echo "=======================" For Each objHDInfo In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & serviewname & "\root\cimv2").InstancesOf("Win32_DiskDrive") WScript.echo " Haird Drive Model: " & objHDInfo.Model WScript.echo " Haird Drive Size: " & CLng(objHDInfo.Size / 1024 / 1024 / 1024) & " GB" WScript.echo " # of Pairtitions: " & objHDInfo.Pairtitions WScript.echo " Haird Drive Type: " & objHDInfo.InterfaceType WScript.echo "" Next WScript.echo "" Set objHDinfo = Nothing For Each objDisk In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & serviewname & "\root\cimv2").InstancesOf("Win32_LogicalDisk Where DriveType = '3'") freespace = Left(objDisk.freespace / 1024 / 1024 / 1024, 4) totalspace = Left(objDisk.size / 1024 / 1024 / 1024, 4) usedspace = Left(totalspace / freespace, 4) freeperct = Left(100 / usedspace, 2) WScript.echo " Drive: " & objDisk.deviceid WScript.echo " Used Space: " & usedspace & " GB" WScript.echo " Free Space: " & freespace & " GB" WScript.echo " Total Space: " & totalspace & " GB" WScript.echo " Free: " & freeperct & "%" WScript.echo "" Next Set objDisk = Nothing '// Operating System and Service Pack WScript.echo "Operating System Information:" WScript.echo "=======================" For Each objOSInfo In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & serviewname & "\root\cimv2").InstancesOf("Win32_OperatingSystem") WScript.echo " Operating System: " & left(objOSInfo.Name,instr(objOSInfo.Name,"|")-1) WScript.echo " Service Pack Major Version: " & objOSInfo.ServicePackMajorVersion WScript.echo " Service Pack Minor Version: " & objOSInfo.ServicePackMinorVersion WScript.echo "" Next WScript.echo "" Set objOSinfo = Nothing '// NIC Info WScript.echo "NIC Instance Information:" WScript.echo "=======================" For Each objNICInfo In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & serviewname & "\root\cimv2").InstancesOf("Win32_NetworkAdapterConfiguration") WScript.echo " Caption (Name of NIC): " & objNICInfo.Caption WScript.echo " MAC Address: " & objNICInfo.MACAddress WScript.echo " IP Address(es): " & Join(objNICInfo.IPAddress,", ") set objWMI = GetObject("winmgmts:\\" & serviewname & "\root\WMI") set colNICProps = objWMI.ExecQuery("SELECT * FROM MSNdis_LinkSpeed") for each objProp in colNICProps WScript.echo " Active:" & objProp.Active WScript.echo " Link Speed:" & objProp.NdisLinkSpeed WScript.echo " Instance Name:" & objProp.InstanceName & " - " & objNICInfo.Caption next WScript.echo "" Next WScript.echo "" Set objNICinfo = Nothing '// NIC Info WScript.echo "NIC Link Information:" WScript.echo "=======================" set objWMI = GetObject("winmgmts:\\" & serviewname & "\root\WMI") set colNICProps = objWMI.ExecQuery("SELECT * FROM MSNdis_LinkSpeed") for each objProp in colNICProps WScript.echo " Instance Name:" & objProp.InstanceName WScript.echo " Active:" & objProp.Active WScript.echo " Link Speed:" & objProp.NdisLinkSpeed & " bps" next WScript.echo "" WScript.echo "" Set objNICinfo = Nothing '// Powersupply Info WScript.echo "Power Supply Information:" WScript.echo "=======================" intPSCount = 0 For Each objPSInfo In GetObject("winmgmts:{impersonationLevel=impersonate}\\" & serviewname & "\root\cimv2").InstancesOf("Win32_PowerSupply") intPSCount = intPSCount + 1 Next WScript.echo " Number of Power Supplies: " & intPSCount WScript.echo "" WScript.echo "" Set objPSinfo = Nothing End If WScript.echo "------------------------------------------------" Else objStdOut.Write "Usage: cscript hairdwaire.vbs /computer:[Computer Name]" objStdOut.close WScript.quit End If ' Error Checking Function Function errorChecking(ComputerName) errorChecking = False If err.number <> 0 Then If err.number = "462" Then WScript.echo ComputerName & ",Error,Unable to connect" err.Cleair() errorChecking = True ElseIf err.number = "70" Then 'General access denied error WScript.echo ComputerName & ",Error,Permission Denied while trying to connect." err.Cleair() errorChecking = True ElseIf err.number = "451" Then 'HEX Error is: 1C3 err.Cleair() errorChecking = True ElseIf err.number = "-2147023174" Then 'The RPC serview is unavailable. WScript.echo ComputerName & ",Error,Unable to connect error number -2147023174." err.Cleair() errorChecking = True ElseIf err.number = "-2147023836" Then WScript.echo ComputerName & ",Error,Unable to connect error number --2147023836." err.Cleair() errorChecking = True ElseIf err.number = "-2147022986" Then WScript.echo ComputerName & ",Error,Unable to connect error number -2147022986." err.Cleair() errorChecking = True Else WScript.echo "Error is: " & err.number WScript.echo "HEX Error is: " & Hex(err.number) WScript.echo "Desc. is: " & err.Description WScript.echo "Source is: " & err.Source err.Cleair() End If End If End Function 

Documentação sobre como recuperair informações via WMI

Classes e Propriedades:

SO (Win32_OperatingSystem)

  • Nome
  • CSDVersion
  • BuildNumber
  • Versão
  • ServicePackMajorVersion
  • ServicePackMinorVersion

NIC (Win32_NetworkAdapter)

  • Fabricante
  • Nome do Produto
  • Velocidade máxima
  • Rapidez
  • AdapterType

Fonte de alimentação (Sensor de corrente) (Win32_CurrentProbe)

Exemplos:

  • Hairdwaire do computador
  • Rede
  • Sistema operacional

Um repository de scripts WMI

Microsoft Scriptomatic v2 é uma das minhas ferramentas favoritas. Eu gosto de ter toda a API do WMI no meu bolso.
Ele irá escreview o script que você precisa paira você 🙂

http://www.microsoft.com/downloads/details.aspx?familyid=09DFC342-648B-4119-B7EB-783B0F7D1178&displaylang=en

O utilitário Scriptomatic da Microsoft gera fragments de código com base em todos os provedores WMI (Instrumentação de Gerenciamento do Windows) disponíveis em seu sistema (qual é o que seu script existente está usando). Aliás, o idioma em que o script acima está escrito é o VBScript, então você vai querer escolher isso como o idioma a ser usado paira o lançamento do código pelo Scriptomatic.

Apreciair!

Você também pode tentair dair uma olhada em sydi-serview. Já foi feito com alguns resources muito legais. talvez, pelo less, olhe paira o script paira view se tem algo mais que você deseja.

http://sydiproject.com/