2014-05-30 Sancho Lerena <slerena@artica.es>

* 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
This commit is contained in:
slerena 2014-05-30 15:55:42 +00:00
parent ced5e8c979
commit 2b828cf28b
9 changed files with 311 additions and 154 deletions

View File

@ -1,3 +1,17 @@
2014-05-30 Sancho Lerena <slerena@artica.es>
* 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 <vanessa.gil@artica.es> 2014-05-21 Vanessa Gil <vanessa.gil@artica.es>
* pc/plugins/pandora_df * pc/plugins/pandora_df

View File

@ -1,7 +1,7 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 5.1dev, GNU/Linux # Version 5.1dev, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com
# General Parameters # General Parameters
@ -11,6 +11,7 @@ server_ip localhost
server_path /var/spool/pandora/data_in server_path /var/spool/pandora/data_in
temporal /tmp temporal /tmp
logfile /var/log/pandora/pandora_agent.log logfile /var/log/pandora/pandora_agent.log
#include /etc/pandora/pandora_agent_alt.conf #include /etc/pandora/pandora_agent_alt.conf
#broker_agent name_agent #broker_agent name_agent
@ -130,10 +131,10 @@ remote_config 0
# Enable or disable XML buffer. # Enable or disable XML buffer.
# If you are in a secured environment and want to enable the XML buffer you # 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. # 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 # Minimum available bytes in the temporal directory to enable the XML buffer
#temporal_min_size 1024 temporal_min_size 1024
# Secondary server configuration # 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 # vmstat syntax depends on linux distro and vmstat command version, please check before use it
module_begin module_begin
module_name cpu_user module_name CPU Load
module_type generic_data module_type generic_data
module_interval 1 module_interval 1
module_exec vmstat 1 2 | tail -1 | awk '{ print $13 }' 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_description Average process in CPU (Last minute)
module_end 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_begin
module_name Cache mem free module_name Connected users
module_type generic_data module_type generic_data
module_exec free -m | grep buffers/cache | awk '{print $4}' module_exec who | wc -l
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_end module_end
#Count total number of processes #Count total number of processes
module_begin module_begin
module_name proctotal module_name Number processes
module_type generic_data module_type generic_data
module_exec ps -A | tail --lines=+5 | wc -l module_exec ps -A | tail --lines=+5 | wc -l
module_description Total processes module_description Total processes
@ -205,15 +209,6 @@ module_max_critical 300
module_unit processes module_unit processes
module_end 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 # Async data example
module_begin module_begin
@ -223,81 +218,24 @@ module_exec last | head -1
module_description Monitor last user loggin module_description Monitor last user loggin
module_end 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" # This plugin will get the network usage (bytes/sec)
# And search for "ssh" string into it, sending only that information.
module_plugin grep_log /var/log/syslog Syslog ssh module_plugin pandora_netusage
# Get disk space free in MB # This parses /var/log/syslog file, under the module name "Syslog_error"
#module_begin # And search for "ERROR" string into it, sending only that information.
#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 module uses postprocess feature to unit conversion module_plugin grep_log /var/log/syslog Syslog_error ERROR
#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
# Plugin for inventory on the agent (Only Enterprise) # 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 module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users 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

View File

@ -0,0 +1,79 @@
#!/usr/bin/perl
###############################################################################
#
# Copyright (c) 2009 Ramon Novoa <rnovoa@artica.es>
# 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 "<module>\n";
print "<name><![CDATA[Disk_" . $filesystem . "]]></name>\n";
print "<type><![CDATA[generic_data]]></type>\n";
print "<data><![CDATA[" . $free . "]]></data>\n";
print "<min_critical>0</min_critical>\n";
print "<unit>%</unit>\n";
print "<max_critical>5</max_critical>\n";
print "<min_warning>5</min_warning>\n";
print "<max_warning>10</max_warning>\n";
print "<description>% of free space in this volume</description>\n";
print "</module>\n";
}
exit 0;

View File

@ -0,0 +1,36 @@
#!/usr/bin/perl
# Pandora FMS Plugin to get memory information on Linux
# (c) 2014 Sancho Lerena <slerena@artica.es
use POSIX;
my $TOTAL=`vmstat -s | grep "total memory" | awk '{ print $1 } '`;
my $FREE=`vmstat -s | grep "free memory" | awk '{ print $1 } '`;
my $FREEP=($FREE/$TOTAL)*100;
my $STOTAL=`vmstat -s | grep "total swap" | awk '{ print $1 } '`;
my $SUSED=`vmstat -s | grep "free swap" | awk '{ print $1 } '`;
my $SFREE=($SUSED/$STOTAL)*100;
$SFREE = floor($SFREE);
$FREEP = floor($FREEP);
print "<module>\n";
print "<name>FreeMemory</name>\n";
print "<type>generic_data</type>\n";
print "<description>Free memory %</description>\n";
print "<unit>%</unit>\n";
print "<min_critical>0</min_critical>\n";
print "<max_critical>5</max_critical>\n";
print "<data>$FREEP</data>\n";
print "</module>\n";
print "<module>\n";
print "<name>FreeSwap</name>\n";
print "<type>generic_data</type>\n";
print "<description>Free Swapy %</description>\n";
print "<unit>%</unit>\n";
print "<min_critical>0</min_critical>\n";
print "<max_critical>10</max_critical>\n";
print "<data>$SFREE</data>\n";
print "</module>\n";

View File

@ -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 "<module>"
echo " <name>Network_Usage_Bytes</name>"
echo " <type>generic_data_inc</type>"
echo " <data>$TOTAL</data>"
echo " <unit>bytes/sec</unit>"
echo " <description>Total bytes/sec transfered in this system</description>"
echo "</module>"

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent # Base config file for Pandora FMS Windows Agent
# (c) 2006-2010 Artica Soluciones Tecnologicas # (c) 2006-2014 Artica Soluciones Tecnologicas
# Version 5.1dev # Version 5.1dev
# This program is Free Software, you can redistribute it and/or modify it # 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 # 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 # You can also try to detect the first IP using "auto", for example
address auto address auto
# or setting a fixed IP address, like for example: # or setting a fixed IP address, like for example:
#address 192.168.36.73 #address 192.168.36.73
@ -79,7 +80,7 @@ remote_config 0
# proxy_timeout 1 # proxy_timeout 1
# Enable or disable XML buffer. # Enable or disable XML buffer.
xml_buffer 0 xml_buffer 1
# Secondary server configuration # Secondary server configuration
# ============================== # ==============================
@ -100,13 +101,29 @@ xml_buffer 0
# Check online documentation and module library at http://pandorafms.org # 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 <factor>
module_end
# CPU Load
module_begin module_begin
module_name CPU Load module_name CPU Load
module_type generic_data module_type generic_data
module_wmiquery SELECT LoadPercentage FROM Win32_Processor #module_wmiquery SELECT LoadPercentage FROM Win32_Processor
module_wmicolumn LoadPercentage #module_wmicolumn LoadPercentage
module_cpuusage all
module_description CPU Load (%) module_description CPU Load (%)
module_unit %
module_min_warning 80 module_min_warning 80
module_max_warning 90 module_max_warning 90
module_min_critical 91 module_min_critical 91
@ -130,6 +147,7 @@ module_begin
module_name FreeMemory module_name FreeMemory
module_type generic_data module_type generic_data
module_freepercentmemory module_freepercentmemory
module_unit %
module_description Free memory (%). module_description Free memory (%).
module_min_warning 21 module_min_warning 21
module_max_warning 30 module_max_warning 30
@ -138,14 +156,6 @@ module_max_critical 20
module_end module_end
# Log events # 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_begin
module_name Security Events (Invalid Login) module_name Security Events (Invalid Login)
@ -156,14 +166,6 @@ module_source Security
module_eventcode 529 module_eventcode 529
module_end 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 #Antivirus monitoring
#This modules checks the antivirus is running on your system, if there is and antivirus #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. #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_description Last update for Antivirus Signature file
module_end module_end
# Example plugin to retrieve drive usage # Windows inventory module (This information will be displayed only in enterprise version)
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)!
module_begin module_begin
module_name Inventory module_name Inventory
module_interval 7 module_interval 7
module_type generic_data_string 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_description Inventory
module_end 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 # Sample on how to get a value from registry
# This returns the last time user launch microsoft Windows update # This returns the last time user launch microsoft Windows update
#module_begin #module_begin
@ -335,4 +303,4 @@ module_end
#module_condition (3,8) cmd.exe /c echo range >> c:\log.txt #module_condition (3,8) cmd.exe /c echo range >> c:\log.txt
#module_exec echo 5 #module_exec echo 5
#module_description Postcondition test module #module_description Postcondition test module
#module_end #module_end

View File

@ -1,6 +1,6 @@
' df_all.vbs ' df_all.vbs
' Returns free space (%) for all drives ' Returns free space (%) for all drives
' Pandora FMS Plugin, (c) 2010 Sancho Lerena ' Pandora FMS Plugin, (c) 2014 Sancho Lerena
' ------------------------------------------ ' ------------------------------------------
Option Explicit Option Explicit
@ -35,6 +35,11 @@ For Each objItem in colItems
Wscript.StdOut.WriteLine " <data><![CDATA[" & 0 & "]]></data>" Wscript.StdOut.WriteLine " <data><![CDATA[" & 0 & "]]></data>"
else else
Wscript.StdOut.WriteLine " <data><![CDATA[" & Percent & "]]></data>" Wscript.StdOut.WriteLine " <data><![CDATA[" & Percent & "]]></data>"
Wscript.StdOut.WriteLine "<unit>%</unit>"
Wscript.StdOut.WriteLine "<min_warning>5</min_warning>"
Wscript.StdOut.WriteLine "<max_warning>10</max_warning>"
Wscript.StdOut.WriteLine "<min_critical>0</min_critical>"
Wscript.StdOut.WriteLine "<max_critical>5</max_critical>"
Wscript.StdOut.WriteLine "</module>" Wscript.StdOut.WriteLine "</module>"
Wscript.StdOut.flush Wscript.StdOut.flush
End If End If

View File

@ -0,0 +1,31 @@
' nettraffic.vbs
' Pandora FMS Agent Plugin for Microsoft Windows (All platfforms)
' (c) 2014 Sancho Lerena <slerena@artica.es>
' 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 "<module>"
Wscript.StdOut.WriteLine " <name><![CDATA[Network_Usage_Bytes]]></name>"
Wscript.StdOut.WriteLine " <description><![CDATA[Total network usage in bytes]]></description>"
Wscript.StdOut.WriteLine " <unit>bytes/sec</unit>"
Wscript.StdOut.WriteLine " <type>generic_data_inc</type>"
Wscript.StdOut.WriteLine " <data><![CDATA[" & BytesSUM & "]]></data>"
Wscript.StdOut.WriteLine "</module>"
Wscript.StdOut.flush
' End script

View File

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