Merge remote-tracking branch 'origin/develop' into features/oracle

This commit is contained in:
Alejandro Gallardo Escobar 2015-05-04 16:44:40 +02:00
commit b78dbf1c0d
57 changed files with 896 additions and 98 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 6.0dev-150427
Version: 6.0dev-150504
Architecture: all
Priority: optional
Section: admin

View File

@ -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-150504"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -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 => '150504';
# Commands to retrieve total memory information in kB
use constant TOTALMEMORY_CMDS => {

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 6.0dev
%define release 150427
%define release 150504
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 6.0dev
%define release 150427
%define release 150504
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -19,7 +19,7 @@
server_ip $ServerIP$
server_path /var/spool/pandora/data_in
temporal "$AgentTemp$"
temporal "C:\Program Files\pandora_agent\temp"
#include "C:\Archivos de programa\pandora_agent\pandora_agent_alt.conf"
#broker_agent name_agent
@ -47,7 +47,7 @@ address auto
#address 192.168.36.73
# Group assigned for this agent (descriptive, p.e: Servers)
group "$AgentGroup$"
group Servers
# This limits operation if temporal dir has not enough free disk.
#temporal_min_size 1024
@ -191,13 +191,85 @@ 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
module_begin
module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\architecture.vbs"
module_crontab * 12-15 * * 1
module_end
module_begin
module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\domain.vbs"
module_crontab * 12-15 * * 1
module_end
module_begin
module_plugin cscript.exe //B "%PROGRAMFILES%\Pandora_Agent\util\osversion.vbs"
module_crontab * 12-15 * * 1
module_end
# ----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,25 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
on error resume next
'WMI architecture
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>Architecture</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set cols = objWMIService.ExecQuery("Select osarchitecture from Win32_OperatingSystem")
For Each data In cols
Wscript.StdOut.WriteLine "<data><![CDATA[" & data.osarchitecture & "]]></data>"
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,29 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
on error resume next
'WMI CD_ROM_drives_info
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>CDROM</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
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 "<data><![CDATA[" & cdromd.caption _
& ";" & cdromd.description _
& ";" & cdromd.drive _
& ";" & cdromd.deviceid _
& "]]></data>"
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,25 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
on error resume next
'WMI cpuinfo
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>CPU</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
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 "<data><![CDATA[" & cpu.name & ";" & cpu.maxclockspeed & " MHz;" & cpu.caption & "]]></data>"
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,34 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
on error resume next
'WMI disksinfo
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>HD</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colHDDs = objWMIService.ExecQuery("Select * from win32_diskdrive")
For Each disco In colHDDs
If ((not IsNull(disco.size)) AND (disco.size > 0)) then
Wscript.StdOut.Write "<data><![CDATA[" & disco.caption _
& ";" & Abs(Round((disco.size/(1024*1024*1024)),2)) & " GB"
If (not IsNull(disco.serialnumber)) then
Wscript.StdOut.Write ";" & disco.serialnumber
Else
Wscript.StdOut.Write ";" & disco.signature
End If
Wscript.StdOut.WriteLine "]]></data>"
End If
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,25 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
on error resume next
'WMI domain/workgroup info
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>Domain</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT Domain FROM Win32_ComputerSystem")
For Each objItem In colItems
WScript.StdOut.WriteLine "<data><![CDATA[" & objItem.Domain & "]]></data>"
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,42 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
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 "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>NIC</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
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%%' " & _
"and not ServiceName is null " & _
"and not ServiceName like 'vwifimp' ")
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 "<data><![CDATA[" & iface.ProductName & ";" & iface.MACAddress & ";"
for each iface_cfg in ifaces_cfg
if ( iface_cfg.IPAddress(0) <> "" ) then
Wscript.StdOut.Write trim(iface_cfg.IPAddress(0))
end if
next
wscript.stdOut.WriteLine "]]></data>"
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,26 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
on error resume next
'WMI mobo info
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>Motherboard</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
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 "<data><![CDATA[" & mobo.manufacturer & ";" & mobo.model & ";" & mobo.OEMStringArray(0) & "]]></data>"
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,29 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
on error resume next
'WMI monitorsinfo
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>Monitors</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
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 "<data><![CDATA[" & display.caption _
& ";" & display.pnpdeviceid _
& "]]></data>"
end if
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,25 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
on error resume next
'WMI OS version
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>OSVersion</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set cols = objWMIService.ExecQuery("SELECT version from win32_operatingsystem")
For Each data In cols
Wscript.StdOut.WriteLine "<data><![CDATA[" & data.version & "]]></data>"
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,59 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
On Error Resume Next
'WMI printers attached
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>Printers</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
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 "<data><![CDATA[" & _
objPrinter.DeviceID & ";" & _
objPrinter.DriverName & ";"
If (objPrinter.Local) Then
Set colPorts = oWMI.ExecQuery("Select HostAddress from Win32_TCPIPPrinterPort where Name like '" & objPrinter.PortName & "'",,48)
For Each objPort in colPorts
tcp_port_exists = 1
Wscript.stdOut.Write objPort.HostAddress
Next
If (tcp_port_exists = 0) Then
Wscript.stdOut.Write objPrinter.PortName
End If
Else
Wscript.stdOut.Write objPrinter.ServerName
End If
wscript.stdOut.WriteLine "]]></data>"
end if
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,24 @@
' windows_product_key.vbs
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Sancho Lerena <slerena@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' ----------------------------------------------------------------
on error resume next
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>product_ID</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
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 "<data><![CDATA[" & Replace(Replace(s, chr(013), ""), chr(010), "") & "]]></data>"
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,25 @@
' windows_product_key.vbs
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Sancho Lerena <slerena@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' ----------------------------------------------------------------
on error resume next
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>product_key</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
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 "<data><![CDATA[" & product.OA3xOriginalProductKey & "]]></data>"
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,28 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
on error resume next
'WMI raminfo
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>RAM</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
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 "<data><![CDATA[" & ram.deviceLocator _
& ";" & Abs(Round((ram.capacity/(1024*1024)),2)) & " MB" _
& ";" & ram.speed & " MHz"_
& "]]></data>"
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -1,72 +1,141 @@
' software_inventory.vbs
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2014 Sancho Lerena <slerena@artica.es>
' (c) 2015 Sancho Lerena <slerena@artica.es>
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' ----------------------------------------------------------------
' usage: cscript //B software_inventory.vbs
' --------------------------------------------------------------------------
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 "<inventory>"
Wscript.StdOut.WriteLine"<inventory_module>"
Wscript.StdOut.WriteLine "<name>software</name>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>Software</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
'------ 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 "<data><![CDATA[" _
& objSoftware.caption & ";" _
& objSoftware.version _
& "]]></data>"
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 "<data>" & appname & ";" & appversion & ";" & appdate & ";" & appsize & "</data>"
' 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 "<data><![CDATA[" & appname & ";" & appversion & "]]></data>"
end if
end if
Next
next
' Closing the XML structure
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,74 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
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 "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>Users</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
For Each usuario in loggedUsers
Wscript.StdOut.WriteLine "<data><![CDATA[" & split(usuario,"\")(0) _
& ";" & split(usuario,"\")(1) _
& "]]></data>"
next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -0,0 +1,28 @@
' Pandora FMS Agent Inventory Plugin for Microsoft Windows (All platfforms)
' (c) 2015 Borja Sanchez <fborja.sanchez@artica.es>
' This plugin extends agent inventory feature. Only enterprise version
' --------------------------------------------------------------------------
on error resume next
'WMI video_card_info
Wscript.StdOut.WriteLine "<inventory>"
Wscript.StdOut.WriteLine "<inventory_module>"
Wscript.StdOut.WriteLine "<name>Video</name>"
Wscript.StdOut.WriteLine "<type><![CDATA[generic_data_string]]></type>"
Wscript.StdOut.WriteLine "<datalist>"
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 "<data><![CDATA[" & vcard.caption _
& ";" & Round(Abs(vcard.AdapterRAM/(1024*1024)),2) & " MB" _
& ";" & vcard.PNPDeviceID _
& "]]></data>"
Next
Wscript.StdOut.WriteLine "</datalist>"
Wscript.StdOut.WriteLine "</inventory_module>"
Wscript.StdOut.WriteLine "</inventory>"

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{150427}
{150504}
ViewReadme
{Yes}

View File

@ -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 150504)")
string pandora_path;
string pandora_dir;

View File

@ -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 150504))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 6.0dev-150427
Version: 6.0dev-150504
Architecture: all
Priority: optional
Section: admin

View File

@ -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-150504"
package_pear=0
package_pandora=1

File diff suppressed because one or more lines are too long

View File

@ -214,6 +214,7 @@ foreach ($layoutDatas as $layoutData) {
case STATIC_GRAPH:
case ICON:
case GROUP_ITEM:
case SERVICE:
$table->data[$i + 1][1] =
html_print_select ($images_list,
'image_' . $idLayoutData, $layoutData['image'], '',

View File

@ -292,7 +292,7 @@ switch ($activeTab) {
$values['id_layout_linked'] = get_parameter('map_linked_' . $id, 0);
if (enterprise_installed()) {
enterprise_visual_map_update_action_from_list_elements($type, $values);
enterprise_visual_map_update_action_from_list_elements($type, $values, $id);
}
db_process_sql_update('tlayout_data', $values, array('id' => $id));

View File

@ -61,7 +61,7 @@ $table->head = array ();
$table->head[0] = __('Name');
$table->head[1] = __('Status');
$table->head[2] = __('Type');
$table->head[3] = __('Load') . ui_print_help_tip (__("Modules running on this server / Total modules of this type"), true);
$table->head[3] = __('Version');
$table->head[4] = __('Modules');
$table->head[5] = __('Lag') . ui_print_help_tip (__("Avg. Delay(sec)/Modules delayed"), true);
$table->head[6] = __('T/Q') . ui_print_help_tip (__("Threads / Queued modules currently"), true);
@ -93,22 +93,22 @@ foreach ($servers as $server) {
if ($server["master"] == 1){
$data[2] .= ui_print_help_tip (__("This is a master server"), true);
}
$data[2] .= '</span> <span style="font-size:8px;"> v' . $server["version"]. '</span>';
//$data[2] .= '</span> <span style="font-size:8px;"> v' .. '</span>';
switch ($server['type']) {
case "snmp":
case "event":
$data[3] = 'N/A';
$data[3] = $server["version"];
$data[4] = 'N/A';
$data[5] = 'N/A';
break;
case "export":
$data[3] = progress_bar($server["load"], 100, 10, $server["lag_txt"], 0);
$data[3] = $server["version"];
$data[4] = $server["modules"] . " ".__('of')." ". $server["modules_total"];
$data[5] = 'N/A';
break;
default:
$data[3] = progress_bar($server["load"], 100, 10, $server["lag_txt"], 0);
$data[3] = $server["version"];
$data[4] = $server["modules"] . " ".__('of')." ". $server["modules_total"];
$data[5] = '<span style="white-space:nowrap;">' .
$server["lag_txt"] . '</span>';

View File

@ -22,7 +22,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC150427';
$build_version = 'PC150504';
$pandora_version = 'v6.0dev';
// Do not overwrite default timezone set if defined.

View File

@ -22,7 +22,6 @@
require_once($config['homedir'] . '/include/functions.php');
require_once($config['homedir'] . "/include/functions_modules.php");
require_once($config['homedir'] . '/include/functions_users.php');
enterprise_include_once('/include/functions_agents.php');
/**
* Check the agent exists in the DB.
@ -1815,6 +1814,7 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
"Deleted agent '$agent_name'");
// Delete the agent from the metaconsole cache
enterprise_include_once('include/functions_agents.php');
enterprise_hook('agent_delete_from_cache', array($id_agent));
/* Break the loop on error */

View File

@ -1359,8 +1359,8 @@ function config_check () {
}
// Get remote file dir.
$remote_config = db_get_value_filter('value',
'tconfig', array('token' => 'remote_config'));
$remote_config = io_safe_output(db_get_value_filter('value',
'tconfig', array('token' => 'remote_config')));
if (enterprise_installed()) {
@ -1412,7 +1412,7 @@ function config_check () {
__("Database maintance problem"));
}
$fontpath = db_get_value_filter('value', 'tconfig', array('token' => 'fontpath'));
$fontpath = io_safe_output(db_get_value_filter('value', 'tconfig', array('token' => 'fontpath')));
if (($fontpath == "") OR (!file_exists ($fontpath))) {
set_pandora_error_for_header(
__('Your defined font doesnt exist or is not defined. Please check font parameters in your config'),

View File

@ -8,7 +8,7 @@
<p>
Defines the number of alerts that must occur before executing the action. It is a fine-tunning parameter.<br><br>
This allows "redefine" a little more the alert behavior, so that if we set a maximum of 5 times the times you can fire a warning, and we just want to send us an email, we will set here 0 and 1 , to say that we only send an email from time 0 to 1 (so, once). <br> <br>
This allows "redefine" a little more the alert behavior, so that if we set a maximum of 5 times the times you can fire a warning, and we just want to send us an email, we will set here 0 and 1 , to say that we only send an email from time 0 to 1 (so, once). When an alert recovers, all the actions that have been executed up to that point will be executed again.<br> <br>
Now we see that we can add more actions to the same alert, defining these fields "Number of alerts match from" alert behavior depending on how often you shoot. <br> <br>

View File

@ -0,0 +1,7 @@
<?php
/* Include package help/en
*/
?>
<p>For the metaconsole agent cache to work, Make sure <b>Metaconsole DB host</b>, <b>Metaconsole DB name</b>, <b>Metaconsole DB user</b>, <b>Metaconsole DB password</b> and <b>Metaconsole DB port</b> are properly configured.</p>

View File

@ -7,7 +7,7 @@
<p>
Define el número de alertas que deben ocurrir antes de ejecutar la acción. Es un parámetro de ajuste fino.<br><br>
Esto permite "redefinir" un poco más el comportamiento de la alerta, de forma que si hemos definido un máximo de 5 veces las veces que se puede disparar una alerta, y sólo queremos que nos envie un email, pondremos aquí un 0 y un 1, para decirle que sólo nos envie un email desde la vez 0 a la 1 (osea, una vez).<br><br>
Esto permite "redefinir" un poco más el comportamiento de la alerta, de forma que si hemos definido un máximo de 5 veces las veces que se puede disparar una alerta, y sólo queremos que nos envie un email, pondremos aquí un 0 y un 1, para decirle que sólo nos envie un email desde la vez 0 a la 1 (osea, una vez). Cuando una alerta se recupera, todas las acciones que se hayan ejecutado hasta ese momento se volverán a ejecutar.<br><br>
Ahora veremos que podemos añadir más acciones a la misma alerta, definiendo con estos campos "Number of alerts match from" el comportamiento de la alerta en función de cuantas veces se dispare.<br><br>

View File

@ -0,0 +1,7 @@
<?php
/* Include package help/es
*/
?>
<p>Para que funcione la caché de agentes de la metaconsola, asegúrese de que <b>Metaconsole DB host</b>, <b>Metaconsole DB name</b>, <b>Metaconsole DB user</b>, <b>Metaconsole DB password</b> y <b>Metaconsole DB port</b> están bien configurados.</p>

View File

@ -8,7 +8,7 @@
<p>
いくつアラートが上がった時にアクションを実行するかを定義します。これは、細かいチューニングパラメータです。<br><br>
これは、アラートの動作の定義を若干変更します。警告のアラートの回数を最大 5に設定した場合に、メールを一度のみ送信したい場合は、ここを 0 および 1 に設定します。0 から 1回目にのみ(つまり 1回のみ)メールを送信するという意味になります。<br><br>
これは、アラートの動作の定義を若干変更します。警告のアラートの回数を最大 5に設定した場合に、メールを一度のみ送信したい場合は、ここを 0 および 1 に設定します。0 から 1回目にのみ(つまり 1回のみ)メールを送信するという意味になります。When an alert recovers, all the actions that have been executed up to that point will be executed again.<br><br>
同一のアラートに複数のアクションを設定できますが、"アラートを起こす回数"を定義することにより、アラートの動作は頻度に依存するようになります。<br><br>

View File

@ -0,0 +1,6 @@
<?php
/* Include package help/ja
*/
?>
<p>For the metaconsole agent cache to work, Make sure <b>Metaconsole DB host</b>, <b>Metaconsole DB name</b>, <b>Metaconsole DB user</b>, <b>Metaconsole DB password</b> and <b>Metaconsole DB port</b> are properly configured.</p>

View File

@ -63,7 +63,7 @@
<div style='height: 10px'>
<?php
$version = '6.0dev';
$build = '150427';
$build = '150504';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -373,7 +373,7 @@ echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&s
echo "<td></td>";
echo "<td></td>";
} else {
echo "<td>" . ui_print_help_icon ('pcap_filter', true, ui_get_full_url(false, false, false, false)) . "</td>";
echo "<td>" . ui_print_help_icon ('pcap_filter', true) . "</td>";
echo "<td colspan='5'>" . html_print_textarea ('advanced_filter', 4, 40, $filter['advanced_filter'], "style='min-height: 0px; width: 90%;'", true) . "</td>";
}

View File

@ -291,7 +291,6 @@ if (!$meta) {
$data[1] = __('Home screen'). ui_print_help_tip(__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type sec=estado&sec2=operation/agentes/estado_agente to show agent detail view'), true);
$values = array (
'Default' =>__('Default'),
'Dashboard'=>__('Dashboard'),
'Visual console'=>__('Visual console'),
'Event list'=>__('Event list'),
'Group view'=>__('Group view'),

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 6.0dev
%define release 150427
%define release 150504
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 6.0dev
%define release 150427
%define release 150504
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

@ -38,7 +38,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('graph_res','5'),
('step_compact','1'),
('db_scheme_version','6.0dev'),
('db_scheme_build','PD150427'),
('db_scheme_build','PD150504'),
('show_unknown','0'),
('show_lastalerts','1'),
('style','pandora'),

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 6.0dev-150427
Version: 6.0dev-150504
Architecture: all
Priority: optional
Section: admin

View File

@ -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-150504"
package_cpan=0
package_pandora=1

View File

@ -107,7 +107,7 @@ sub pandora_startup () {
pandora_audit (\%Config, 'Pandora FMS Server Daemon starting', 'SYSTEM', 'System', $DBH);
# Load servers
if ($Config{"license_type"} != METACONSOLE_LICENSE) {
if (!defined($Config{"license_type"}) || $Config{"license_type"} != METACONSOLE_LICENSE) {
pandora_reset_server (\%Config, $DBH);
push (@Servers, new PandoraFMS::DataServer (\%Config, $DBH));
push (@Servers, new PandoraFMS::NetworkServer (\%Config, $DBH));

View File

@ -43,7 +43,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "6.0dev";
my $pandora_build = "150427";
my $pandora_build = "150504";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -647,15 +647,26 @@ sub pandora_execute_alert ($$$$$$$$;$) {
# Simple alert
if (defined ($alert->{'id_template_module'})) {
@actions = get_db_rows ($dbh, 'SELECT *, talert_template_module_actions.id AS id_alert_template_module_actions
FROM talert_template_module_actions, talert_actions, talert_commands
WHERE talert_template_module_actions.id_alert_action = talert_actions.id
AND talert_actions.id_alert_command = talert_commands.id
AND talert_template_module_actions.id_alert_template_module = ?
AND ((fires_min = 0 AND fires_max = 0)
OR (fires_min <= fires_max AND ? >= fires_min AND ? <= fires_max)
OR (fires_min > fires_max AND ? >= fires_min))',
$alert->{'id_template_module'}, $alert->{'times_fired'}, $alert->{'times_fired'}, $alert->{'times_fired'});
if ($alert_mode == RECOVERED_ALERT) {
@actions = get_db_rows ($dbh, 'SELECT *, talert_template_module_actions.id AS id_alert_template_module_actions
FROM talert_template_module_actions, talert_actions, talert_commands
WHERE talert_template_module_actions.id_alert_action = talert_actions.id
AND talert_actions.id_alert_command = talert_commands.id
AND talert_template_module_actions.id_alert_template_module = ?
AND ((fires_min = 0 AND fires_max = 0)
OR ? >= fires_min)',
$alert->{'id_template_module'}, $alert->{'times_fired'});
} else {
@actions = get_db_rows ($dbh, 'SELECT *, talert_template_module_actions.id AS id_alert_template_module_actions
FROM talert_template_module_actions, talert_actions, talert_commands
WHERE talert_template_module_actions.id_alert_action = talert_actions.id
AND talert_actions.id_alert_command = talert_commands.id
AND talert_template_module_actions.id_alert_template_module = ?
AND ((fires_min = 0 AND fires_max = 0)
OR (fires_min <= fires_max AND ? >= fires_min AND ? <= fires_max)
OR (fires_min > fires_max AND ? >= fires_min))',
$alert->{'id_template_module'}, $alert->{'times_fired'}, $alert->{'times_fired'}, $alert->{'times_fired'});
}
# Get default action
if ($#actions < 0) {
@ -667,15 +678,25 @@ sub pandora_execute_alert ($$$$$$$$;$) {
}
# Event alert
else {
@actions = get_db_rows ($dbh, 'SELECT * FROM tevent_alert_action, talert_actions, talert_commands
WHERE tevent_alert_action.id_alert_action = talert_actions.id
AND talert_actions.id_alert_command = talert_commands.id
AND tevent_alert_action.id_event_alert = ?
AND ((fires_min = 0 AND fires_max = 0)
OR (fires_min <= fires_max AND ? >= fires_min AND ? <= fires_max)
OR (fires_min > fires_max AND ? >= fires_min))',
$alert->{'id'}, $alert->{'times_fired'}, $alert->{'times_fired'}, $alert->{'times_fired'});
if ($alert_mode == RECOVERED_ALERT) {
@actions = get_db_rows ($dbh, 'SELECT * FROM tevent_alert_action, talert_actions, talert_commands
WHERE tevent_alert_action.id_alert_action = talert_actions.id
AND talert_actions.id_alert_command = talert_commands.id
AND tevent_alert_action.id_event_alert = ?
AND ((fires_min = 0 AND fires_max = 0)
OR ? >= fires_min)',
$alert->{'id'}, $alert->{'times_fired'});
} else {
@actions = get_db_rows ($dbh, 'SELECT * FROM tevent_alert_action, talert_actions, talert_commands
WHERE tevent_alert_action.id_alert_action = talert_actions.id
AND talert_actions.id_alert_command = talert_commands.id
AND tevent_alert_action.id_event_alert = ?
AND ((fires_min = 0 AND fires_max = 0)
OR (fires_min <= fires_max AND ? >= fires_min AND ? <= fires_max)
OR (fires_min > fires_max AND ? >= fires_min))',
$alert->{'id'}, $alert->{'times_fired'}, $alert->{'times_fired'}, $alert->{'times_fired'});
}
# Get default action
if ($#actions < 0) {
@actions = get_db_rows ($dbh, 'SELECT * FROM talert_actions, talert_commands
@ -733,7 +754,7 @@ sub pandora_execute_alert ($$$$$$$$;$) {
if ($event_generated == 0) {
#If we've spotted an alert recovered, we set the new event's severity to 2 (NORMAL), otherwise the original value is maintained.
my ($text, $event, $severity) = ($alert_mode == 0) ? ('recovered', 'alert_recovered', 2) : ('fired', 'alert_fired', $alert->{'priority'});
my ($text, $event, $severity) = ($alert_mode == RECOVERED_ALERT) ? ('recovered', 'alert_recovered', 2) : ('fired', 'alert_fired', $alert->{'priority'});
pandora_event ($pa_config, "Alert $text (" . safe_output($alert->{'name'}) . ") " . (defined ($module) ? 'assigned to ('. safe_output($module->{'nombre'}) . ")" : ""),
(defined ($agent) ? $agent->{'id_grupo'} : 0), (defined ($agent) ? $agent->{'id_agente'} : 0), $severity, (defined ($alert->{'id_template_module'}) ? $alert->{'id_template_module'} : 0),
@ -785,7 +806,7 @@ sub pandora_execute_action ($$$$$$$$$;$) {
}
# Recovery fields, thanks to Kato Atsushi
if ($alert_mode == 0) {
if ($alert_mode == RECOVERED_ALERT) {
# Field 1 is a special case where [RECOVER] prefix is not added even when it is defined
$field1 = $alert->{'field1_recovery'} ? $alert->{'field1_recovery'} : $field1;
$field1 = $action->{'field1_recovery'} ? $action->{'field1_recovery'} : $field1;

View File

@ -58,6 +58,8 @@ our @EXPORT = qw(
SNMPSERVER
METACONSOLE_LICENSE
$DEVNULL
RECOVERED_ALERT
FIRED_ALERT
cron_get_closest_in_range
cron_next_execution
cron_next_execution_date
@ -110,6 +112,10 @@ use constant SNMPSERVER => 12;
# Value for a metaconsole license type
use constant METACONSOLE_LICENSE => 0x01;
# Alert modes
use constant RECOVERED_ALERT => 0;
use constant FIRED_ALERT => 1;
# /dev/null
our $DEVNULL = ($^O eq 'MSWin32') ? '/Nul' : '/dev/null';

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 6.0dev
%define release 150427
%define release 150504
Summary: Pandora FMS Server
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 6.0dev
%define release 150427
%define release 150504
Summary: Pandora FMS Server
Name: %{name}

View File

@ -0,0 +1,91 @@
#!/usr/bin/perl
###############################################################################
# Pandora FMS Schema comparison
###############################################################################
# Copyright (c) 2015 Artica Soluciones Tecnologicas S.L
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA
###############################################################################
use strict;
use warnings;
################################################################################
# Parse the given schema file and store the found schema in a hash.
################################################################################
sub parse_schema($) {
my ($schema_file) = @_;
open(SCHEMA, $schema_file) or die("Error opening schema file $schema_file: $!\n");
my $schema_hash = {};
while(my $line = <SCHEMA>) {
if($line =~ m/^\s*CREATE\s+TABLE[^a-z]+([a-z_]+)/) {
my $table = $1;
while(my $line = <SCHEMA>) {
next if ($line =~ m/^\s*--/); # Skip comments.
last if ($line =~ m/;\s*$/); # End of the definition.
if ($line =~ m/^["`'\s]+([a-z_][^"`'\s]+)["`'\s]+/) {
$schema_hash->{$table}->{$1} = '';
}
}
}
}
close(SCHEMA);
return $schema_hash;
}
################################################################################
# Show tables and columns present in schema 1 but not in schema 2.
################################################################################
sub diff_schemas($$$$) {
my ($schema_file_1, $schema_file_2, $schema_1, $schema_2) = @_;
# Look for differences.
while (my ($table, $columns) = each(%{$schema_1})) {
# Check tables.
if (!defined($schema_2->{$table})) {
print "> Table $table defined in $schema_file_1 but not in $schema_file_2.\n";
next;
}
# Check columns.
foreach my $column (keys(%{$columns})) {
if (!defined($schema_2->{$table}->{$column})) {
print "> Column $column on table $table defined in $schema_file_1 but not in $schema_file_2.\n";
next;
}
}
}
}
################################################################################
################################################################################
# Main.
################################################################################
################################################################################
# Check command line parameters.
if ($#ARGV != 1) {
die("Usage: $0 <SQL file 1> <SQL file 2>\n\n");
}
my ($sql_file_1, $sql_file_2) = @ARGV;
# Parse the schema files.
my $schema_1 = parse_schema($sql_file_1);
my $schema_2 = parse_schema($sql_file_2);
# Diff the schemas.
diff_schemas($sql_file_1, $sql_file_2, $schema_1, $schema_2);
diff_schemas($sql_file_2, $sql_file_1, $schema_2, $schema_1);

View File

@ -33,7 +33,7 @@ use PandoraFMS::Tools;
use PandoraFMS::DB;
# version: define current version
my $version = "6.0dev PS150427";
my $version = "6.0dev PS150504";
# Pandora server configuration
my %conf;

View File

@ -35,7 +35,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "6.0dev PS150427";
my $version = "6.0dev PS150504";
# save program name for logging
my $progname = basename($0);