From 2b828cf28b0f3bde1274b17b481045388d5c7dbb Mon Sep 17 00:00:00 2001 From: slerena Date: Fri, 30 May 2014 15:55:42 +0000 Subject: [PATCH] 2014-05-30 Sancho Lerena * win32/bin/pandora_agent.conf: New default configuration file Simplified modules, use of new plugins and same module names for most monitors as linux agent * win32/bin/util/df_percent.vbs: Modified plugin for return unit and predefined thresholds. * win32/bin/util/nettraffic.vbs, win32/bin/util/software_installed.vbs: New agent plugins for network usage and software installed inventory plugin, to fix embedded agent inventory which doesnt report all packages. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10054 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/ChangeLog | 14 +++ pandora_agents/unix/Linux/pandora_agent.conf | 118 +++++------------- pandora_agents/unix/plugins/pandora_df_free | 79 ++++++++++++ pandora_agents/unix/plugins/pandora_mem | 36 ++++++ pandora_agents/unix/plugins/pandora_netusage | 14 +++ pandora_agents/win32/bin/pandora_agent.conf | 94 +++++--------- pandora_agents/win32/bin/util/df_percent.vbs | 7 +- pandora_agents/win32/bin/util/nettraffic.vbs | 31 +++++ .../win32/bin/util/software_installed.vbs | 72 +++++++++++ 9 files changed, 311 insertions(+), 154 deletions(-) create mode 100755 pandora_agents/unix/plugins/pandora_df_free create mode 100755 pandora_agents/unix/plugins/pandora_mem create mode 100755 pandora_agents/unix/plugins/pandora_netusage create mode 100644 pandora_agents/win32/bin/util/nettraffic.vbs create mode 100644 pandora_agents/win32/bin/util/software_installed.vbs diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog index 1870232cc3..94bdb244b0 100644 --- a/pandora_agents/ChangeLog +++ b/pandora_agents/ChangeLog @@ -1,3 +1,17 @@ +2014-05-30 Sancho Lerena + + * win32/bin/pandora_agent.conf: New default configuration file + Simplified modules, use of new plugins and same module names + for most monitors as linux agent + + * win32/bin/util/df_percent.vbs: Modified plugin for return + unit and predefined thresholds. + + * win32/bin/util/nettraffic.vbs, + win32/bin/util/software_installed.vbs: New agent plugins for + network usage and software installed inventory plugin, to fix + embedded agent inventory which doesnt report all packages. + 2014-05-21 Vanessa Gil * pc/plugins/pandora_df diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index bec64153f5..cd3e0bbf7f 100755 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -1,7 +1,7 @@ # Base config file for Pandora FMS agents # Version 5.1dev, GNU/Linux # Licensed under GPL license v2, -# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas +# Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # http://www.pandorafms.com # General Parameters @@ -11,6 +11,7 @@ server_ip localhost server_path /var/spool/pandora/data_in temporal /tmp logfile /var/log/pandora/pandora_agent.log + #include /etc/pandora/pandora_agent_alt.conf #broker_agent name_agent @@ -130,10 +131,10 @@ remote_config 0 # Enable or disable XML buffer. # If you are in a secured environment and want to enable the XML buffer you # should consider changing the temporal directory, since /tmp is world writable. -#xml_buffer 0 +xml_buffer 1 # Minimum available bytes in the temporal directory to enable the XML buffer -#temporal_min_size 1024 +temporal_min_size 1024 # Secondary server configuration # ============================== @@ -157,7 +158,7 @@ remote_config 0 # vmstat syntax depends on linux distro and vmstat command version, please check before use it module_begin -module_name cpu_user +module_name CPU Load module_type generic_data module_interval 1 module_exec vmstat 1 2 | tail -1 | awk '{ print $13 }' @@ -179,22 +180,25 @@ module_exec cat /proc/loadavg | cut -d' ' -f1 module_description Average process in CPU (Last minute) module_end -#Get free memory in MB +#IO Wait CPU ticks /sec +module_begin +module_name IOWaitCPU +module_type generic_data_inc +module_exec vmstat -s | grep "IO-wait cpu ticks" | awk '{ print $1 }' +module_unit ticks/sec +module_description Too much IOwait means IO bottleneck and performance problems. Check also LoadAVG. +module_end + +#Connected users module_begin -module_name Cache mem free +module_name Connected users module_type generic_data -module_exec free -m | grep buffers/cache | awk '{print $4}' -module_description Free cache memory in MB -module_min_warning 500 -module_max_warning 600 -module_min_critical 100 -module_max_critical 499 -module_unit MB +module_exec who | wc -l module_end #Count total number of processes module_begin -module_name proctotal +module_name Number processes module_type generic_data module_exec ps -A | tail --lines=+5 | wc -l module_description Total processes @@ -205,15 +209,6 @@ module_max_critical 300 module_unit processes module_end -# Process information - -module_begin -module_name sshDaemon -module_type generic_proc -module_exec ps -Af | grep sshd | grep -v "grep" | wc -l -module_description Check ssh service -module_end - # Async data example module_begin @@ -223,81 +218,24 @@ module_exec last | head -1 module_description Monitor last user loggin module_end -# Module that get the number of cron file -# This module uses a precondition, if cron is running the -# module will check the folder /etc/cron.d to get the number of files -module_begin -module_name Cron task files -module_type async_string -module_precondition =~ .*cron.* ps aux | grep cron -module_exec ls -l /etc/cron.d | awk 'NR>1 {print $0}' | wc -l -module_description Number of cron task files -module_unit files -module_end +# This plugin detects all disk and report free space (%) -# Plugin example +module_plugin pandora_df_free -# This plugin detects all disk partitions and monitor the free spaces +# This plugin detects system free memory and free swap (in %) -module_plugin pandora_df +module_plugin pandora_mem -# This parses /var/log/syslog file, under the module name "syslog" -# And search for "ssh" string into it, sending only that information. +# This plugin will get the network usage (bytes/sec) -module_plugin grep_log /var/log/syslog Syslog ssh +module_plugin pandora_netusage -# Get disk space free in MB -#module_begin -#module_name disk_root_free -#module_type generic_data -#module_exec df -kh / | tail -1 | awk '{ print 100-$5 }' -#module_max 100 -#module_min 0 -#module_description Free disk Percentage of root partition -#module_min_warning 70 -#module_max_warning 90 -#module_min_critical 91 -#module_max_critical 100 -#module_end +# This parses /var/log/syslog file, under the module name "Syslog_error" +# And search for "ERROR" string into it, sending only that information. -# This module uses postprocess feature to unit conversion -#module_begin -#module_name memused -#module_type generic_data -#module_exec free -k | grep buffers/cache | awk '{print $3}' -#module_postprocess 0,000976 -#module_description Used memory in KB postprocessed to be in MB -#module_end +module_plugin grep_log /var/log/syslog Syslog_error ERROR # Plugin for inventory on the agent (Only Enterprise) -# module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users process ip route - -# Example of preconditions -#module_begin -#module_name Test Precondicion -#module_type generic_data -#module_precondition < 10 echo 5 -#module_precondition > 10 echo 15 -#module_precondition = 10 echo 10 -#module_precondition != 10 echo 5 -#module_precondition =~ 10 echo 10 -#module_precondition (5,15) echo 10 -#module_freepercentmemory -#module_description Precondition test module -#module_end - -# Example of postconditions -#module_begin -#module_name Test Postcondicion -#module_type generic_data -#module_condition < 10 echo min >> /tmp/log.txt -#module_condition > 3 echo max >> /tmp/log.txt -#module_condition = 5 echo equal >> /tmp/log.txt -#module_condition != 10 echo diff >> /tmp/log.txt -#module_condition =~ 5 echo regexp >> /tmp/log.txt -#module_condition (3,8) echo range >> /tmp/log.txt -#module_exec echo 5 -#module_description Postcondition test module -#module_end +module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route \ No newline at end of file diff --git a/pandora_agents/unix/plugins/pandora_df_free b/pandora_agents/unix/plugins/pandora_df_free new file mode 100755 index 0000000000..58d9e7a003 --- /dev/null +++ b/pandora_agents/unix/plugins/pandora_df_free @@ -0,0 +1,79 @@ +#!/usr/bin/perl +############################################################################### +# +# Copyright (c) 2009 Ramon Novoa +# Copyright (c) 2009 Artica Soluciones Tecnologicas S.L. +# +# pandora_df Retrieve filesystem disk usage. By default information for all +# filesystems is returned, but one or more filesystems may be +# specified as command line parameters. +# +# Sample usage: ./pandora_df tmpfs /dev/sda1 +# +# 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 of the License. +# +# 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. +# +############################################################################### + +use strict; + +# Retrieve information from all filesystems +my $all_filesystems = 0; + +# Check command line parameters +if ($#ARGV < 0) { + $all_filesystems = 1; +} + +# Parse command line parameters +my %filesystems; +foreach my $fs (@ARGV) { + $filesystems{$fs} = '-1%'; +} + +# Retrieve filesystem information +# -P use the POSIX output format for portability +my @df = `df -P`; +shift (@df); + +# No filesystems? Something went wrong. +if ($#df < 0) { + exit 1; +} + +# Parse filesystem usage +foreach my $row (@df) { + my @columns = split (' ', $row); + exit 1 if ($#columns < 4); + $filesystems{$columns[5]} = $columns[4] if (defined ($filesystems{$columns[0]}) || $all_filesystems == 1); +} + +my $free; + +while (my ($filesystem, $use) = each (%filesystems)) { + + # Remove the trailing % + chop ($use); + $free = 100 - $use; + + # Print module output + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "0\n"; + print "%\n"; + print "5\n"; + print "5\n"; + print "10\n"; + print "% of free space in this volume\n"; + print "\n"; +} + +exit 0; diff --git a/pandora_agents/unix/plugins/pandora_mem b/pandora_agents/unix/plugins/pandora_mem new file mode 100755 index 0000000000..90f912efa4 --- /dev/null +++ b/pandora_agents/unix/plugins/pandora_mem @@ -0,0 +1,36 @@ +#!/usr/bin/perl + +# Pandora FMS Plugin to get memory information on Linux +# (c) 2014 Sancho Lerena \n"; +print "FreeMemory\n"; +print "generic_data\n"; +print "Free memory %\n"; +print "%\n"; +print "0\n"; +print "5\n"; +print "$FREEP\n"; +print "\n"; + +print "\n"; +print "FreeSwap\n"; +print "generic_data\n"; +print "Free Swapy %\n"; +print "%\n"; +print "0\n"; +print "10\n"; +print "$SFREE\n"; +print "\n"; diff --git a/pandora_agents/unix/plugins/pandora_netusage b/pandora_agents/unix/plugins/pandora_netusage new file mode 100755 index 0000000000..a082622f85 --- /dev/null +++ b/pandora_agents/unix/plugins/pandora_netusage @@ -0,0 +1,14 @@ +!/bin/bash + +OUT=`netstat -as | grep "OutOctets" | awk '{ print $2 }'` +IN=`netstat -as | grep "InOctets" | awk '{ print $2 }'` + +TOTAL=`expr $OUT + $IN` +echo "" +echo " Network_Usage_Bytes" +echo " generic_data_inc" +echo " $TOTAL" +echo " bytes/sec" +echo " Total bytes/sec transfered in this system" +echo "" + diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 1f583c346e..2fba595d44 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent -# (c) 2006-2010 Artica Soluciones Tecnologicas -# Version 5.1dev +# (c) 2006-2014 Artica Soluciones Tecnologicas +# Version 5.1dev # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software @@ -37,6 +37,7 @@ temporal "$AgentTemp$" # You can also try to detect the first IP using "auto", for example address auto + # or setting a fixed IP address, like for example: #address 192.168.36.73 @@ -79,7 +80,7 @@ remote_config 0 # proxy_timeout 1 # Enable or disable XML buffer. -xml_buffer 0 +xml_buffer 1 # Secondary server configuration # ============================== @@ -100,13 +101,29 @@ xml_buffer 0 # Check online documentation and module library at http://pandorafms.org # ================= -# CPU Load using WMI +# Get Network information using Agent plugin +module_plugin cscript //B "%ProgramFiles%\Pandora_Agent\util\nettraffic.vbs" + +# Get disk occupation (percent) +module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df_percent.vbs" + +# External inventory plugin +module_begin +module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\software_installed.vbs" +module_interval 288 +# 288 x 5min = 24 hr, one execution per day, using module_interval +module_end + +# CPU Load + module_begin module_name CPU Load module_type generic_data -module_wmiquery SELECT LoadPercentage FROM Win32_Processor -module_wmicolumn LoadPercentage +#module_wmiquery SELECT LoadPercentage FROM Win32_Processor +#module_wmicolumn LoadPercentage +module_cpuusage all module_description CPU Load (%) +module_unit % module_min_warning 80 module_max_warning 90 module_min_critical 91 @@ -130,6 +147,7 @@ module_begin module_name FreeMemory module_type generic_data module_freepercentmemory +module_unit % module_description Free memory (%). module_min_warning 21 module_max_warning 30 @@ -138,14 +156,6 @@ module_max_critical 20 module_end # Log events -module_begin -module_name System Events (TermService) -module_type async_string -module_logevent -module_description Log Events coming from Terminal Service -module_source System -module_application TermService -module_end module_begin module_name Security Events (Invalid Login) @@ -156,14 +166,6 @@ module_source Security module_eventcode 529 module_end -# Check if Dhcp service is enabled -module_begin -module_name DHCP Enabled -module_type generic_proc -module_service Dhcp -module_description Check DCHP service enabled -module_end - #Antivirus monitoring #This modules checks the antivirus is running on your system, if there is and antivirus #This module gets the last date the signature file was updated and send this date to pandora. @@ -175,53 +177,19 @@ module_exec dir "%ProgramFiles%\Avira\AntiVir Desktop\aevdf.dat" | grep aevdf.da module_description Last update for Antivirus Signature file module_end -# Example plugin to retrieve drive usage -module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df.vbs" - -# Free space on disk C: (%) -#module_begin -#module_name FreeDiskC -#module_type generic_data -#module_freepercentdisk C: -#module_description Free space on drive C: (%) -#module_min_warning 31 -#module_max_warning 40 -#module_min_critical 0 -#module_max_critical 30 -#module_end - -# CPU usage percentage -#module_begin -#module_name CPUUse -#module_type generic_data -#module_cpuusage all -#module_description CPU# usage -#module_min_warning 70 -#module_max_warning 90 -#module_min_critical 91 -#module_max_critical 100 -#module_end - -# Free space on disk D: (%) -# module_begin -# module_name FreeDiskD -# module_type generic_data -# module_freepercentdisk D: -# module_description Free space on drive D: (%) -# module_end - -# Sample of Windows inventory module (ONLY ENTERPRISE)! +# Windows inventory module (This information will be displayed only in enterprise version) module_begin module_name Inventory module_interval 7 module_type generic_data_string -module_inventory CPU RAM CDROM Video HD Patches Software Services NIC +module_inventory CPU RAM CDROM Video HD Patches Services NIC module_description Inventory module_end -# Example plugin to retrieve last 5 min events in log4x format -# module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\logevent_log4x.vbs" Aplicacion System 300 - +# ---------------------------------------------------------------------------------------------------- +# 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 +# ---------------------------------------------------------------------------------------------------- # Sample on how to get a value from registry # This returns the last time user launch microsoft Windows update #module_begin @@ -335,4 +303,4 @@ module_end #module_condition (3,8) cmd.exe /c echo range >> c:\log.txt #module_exec echo 5 #module_description Postcondition test module -#module_end \ No newline at end of file +#module_end diff --git a/pandora_agents/win32/bin/util/df_percent.vbs b/pandora_agents/win32/bin/util/df_percent.vbs index e5b3406860..69029b66d4 100644 --- a/pandora_agents/win32/bin/util/df_percent.vbs +++ b/pandora_agents/win32/bin/util/df_percent.vbs @@ -1,6 +1,6 @@ ' df_all.vbs ' Returns free space (%) for all drives -' Pandora FMS Plugin, (c) 2010 Sancho Lerena +' Pandora FMS Plugin, (c) 2014 Sancho Lerena ' ------------------------------------------ Option Explicit @@ -35,6 +35,11 @@ For Each objItem in colItems Wscript.StdOut.WriteLine " " else Wscript.StdOut.WriteLine " " + Wscript.StdOut.WriteLine "%" + Wscript.StdOut.WriteLine "5" + Wscript.StdOut.WriteLine "10" + Wscript.StdOut.WriteLine "0" + Wscript.StdOut.WriteLine "5" Wscript.StdOut.WriteLine "" Wscript.StdOut.flush End If diff --git a/pandora_agents/win32/bin/util/nettraffic.vbs b/pandora_agents/win32/bin/util/nettraffic.vbs new file mode 100644 index 0000000000..fe65b36e63 --- /dev/null +++ b/pandora_agents/win32/bin/util/nettraffic.vbs @@ -0,0 +1,31 @@ +' nettraffic.vbs +' Pandora FMS Agent Plugin for Microsoft Windows (All platfforms) +' (c) 2014 Sancho Lerena +' Returns total bytes in network since bootup and % of network use +' ---------------------------------------------------------------- +' usage: cscript //B nettraffic.vbs + +strComputer = "." +Set objWMIService = GetObject("winmgmts:" _ +& "{impersonationLevel=impersonate}!\\" & strComputer & "\Root\CIMV2") +Set colItems = objWMIService.ExecQuery _ +("select * from Win32_PerfRawData_Tcpip_NetworkInterface ") + +BytesSUM = 0 + +For Each objItem in colItems + bytesTotal = objitem.BytesTotalPersec * 8 + BytesSUM = BytesSUM + bytesTotal + +Next + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine " " +Wscript.StdOut.WriteLine " " +Wscript.StdOut.WriteLine " bytes/sec" +Wscript.StdOut.WriteLine " generic_data_inc" +Wscript.StdOut.WriteLine " " +Wscript.StdOut.WriteLine "" + +Wscript.StdOut.flush +' End script \ No newline at end of file diff --git a/pandora_agents/win32/bin/util/software_installed.vbs b/pandora_agents/win32/bin/util/software_installed.vbs new file mode 100644 index 0000000000..a82626577b --- /dev/null +++ b/pandora_agents/win32/bin/util/software_installed.vbs @@ -0,0 +1,72 @@ +' 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 + + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine"" +Wscript.StdOut.WriteLine "software" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" + +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" + +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) + If intRet1 <> 0 Then + objReg.GetStringValue HKLM, strKey & strSubkey, _ + strEntry1b, strValue1 + End If + If strValue1 <> "" Then + appname = strValue1 + End If + 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 + If intValue3 <> "" Then + appversion = intValue3 & "." & intValue4 + 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 & "" + end if + +Next + +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +Wscript.StdOut.WriteLine "" +