From 440ad8296ff685725f37dc7a813ff13ffe4bb7ca Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Tue, 21 Apr 2015 11:42:45 +0200 Subject: [PATCH 1/3] Change modules inventory and add new plugins --- pandora_agents/win32/bin/pandora_agent.conf | 69 ++++++++- pandora_agents/win32/bin/util/cdromdrives.vbs | 25 ++++ pandora_agents/win32/bin/util/cpuinfo.vbs | 21 +++ pandora_agents/win32/bin/util/diskdrives.vbs | 24 +++ pandora_agents/win32/bin/util/ifaces.vbs | 34 +++++ pandora_agents/win32/bin/util/moboinfo.vbs | 22 +++ pandora_agents/win32/bin/util/monitors.vbs | 25 ++++ pandora_agents/win32/bin/util/printers.vbs | 51 +++++++ pandora_agents/win32/bin/util/productID.vbs | 24 +++ pandora_agents/win32/bin/util/productkey.vbs | 25 ++++ pandora_agents/win32/bin/util/raminfo.vbs | 24 +++ .../win32/bin/util/software_installed.vbs | 139 +++++++++++++----- pandora_agents/win32/bin/util/userslogged.vbs | 69 +++++++++ .../win32/bin/util/videocardinfo.vbs | 24 +++ 14 files changed, 536 insertions(+), 40 deletions(-) create mode 100644 pandora_agents/win32/bin/util/cdromdrives.vbs create mode 100644 pandora_agents/win32/bin/util/cpuinfo.vbs create mode 100644 pandora_agents/win32/bin/util/diskdrives.vbs create mode 100644 pandora_agents/win32/bin/util/ifaces.vbs create mode 100644 pandora_agents/win32/bin/util/moboinfo.vbs create mode 100644 pandora_agents/win32/bin/util/monitors.vbs create mode 100644 pandora_agents/win32/bin/util/printers.vbs create mode 100644 pandora_agents/win32/bin/util/productID.vbs create mode 100644 pandora_agents/win32/bin/util/productkey.vbs create mode 100644 pandora_agents/win32/bin/util/raminfo.vbs create mode 100644 pandora_agents/win32/bin/util/userslogged.vbs create mode 100644 pandora_agents/win32/bin/util/videocardinfo.vbs diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 7431f2752f..5dd7cb0edc 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -191,15 +191,72 @@ module_exec dir "%ProgramFiles%\Avira\AntiVir Desktop\aevdf.dat" | grep aevdf.da module_description Last update for Antivirus Signature file module_end -# Windows inventory module (This information will be displayed only in enterprise version) +# Windows inventory module (This information will be displayed only in enterprise version)^M module_begin -module_name Inventory -module_interval 7 -module_type generic_data_string -module_inventory CPU RAM CDROM Video HD Patches Services NIC -module_description Inventory +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\cpuinfo.vbs" +module_crontab * 12-15 * * 1 module_end +module_begin +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\moboinfo.vbs" +module_crontab * 12-15 * * 1 +module_end + +module_begin +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\diskdrives.vbs" +module_crontab * 12-15 * * 1 +module_end + +module_begin +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\cdromdrives.vbs" +module_crontab * 12-15 * * 1 +module_end + +module_begin +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\videocardinfo.vbs" +module_crontab * 12-15 * * 1 +module_end + +module_begin +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\ifaces.vbs" +module_crontab * 12-15 * * 1 +module_end + +module_begin +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\monitors.vbs" +module_crontab * 12-15 * * 1 +module_end + +module_begin +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\printers.vbs" +module_crontab * 12-15 * * 1 +module_end + +module_begin +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\raminfo.vbs" +module_crontab * 12-15 * * 1 +module_end + +module_begin +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\software_installed.vbs" +module_crontab * 12-15 * * 1 +module_end + +module_begin +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\userslogged.vbs" +module_crontab * 12-15 * * 1 +module_end + +module_begin +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\productkey.vbs" +module_crontab * 12-15 * * 1 +module_end + +module_begin +module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\productID.vbs" +module_crontab * 12-15 * * 1 +module_end + # ---------------------------------------------------------------------------------------------------- # This samples below need to be reconfigured and uncommented. Please read documentation # on how to setup pandora fms windows agent at http://wiki.pandorafms.com diff --git a/pandora_agents/win32/bin/util/cdromdrives.vbs b/pandora_agents/win32/bin/util/cdromdrives.vbs new file mode 100644 index 0000000000..8edd6a8172 --- /dev/null +++ b/pandora_agents/win32/bin/util/cdromdrives.vbs @@ -0,0 +1,25 @@ +on error resume next +'WMI CD_ROM_drives_info + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "CDROMs" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + +strComputer = "." +Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") +Set colCDROMDrives = objWMIService.ExecQuery("Select caption,description,drive,deviceid from win32_CDROMDrive") + +For Each cdromd In colCDROMDrives + Wscript.StdOut.WriteLine "" +Next + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + diff --git a/pandora_agents/win32/bin/util/cpuinfo.vbs b/pandora_agents/win32/bin/util/cpuinfo.vbs new file mode 100644 index 0000000000..cd65e2dcfd --- /dev/null +++ b/pandora_agents/win32/bin/util/cpuinfo.vbs @@ -0,0 +1,21 @@ +on error resume next +'WMI cpuinfo + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "CPU" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + +strComputer = "." +Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") +Set colCPUs = objWMIService.ExecQuery("Select name,maxclockspeed,caption from Win32_Processor") + +For Each cpu In colCPUs + Wscript.StdOut.WriteLine "" +Next + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + diff --git a/pandora_agents/win32/bin/util/diskdrives.vbs b/pandora_agents/win32/bin/util/diskdrives.vbs new file mode 100644 index 0000000000..3cba8eb106 --- /dev/null +++ b/pandora_agents/win32/bin/util/diskdrives.vbs @@ -0,0 +1,24 @@ +on error resume next +'WMI disksinfo + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "Disks" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + +strComputer = "." +Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") +Set colHDDs = objWMIService.ExecQuery("Select caption,size,serialnumber from win32_diskdrive") + +For Each disco In colHDDs + Wscript.StdOut.WriteLine "" +Next + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + diff --git a/pandora_agents/win32/bin/util/ifaces.vbs b/pandora_agents/win32/bin/util/ifaces.vbs new file mode 100644 index 0000000000..45be437a78 --- /dev/null +++ b/pandora_agents/win32/bin/util/ifaces.vbs @@ -0,0 +1,34 @@ +on error resume next +'WMI real interfaces info +' exlusions: +' VBox network interfaces +' VMWare network interfaces +' +'nic where "guid is not null and not PNPDeviceID like 'ROOT%'" + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "NIC" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + +strComputer = "." +Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") +Set colAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter Where not PNPDeviceID like 'ROOT%%' and not PNPDeviceID like 'SW%%'") + +For Each iface In colAdapters +' return model MACAddress IPAddress + + set ifaces_cfg = objWMIService.ExecQuery("Select ipaddress from Win32_NetworkAdapterConfiguration Where Caption='" & iface.caption & "'") + Wscript.StdOut.Write " "" ) then + Wscript.StdOut.Write trim(iface_cfg.IPAddress(0)) + end if + next + wscript.stdOut.WriteLine "]]>" +Next + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" diff --git a/pandora_agents/win32/bin/util/moboinfo.vbs b/pandora_agents/win32/bin/util/moboinfo.vbs new file mode 100644 index 0000000000..74753c0db5 --- /dev/null +++ b/pandora_agents/win32/bin/util/moboinfo.vbs @@ -0,0 +1,22 @@ +on error resume next +'WMI mobo info + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "Motherboard" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + +strComputer = "." +Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") +'Set colMobos = objWMIService.ExecQuery("Select name,product,manufacturer from Win32_baseboard") +Set colMobos2 = objWMIService.ExecQuery("Select manufacturer,model,OEMStringArray from Win32_computersystem") + +For Each mobo In colMobos2 + Wscript.StdOut.WriteLine "" +Next + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + diff --git a/pandora_agents/win32/bin/util/monitors.vbs b/pandora_agents/win32/bin/util/monitors.vbs new file mode 100644 index 0000000000..c767a5a992 --- /dev/null +++ b/pandora_agents/win32/bin/util/monitors.vbs @@ -0,0 +1,25 @@ +on error resume next +'WMI monitorsinfo + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "Monitors" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + +strComputer = "." +Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") +Set colDisplays = objWMIService.ExecQuery("Select caption,pnpdeviceid from win32_desktopmonitor") + +For Each display In colDisplays + if (NOT isNull(display.pnpdeviceid)) then + Wscript.StdOut.WriteLine "" + end if +Next + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + diff --git a/pandora_agents/win32/bin/util/printers.vbs b/pandora_agents/win32/bin/util/printers.vbs new file mode 100644 index 0000000000..30c2d080ee --- /dev/null +++ b/pandora_agents/win32/bin/util/printers.vbs @@ -0,0 +1,51 @@ +On Error Resume Next + +'WMI printers attached + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "Printers" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + +function validPort(port) + if strComp(port,"SHRFAX:") = 0 then + validPort = false + elseif strComp(port,"nul:") = 0 then + validPort = false + elseif strComp(port,"PORTPROMPT:") = 0 then + validPort = false + elseif strComp(port,"XPSPort:") = 0 then + validPort = false + elseif strComp(port,"PDF:") = 0 then + validPort = false + else + validPort = true + end if +end function + +Set oWMI = GetObject("winmgmts:\\" & "." & "\root\cimv2") +Set colPrinters = oWMI.ExecQuery("Select * from Win32_Printer",,48) + +For Each objPrinter in colPrinters + if validPort (objPrinter.PortName) then + set tcp_port_exists = 0 + WScript.stdOut.Write "" + end if +Next + + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" diff --git a/pandora_agents/win32/bin/util/productID.vbs b/pandora_agents/win32/bin/util/productID.vbs new file mode 100644 index 0000000000..65764d9f0d --- /dev/null +++ b/pandora_agents/win32/bin/util/productID.vbs @@ -0,0 +1,24 @@ +' windows_product_key.vbs +' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) +' (c) 2015 Sancho Lerena +' This plugin extends agent inventory feature. Only enterprise version +' ---------------------------------------------------------------- + + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "product_ID" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + +Set oShell = WScript.CreateObject ("WScript.Shell") +Set objExec = oShell.Exec("cmd.exe /C wmic os get ""SerialNumber"" | find /v ""SerialNumber"" ") +Do + line = objExec.StdOut.ReadLine() + s = s & line +Loop While Not objExec.Stdout.atEndOfStream + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" diff --git a/pandora_agents/win32/bin/util/productkey.vbs b/pandora_agents/win32/bin/util/productkey.vbs new file mode 100644 index 0000000000..39eb490f5d --- /dev/null +++ b/pandora_agents/win32/bin/util/productkey.vbs @@ -0,0 +1,25 @@ +' windows_product_key.vbs +' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) +' (c) 2015 Sancho Lerena +' This plugin extends agent inventory feature. Only enterprise version +' ---------------------------------------------------------------- + +on error resume next + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "product_key" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + +strComputer = "." +Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") +Set colProducts = objWMIService.ExecQuery("Select OA3xOriginalProductKey from SoftwareLicensingService") + +For Each product In colProducts + Wscript.StdOut.WriteLine "" +Next + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" diff --git a/pandora_agents/win32/bin/util/raminfo.vbs b/pandora_agents/win32/bin/util/raminfo.vbs new file mode 100644 index 0000000000..ee4e1ced98 --- /dev/null +++ b/pandora_agents/win32/bin/util/raminfo.vbs @@ -0,0 +1,24 @@ +on error resume next +'WMI raminfo + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "RAM" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + +strComputer = "." +Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") +Set colRAMs = objWMIService.ExecQuery("Select deviceLocator,capacity,speed from Win32_PhysicalMemory") + +For Each ram In colRAMs + Wscript.StdOut.WriteLine "" +Next + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + diff --git a/pandora_agents/win32/bin/util/software_installed.vbs b/pandora_agents/win32/bin/util/software_installed.vbs index a82626577b..39ee5fd946 100644 --- a/pandora_agents/win32/bin/util/software_installed.vbs +++ b/pandora_agents/win32/bin/util/software_installed.vbs @@ -1,72 +1,143 @@ -' software_inventory.vbs -' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) -' (c) 2014 Sancho Lerena -' This plugin extends agent inventory feature. Only enterprise version -' ---------------------------------------------------------------- -' usage: cscript //B software_inventory.vbs +' +' Windows information retriever: Software Installed +' +' WMI/REGISTRY based +' (c) 2015 Sancho Lerena +' (c) 2015 Borja Sanchez +'-------------------------------------------------------- +on error resume next +Class ObjectList + Public List + Sub Class_Initialize() + Set List = CreateObject("Scripting.Dictionary") + End Sub + + Sub Class_Terminate() + Set List = Nothing + End Sub + + Function Append(Anything) + List.Add CStr(List.Count + 1), Anything + Set Append = Anything + End Function + + Function Item(id) + If List.Exists(CStr(id)) Then + Set Item = List(CStr(id)) + Else + Set Item = Nothing + End If + End Function +End Class + +class AppClass + dim InstallDate,Caption,Version,Vendor +end class + +' Print the XML structure Wscript.StdOut.WriteLine "" -Wscript.StdOut.WriteLine"" -Wscript.StdOut.WriteLine "software" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "Software" Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" +'------ Checks if an item exists on the main collection +function isItemInArray(objeto,coleccion) + for each id in coleccion.List + if (strComp(objeto,coleccion.List(id).caption) = 0) then + isItemInArray=true + exit function + end if + next + isItemInArray=false +end function + +'------ main collection definition +dim colObjSW : set colObjSW = new ObjectList +strComputer = "." + +'------ Retrieve the WMI registers first +Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") +Set colSoftware = objWMIService.ExecQuery ("SELECT installstate,caption,installdate,Version,vendor FROM Win32_Product") + + +'------ Check all +'-- first) add all unique WMI (unique) entries to main collector +'-- second) add all unique REGISTRY items to main collector + +for each objSoftware in colSoftware + if ( objSoftware.installstate = 5 ) then + if ( isItemInArray(objSoftware.caption, colObjSW) = false ) then + ' It doesn't exists, added. + With colObjSW.Append(New AppClass) + .caption = objSoftware.caption + .InstallDate = objSoftware.InstallDate + .version = objSoftware.version + .vendor = objSoftware.vendor + End with + ' Add to XML the verified ones + Wscript.StdOut.WriteLine "" + end if + end if +next + +' ------ Getting the REGISTRY Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE -strComputer = "." + strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" strEntry1a = "DisplayName" strEntry1b = "QuietDisplayName" strEntry2 = "InstallDate" -strEntry3 = "VersionMajor" -strEntry4 = "VersionMinor" -strEntry5 = "EstimatedSize" +strEntry3 = "DisplayVersion" -Set objReg = GetObject("winmgmts://" & strComputer & _ - "/root/default:StdRegProv") +Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv") objReg.EnumKey HKLM, strKey, arrSubkeys For Each strSubkey In arrSubkeys - appname = "" appsize = "" appversion = "" appdate = "" - intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _ - strEntry1a, strValue1) + intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, strEntry1a, strValue1) If intRet1 <> 0 Then - objReg.GetStringValue HKLM, strKey & strSubkey, _ - strEntry1b, strValue1 + objReg.GetStringValue HKLM, strKey & strSubkey, strEntry1b, strValue1 End If If strValue1 <> "" Then appname = strValue1 End If - objReg.GetStringValue HKLM, strKey & strSubkey, _ - strEntry2, strValue2 + objReg.GetStringValue HKLM, strKey & strSubkey, strEntry2, strValue2 If strValue2 <> "" Then appdate = strValue2 End If - objReg.GetDWORDValue HKLM, strKey & strSubkey, _ - strEntry3, intValue3 - objReg.GetDWORDValue HKLM, strKey & strSubkey, _ - strEntry4, intValue4 + + objReg.GetStringValue HKLM, strKey & strSubkey, strEntry3, intValue3 If intValue3 <> "" Then - appversion = intValue3 & "." & intValue4 + appversion = intValue3 End If - objReg.GetDWORDValue HKLM, strKey & strSubkey, _ - strEntry5, intValue5 - If intValue5 <> "" Then - appsize = Round(intValue5/1024, 3) & " megabytes" - End If If appname <> "" Then - Wscript.StdOut.WriteLine "" & appname & ";" & appversion & ";" & appdate & ";" & appsize & "" + ' foreach registry item, check if exists in the main collector + ' it it exists, it doesn't be added. + if ( isItemInArray(appname, colObjSW) = false ) then + ' as item doesn't exist, we add it to main collector and to XML + With colObjSW.Append(New AppClass) + .caption = appname + .version = appversion + End with + Wscript.StdOut.WriteLine "" + end if end if - -Next +next +' Closing the XML structure Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" + diff --git a/pandora_agents/win32/bin/util/userslogged.vbs b/pandora_agents/win32/bin/util/userslogged.vbs new file mode 100644 index 0000000000..5251f23573 --- /dev/null +++ b/pandora_agents/win32/bin/util/userslogged.vbs @@ -0,0 +1,69 @@ +on error resume next +' Lista todos los usuarios del equipo que han iniciado procesos + +dim loggedUsers(),i +i=0 +Sub insertIfNotExists(sDomain,sUser) + For Each lUser in loggedUsers + If StrComp(sDomain & "\" & sUser, lUser) = 0 Then + Exit Sub + End If + Next + redim preserve loggedUsers(i) + i=i+1 + loggedUsers (i-1)=sDomain & "\" & sUser +End Sub + +Function CheckRealUser(sHost, sUser, sDomain) + Dim oWMI,realUsers + Set oWmi = GetObject("winmgmts:{impersonationLevel=impersonate,(debug)}!\\" _ + & sHost & "\root\cimv2") + Set realUsers = oWmi.ExecQuery("SELECT * FROM Win32_UserAccount WHERE Domain='" & sDomain & "' OR Name='" & sUser & "'") + If (realUsers.count=0) Then + CheckRealUser = False + Else + CheckRealUser = True + End If + +End Function + +Function ConsoleUser(sHost) + Dim oWMI, colProc, oProcess, strUser, strDomain + Set oWmi = GetObject("winmgmts:" _ + & "{impersonationLevel=impersonate,(debug)}!\\" _ + & sHost & "\root\cimv2") + + Set colProc = oWmi.ExecQuery("Select sessionID from Win32_Process") + + ConsoleUser = "" + For Each oProcess In colProc + lRet = oProcess.getOwner(strOwner, strDomain) + If (lRet = 0) AND (CheckRealUser(sHost,strOwner,strDomain)) Then + insertIfNotExists strDomain,strOwner + ConsoleUser = sUser + End If + Next +End Function + +' MAIN + +sUser = ConsoleUser(".") ' use "." for local computer + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "Users" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + + +For Each usuario in loggedUsers + Wscript.StdOut.WriteLine "" +next + + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + + diff --git a/pandora_agents/win32/bin/util/videocardinfo.vbs b/pandora_agents/win32/bin/util/videocardinfo.vbs new file mode 100644 index 0000000000..e7766c90ba --- /dev/null +++ b/pandora_agents/win32/bin/util/videocardinfo.vbs @@ -0,0 +1,24 @@ +on error resume next +'WMI video_card_info + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "VideoCards" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + +strComputer = "." +Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") +Set colVideoCards = objWMIService.ExecQuery("Select caption,AdapterRAM,PNPDeviceID from win32_videocontroller") + +For Each vcard In colVideoCards + Wscript.StdOut.WriteLine "" +Next + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + From 01a2383a3bf7d7f0793453ed618ef0bde7ef319c Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Fri, 24 Apr 2015 12:22:53 +0200 Subject: [PATCH 2/3] Fixed problems with plugins --- pandora_agents/win32/bin/util/cdromdrives.vbs | 6 ++++- pandora_agents/win32/bin/util/cpuinfo.vbs | 2 +- pandora_agents/win32/bin/util/diskdrives.vbs | 22 ++++++++++++++----- pandora_agents/win32/bin/util/ifaces.vbs | 10 ++++++++- pandora_agents/win32/bin/util/moboinfo.vbs | 4 ++++ pandora_agents/win32/bin/util/monitors.vbs | 4 ++++ pandora_agents/win32/bin/util/printers.vbs | 22 +++++++++++++------ pandora_agents/win32/bin/util/productID.vbs | 2 +- pandora_agents/win32/bin/util/raminfo.vbs | 8 +++++-- .../win32/bin/util/software_installed.vbs | 8 +++---- pandora_agents/win32/bin/util/userslogged.vbs | 9 ++++++-- .../win32/bin/util/videocardinfo.vbs | 8 +++++-- 12 files changed, 77 insertions(+), 28 deletions(-) diff --git a/pandora_agents/win32/bin/util/cdromdrives.vbs b/pandora_agents/win32/bin/util/cdromdrives.vbs index 8edd6a8172..fc73a2bd32 100644 --- a/pandora_agents/win32/bin/util/cdromdrives.vbs +++ b/pandora_agents/win32/bin/util/cdromdrives.vbs @@ -1,9 +1,13 @@ +' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) +' (c) 2015 Borja Sanchez +' This plugin extends agent inventory feature. Only enterprise version +' -------------------------------------------------------------------------- on error resume next 'WMI CD_ROM_drives_info Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" -Wscript.StdOut.WriteLine "CDROMs" +Wscript.StdOut.WriteLine "CDROM" Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" diff --git a/pandora_agents/win32/bin/util/cpuinfo.vbs b/pandora_agents/win32/bin/util/cpuinfo.vbs index cd65e2dcfd..4255ec9b77 100644 --- a/pandora_agents/win32/bin/util/cpuinfo.vbs +++ b/pandora_agents/win32/bin/util/cpuinfo.vbs @@ -12,7 +12,7 @@ Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\ Set colCPUs = objWMIService.ExecQuery("Select name,maxclockspeed,caption from Win32_Processor") For Each cpu In colCPUs - Wscript.StdOut.WriteLine "" + Wscript.StdOut.WriteLine "" Next Wscript.StdOut.WriteLine "" diff --git a/pandora_agents/win32/bin/util/diskdrives.vbs b/pandora_agents/win32/bin/util/diskdrives.vbs index 3cba8eb106..57ec380b6e 100644 --- a/pandora_agents/win32/bin/util/diskdrives.vbs +++ b/pandora_agents/win32/bin/util/diskdrives.vbs @@ -1,21 +1,31 @@ +' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) +' (c) 2015 Borja Sanchez +' This plugin extends agent inventory feature. Only enterprise version +' -------------------------------------------------------------------------- on error resume next 'WMI disksinfo Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" -Wscript.StdOut.WriteLine "Disks" +Wscript.StdOut.WriteLine "HD" Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") -Set colHDDs = objWMIService.ExecQuery("Select caption,size,serialnumber from win32_diskdrive") +Set colHDDs = objWMIService.ExecQuery("Select * from win32_diskdrive") For Each disco In colHDDs - Wscript.StdOut.WriteLine "" + If ((not IsNull(disco.size)) AND (disco.size > 0)) then + Wscript.StdOut.Write "" + End If Next Wscript.StdOut.WriteLine "" diff --git a/pandora_agents/win32/bin/util/ifaces.vbs b/pandora_agents/win32/bin/util/ifaces.vbs index 45be437a78..d08d23bc5e 100644 --- a/pandora_agents/win32/bin/util/ifaces.vbs +++ b/pandora_agents/win32/bin/util/ifaces.vbs @@ -1,3 +1,7 @@ +' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) +' (c) 2015 Borja Sanchez +' This plugin extends agent inventory feature. Only enterprise version +' -------------------------------------------------------------------------- on error resume next 'WMI real interfaces info ' exlusions: @@ -14,7 +18,11 @@ Wscript.StdOut.WriteLine "" strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") -Set colAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter Where not PNPDeviceID like 'ROOT%%' and not PNPDeviceID like 'SW%%'") +Set colAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter " & _ + "Where not PNPDeviceID like 'ROOT%%' " & _ + "and not PNPDeviceID like 'SW%%' " & _ + "and not ServiceName is null " & _ + "and not ServiceName like 'vwifimp' ") For Each iface In colAdapters ' return model MACAddress IPAddress diff --git a/pandora_agents/win32/bin/util/moboinfo.vbs b/pandora_agents/win32/bin/util/moboinfo.vbs index 74753c0db5..5557d894c0 100644 --- a/pandora_agents/win32/bin/util/moboinfo.vbs +++ b/pandora_agents/win32/bin/util/moboinfo.vbs @@ -1,3 +1,7 @@ +' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) +' (c) 2015 Borja Sanchez +' This plugin extends agent inventory feature. Only enterprise version +' -------------------------------------------------------------------------- on error resume next 'WMI mobo info diff --git a/pandora_agents/win32/bin/util/monitors.vbs b/pandora_agents/win32/bin/util/monitors.vbs index c767a5a992..7655d18328 100644 --- a/pandora_agents/win32/bin/util/monitors.vbs +++ b/pandora_agents/win32/bin/util/monitors.vbs @@ -1,3 +1,7 @@ +' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) +' (c) 2015 Borja Sanchez +' This plugin extends agent inventory feature. Only enterprise version +' -------------------------------------------------------------------------- on error resume next 'WMI monitorsinfo diff --git a/pandora_agents/win32/bin/util/printers.vbs b/pandora_agents/win32/bin/util/printers.vbs index 30c2d080ee..c664ca33b5 100644 --- a/pandora_agents/win32/bin/util/printers.vbs +++ b/pandora_agents/win32/bin/util/printers.vbs @@ -1,3 +1,7 @@ +' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) +' (c) 2015 Borja Sanchez +' This plugin extends agent inventory feature. Only enterprise version +' -------------------------------------------------------------------------- On Error Resume Next 'WMI printers attached @@ -33,13 +37,17 @@ For Each objPrinter in colPrinters WScript.stdOut.Write "" end if diff --git a/pandora_agents/win32/bin/util/productID.vbs b/pandora_agents/win32/bin/util/productID.vbs index 65764d9f0d..f25376ef29 100644 --- a/pandora_agents/win32/bin/util/productID.vbs +++ b/pandora_agents/win32/bin/util/productID.vbs @@ -3,7 +3,7 @@ ' (c) 2015 Sancho Lerena ' This plugin extends agent inventory feature. Only enterprise version ' ---------------------------------------------------------------- - +on error resume next Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" diff --git a/pandora_agents/win32/bin/util/raminfo.vbs b/pandora_agents/win32/bin/util/raminfo.vbs index ee4e1ced98..8750346314 100644 --- a/pandora_agents/win32/bin/util/raminfo.vbs +++ b/pandora_agents/win32/bin/util/raminfo.vbs @@ -1,3 +1,7 @@ +' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) +' (c) 2015 Borja Sanchez +' This plugin extends agent inventory feature. Only enterprise version +' -------------------------------------------------------------------------- on error resume next 'WMI raminfo @@ -13,8 +17,8 @@ Set colRAMs = objWMIService.ExecQuery("Select deviceLocator,capacity,speed from For Each ram In colRAMs Wscript.StdOut.WriteLine "" Next diff --git a/pandora_agents/win32/bin/util/software_installed.vbs b/pandora_agents/win32/bin/util/software_installed.vbs index 39ee5fd946..4317a06732 100644 --- a/pandora_agents/win32/bin/util/software_installed.vbs +++ b/pandora_agents/win32/bin/util/software_installed.vbs @@ -1,10 +1,8 @@ -' -' Windows information retriever: Software Installed -' -' WMI/REGISTRY based +' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) ' (c) 2015 Sancho Lerena ' (c) 2015 Borja Sanchez -'-------------------------------------------------------- +' This plugin extends agent inventory feature. Only enterprise version +' -------------------------------------------------------------------------- on error resume next Class ObjectList diff --git a/pandora_agents/win32/bin/util/userslogged.vbs b/pandora_agents/win32/bin/util/userslogged.vbs index 5251f23573..fcf810015e 100644 --- a/pandora_agents/win32/bin/util/userslogged.vbs +++ b/pandora_agents/win32/bin/util/userslogged.vbs @@ -1,3 +1,7 @@ +' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) +' (c) 2015 Borja Sanchez +' This plugin extends agent inventory feature. Only enterprise version +' -------------------------------------------------------------------------- on error resume next ' Lista todos los usuarios del equipo que han iniciado procesos @@ -57,8 +61,9 @@ Wscript.StdOut.WriteLine "" For Each usuario in loggedUsers - Wscript.StdOut.WriteLine "" + Wscript.StdOut.WriteLine "" next diff --git a/pandora_agents/win32/bin/util/videocardinfo.vbs b/pandora_agents/win32/bin/util/videocardinfo.vbs index e7766c90ba..807b567c29 100644 --- a/pandora_agents/win32/bin/util/videocardinfo.vbs +++ b/pandora_agents/win32/bin/util/videocardinfo.vbs @@ -1,9 +1,13 @@ +' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms) +' (c) 2015 Borja Sanchez +' This plugin extends agent inventory feature. Only enterprise version +' -------------------------------------------------------------------------- on error resume next 'WMI video_card_info Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" -Wscript.StdOut.WriteLine "VideoCards" +Wscript.StdOut.WriteLine "Video" Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" @@ -13,7 +17,7 @@ Set colVideoCards = objWMIService.ExecQuery("Select caption,AdapterRAM,PNPDevice For Each vcard In colVideoCards Wscript.StdOut.WriteLine "" Next From 3ee1cfacd9b9cad0f1a592766ce3d204bc116677 Mon Sep 17 00:00:00 2001 From: artica Date: Tue, 28 Apr 2015 00:01:15 +0200 Subject: [PATCH 3/3] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_console/pandoradb_data.sql | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 2aedb1a757..87eebfb5a9 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 6.0dev-150427 +Version: 6.0dev-150428 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 490df892cf..493410153f 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="6.0dev-150427" +pandora_version="6.0dev-150428" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 7ca44dcb8f..7af5a01e7a 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '6.0dev'; -use constant AGENT_BUILD => '150427'; +use constant AGENT_BUILD => '150428'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index a9927948cd..6a7e2903fa 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150427 +%define release 150428 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index e906675e87..3e34bc2e82 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150427 +%define release 150428 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index fbed5b1a66..40f9742f36 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150427} +{150428} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 81fc0d6fdb..8ae1cf01c3 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("6.0dev(Build 150427)") +#define PANDORA_VERSION ("6.0dev(Build 150428)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index b7aa57760d..6573bceb9b 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(6.0dev(Build 150427))" + VALUE "ProductVersion", "(6.0dev(Build 150428))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 9f50b8e7e4..96cb896d1f 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 6.0dev-150427 +Version: 6.0dev-150428 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 7215ec29ff..68269465bf 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="6.0dev-150427" +pandora_version="6.0dev-150428" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index cea3cc58a9..c9df706a64 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC150427'; +$build_version = 'PC150428'; $pandora_version = 'v6.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index ed86d2a7bd..582edee663 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -63,7 +63,7 @@