diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog index 14d7a7e3a4..cff540bfac 100644 --- a/pandora_agents/unix/ChangeLog +++ b/pandora_agents/unix/ChangeLog @@ -1,3 +1,11 @@ +2010-11-04 Sancho Lerena + + * NT4: New binary version of Unix perl agent for NT4, with some tools. + .exe compiled with ActiveState SDK 9.0 + + * pandora_agent: Some small modifications to make it work nicely in + windows boxes. + 2010-11-02 Raul Mateos * tentacle_client: Fixed year from last commit. Converted some spaces diff --git a/pandora_agents/unix/NT4/cmp.exe b/pandora_agents/unix/NT4/cmp.exe new file mode 100644 index 0000000000..5ac8a30835 Binary files /dev/null and b/pandora_agents/unix/NT4/cmp.exe differ diff --git a/pandora_agents/unix/NT4/cut.exe b/pandora_agents/unix/NT4/cut.exe new file mode 100644 index 0000000000..a75f2963a7 Binary files /dev/null and b/pandora_agents/unix/NT4/cut.exe differ diff --git a/pandora_agents/unix/NT4/date.exe b/pandora_agents/unix/NT4/date.exe new file mode 100644 index 0000000000..069bae1481 Binary files /dev/null and b/pandora_agents/unix/NT4/date.exe differ diff --git a/pandora_agents/unix/NT4/df.vbs b/pandora_agents/unix/NT4/df.vbs new file mode 100644 index 0000000000..3b22a1baf5 --- /dev/null +++ b/pandora_agents/unix/NT4/df.vbs @@ -0,0 +1,33 @@ +' df.vbs +' Returns free space for avaible drives. +' -------------------------------------- + +Option Explicit +On Error Resume Next + +' Variables +Dim objWMIService, objItem, colItems, argc, argv, i + +' Parse command line parameters +argc = Wscript.Arguments.Count +Set argv = CreateObject("Scripting.Dictionary") +For i = 0 To argc - 1 + argv.Add Wscript.Arguments(i), i +Next + +' Get drive information +Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2") +Set colItems = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk") + +For Each objItem in colItems + If argc = 0 Or argv.Exists(objItem.Name) Then + If objItem.FreeSpace <> "" Then + Wscript.StdOut.WriteLine "" + Wscript.StdOut.WriteLine " " + Wscript.StdOut.WriteLine " " + Wscript.StdOut.WriteLine " " + Wscript.StdOut.WriteLine "" + Wscript.StdOut.flush + End If + End If +Next diff --git a/pandora_agents/unix/NT4/df_percent.vbs b/pandora_agents/unix/NT4/df_percent.vbs new file mode 100644 index 0000000000..b904324836 --- /dev/null +++ b/pandora_agents/unix/NT4/df_percent.vbs @@ -0,0 +1,38 @@ +' df_all.vbs +' Returns free space (%) for all drives +' Pandora FMS Plugin, (c) 2010 Sancho Lerena +' ------------------------------------------ + +Option Explicit +On Error Resume Next + +' Variables +Dim objWMIService, objItem, colItems, argc, argv, i, Percent + + +' Parse command line parameters +argc = Wscript.Arguments.Count +Set argv = CreateObject("Scripting.Dictionary") +For i = 0 To argc - 1 + argv.Add Wscript.Arguments(i), i +Next + +' Get drive information +Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2") +Set colItems = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk") + +For Each objItem in colItems + If argc = 0 Or argv.Exists(objItem.Name) Then + ' Include only harddrivers (type 3) + If (objItem.FreeSpace <> "") AND (objItem.DriveType =3) Then + Percent = round ((objItem.FreeSpace / objItem.Size) * 100, 2) + + Wscript.StdOut.WriteLine "" + Wscript.StdOut.WriteLine " " + Wscript.StdOut.WriteLine " " + Wscript.StdOut.WriteLine " " + Wscript.StdOut.WriteLine "" + Wscript.StdOut.flush + End If + End If +Next diff --git a/pandora_agents/unix/NT4/expr.exe b/pandora_agents/unix/NT4/expr.exe new file mode 100644 index 0000000000..bce338407b Binary files /dev/null and b/pandora_agents/unix/NT4/expr.exe differ diff --git a/pandora_agents/unix/NT4/gawk.exe b/pandora_agents/unix/NT4/gawk.exe new file mode 100644 index 0000000000..f4a2f21d3a Binary files /dev/null and b/pandora_agents/unix/NT4/gawk.exe differ diff --git a/pandora_agents/unix/NT4/getreg.exe b/pandora_agents/unix/NT4/getreg.exe new file mode 100644 index 0000000000..5e51053d84 Binary files /dev/null and b/pandora_agents/unix/NT4/getreg.exe differ diff --git a/pandora_agents/unix/NT4/grep.exe b/pandora_agents/unix/NT4/grep.exe new file mode 100644 index 0000000000..9597377a38 Binary files /dev/null and b/pandora_agents/unix/NT4/grep.exe differ diff --git a/pandora_agents/unix/NT4/head.exe b/pandora_agents/unix/NT4/head.exe new file mode 100644 index 0000000000..7f5ef8764a Binary files /dev/null and b/pandora_agents/unix/NT4/head.exe differ diff --git a/pandora_agents/unix/NT4/logevent_log4x.vbs b/pandora_agents/unix/NT4/logevent_log4x.vbs new file mode 100644 index 0000000000..d4380c2bfe --- /dev/null +++ b/pandora_agents/unix/NT4/logevent_log4x.vbs @@ -0,0 +1,93 @@ +' -------------------------------------------------------------- +' WMI Log Event Parser for Windows +' Used as Plugin in Pandora FMS Monitoring System +' Written by Sancho Lerena 2010 +' Licensed under BSD Licence +' -------------------------------------------------------------- + +' This plugin uses three parameters: +' +' module_name : Module name to be reported at pandora, p.e: Event_Application +' logfile : Windows event logfile: Application, System, Security... +' interval: Should be the same interval agent has, p.e: 300 (seconds) + +' Code begins here + +' Take args from command line +if (Wscript.Arguments.Count = 0) then + WScript.Quit +end if + +On Error Resume Next +cfg_module_name = Wscript.Arguments(0) +cfg_logfile = Wscript.Arguments(1) +cfg_interval = Wscript.Arguments(2) +strComputer = "." + +MyDate = dateAdd("s", -cfg_interval, Now) ' Latest X seconds + +Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime") + +CONVERT_TO_LOCAL_TIME = TRUE + +DateToCheck = CDate(MyDate) +dtmStartDate.SetVarDate DateToCheck, CONVERT_TO_LOCAL_TIME + +WMI_QUERY = "Select * from Win32_NTLogEvent Where Logfile = '" & cfg_logfile & "' AND TimeWritten >= '" & dtmStartDate & "'" + +' DEBUG +'wscript.StdOut.WriteLine dtmStartDate +'wscript.StdOut.WriteLine WMI_QUERY + +Set objWMIService = GetObject("winmgmts:" _ + & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") +Set colEvents = objWMIService.ExecQuery (WMI_QUERY) + +'The XML files need the have the fields SEVERITY, MESSAGE and +'STACKTRACE. These are the fields that are often used when logging with +'log4j. Just in case, the severity field can have the following values: +'TRACE, DEBUG, INFO, WARN, ERROR, FATAL. The "message" field is just + +For Each objEvent in colEvents + + if (objEvent.Type = "0") then + severity = "FATAL" + end if + + if (objEvent.Type = "1") then + severity = "ERROR" + end if + + if (objEvent.Type = "2") then + severity = "WARN" + end if + + if (objEvent.Type >= "3") then + severity = "INFO" + end if + + stacktrace = "Category: " & objEvent.CategoryString & ", Event Code: " & objEvent.EventCode & ", Source Name: " & objEvent.SourceName & ", LogFile: " & cfg_logfile + + event_message = objEvent.Message + Wscript.StdOut.Write "" + Wscript.StdOut.Write "" + Wscript.StdOut.Write "log4x" + Wscript.StdOut.Write "" & severity & "" + + if (event_message = "") then + Wscript.StdOut.Write "" + else + Wscript.StdOut.Write "" + end if + + if (stacktrace = "") then + Wscript.StdOut.Write "" + else + Wscript.StdOut.Write "" + end if + + Wscript.StdOut.WriteLine "" + Wscript.StdOut.flush +Next + +' Code ends here diff --git a/pandora_agents/unix/NT4/ls.exe b/pandora_agents/unix/NT4/ls.exe new file mode 100644 index 0000000000..388af5eb41 Binary files /dev/null and b/pandora_agents/unix/NT4/ls.exe differ diff --git a/pandora_agents/unix/NT4/md5.exe b/pandora_agents/unix/NT4/md5.exe new file mode 100644 index 0000000000..8bdc35ccc8 Binary files /dev/null and b/pandora_agents/unix/NT4/md5.exe differ diff --git a/pandora_agents/unix/NT4/pandora.win32.README b/pandora_agents/unix/NT4/pandora.win32.README new file mode 100644 index 0000000000..831b2e1a06 --- /dev/null +++ b/pandora_agents/unix/NT4/pandora.win32.README @@ -0,0 +1,25 @@ +Pandora FMS for windows NT4 +=========================== + +This agent is a port of the Unix agent (in perl) compiled with ActiveState DevKit Perl compiler. This is a stand-alone EXE with all the tools it will need to run. It has the same features than the Unix agent, but running on a NT4 box. This means can execute commands and get the output to produce data for Pandora FMS. + +Could be used on any Windows machine (NT4, Win95, Windows 2000-2008, and of course Windows 7), could be useful on windows embedded systems without WMI core, which makes standard Pandora FMS windows agent to do not run properly. + +Install +======= + +Copy all contents on a directory of your choice, for example c:\pandora. + +Edit pandora_agent.conf and set your parameters, including the log file and the temporal directory, should be something like c:\pandora\temp and c:\pandora\log. MAKE SURE that directories exists before trying to start Pandora agent. + +Run +=== + +This agent does not run as a service, so you need to install in the startup menu or start by hand. The shortlink you create must have a parameter, which is where is the main Pandora FMS agent directory, in this scenario is c:\pandora, so the command to start will be : + + c:\pandora\pandora_agent.exe c:\pandora + +Install as a service +==================== + +srvany.exe tool is provided to do this. Is a microsoft resource kit tool to be able to use any .exe as a service. Just read the documentation about how to use srvany (provided in this package). diff --git a/pandora_agents/unix/NT4/pandora_agent.conf b/pandora_agents/unix/NT4/pandora_agent.conf new file mode 100644 index 0000000000..d130ee39cd --- /dev/null +++ b/pandora_agents/unix/NT4/pandora_agent.conf @@ -0,0 +1,140 @@ +# Base config file for Pandora FMS agents +# Version 3.0, GNU/Linux +# Licensed under GPL license v2, +# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas +# http://www.pandorafms.com + +# General Parameters +# ================== + +server_ip 192.168.50.1 +server_path /var/spool/pandora/data_in +temporal c:\pandora\temp +logfile c:\pandora\log\pandora_agent.log + +# Interval in seconds, 300 by default +interval 30 + +# Debug mode only generate XML, and stop after first execution, +# and does not copy XML to server. +debug 0 + +# Optional. UDP Server to receive orders from outside +# By default is disabled, set 1 to enable +# Set port (41122 by default) +# Set address to restrict who can order a agent restart (0.0.0.0 = anybody) +# +udp_server 1 +udp_server_port 41122 +udp_server_auth_address 0.0.0.0 + +# By default, agent takes machine name +# agent_name WinNT4_Test + +#Parent agent_name +#parent_agent_name caprica + +# Agent description +#description This is a demo agent for Linux + +# Group assigned for this agent (descriptive, p.e: Servers) +#group Servers + +# Autotime: Enforce to server to ignore timestamp coming from this +# agent, used when agents has no timer or it's inestable. 1 to enable +# this feature +#autotime 1 + +# Timezone offset: Difference with the server timezone +#timezone_offset 0 + +# Agent position paramters +# Those parameters define the geographical position of the agent + +# latitude +#latitude 0 +# longitude +#longitude 0 +# altitude +#altitude 0 + +#Position description +#position_description Madrid, centro + +# By default agent try to take default encoding defined in host. +#encoding iso-8859-15 + +# Listening TCP port for remote server. By default is 41121 (for tentacle) +# if you want to use SSH use 22, and FTP uses 21. +server_port 41121 + +# Transfer mode: tentacle, ftp, ssh or local +transfer_mode tentacle + +# Server password (Tentacle or FTP). Leave empty for no password (default). +#server_pwd mypassword + +# Set to yes/no to enable/disable OpenSSL support for Tentacle (disabled by default). +#server_ssl no + +# Extra options for the Tentacle client (for example, server_opts "-v -r 5"). +#server_opts + +# delayed_startup defines number of MINUTES before start execution +# for first time when startup Pandora FMS Agent +#delayed_startup 10 + +# Pandora nice defines priority of execution. Less priority means more intensive execution +# A recommended value is 10. 0 priority means no Pandora CPU protection enabled (default) +#pandora_nice 0 + +# Cron mode replace Pandora FMS own task schedule each XX interval seconds by the use +# of old style cron. You should add to crontab Pandora FMS agent script to use this mode. +# This is disabled by default, and is not recommended. Use Pandora FMS internal scheduler +# is much more safe +#cron_mode + +# If set to 1 allows the agent to be configured via the web console (Only Enterprise version) +remote_config 1 + +# Number of threads to execute modules in parallel +#agent_threads 1 + +# Secondary server configuration +# ============================== + +# If secondary_mode is set to on_error, data files are copied to the secondary +# server only if the primary server fails. If set to always, data files are +# always copied to the secondary server. +#secondary_mode on_error +#secondary_server_ip localhost +#secondary_server_path /var/spool/pandora/data_in +#secondary_server_port 41121 +#secondary_transfer_mode tentacle +#secondary_server_pwd mypassword +#secondary_server_ssl no +#secondary_server_opts + +# Module Definition +# ================= + +# System information + +# vmstat syntax depends on linux distro and vmstat command version, please check before use it +module_begin +module_name Disk_Free_C +module_type generic_data +module_exec dir c:\ | grep "bytes [a-z]*" | gawk "{ print $1 }" | tr -d "," +module_end + +module_begin +module_name Service_EventLog +module_type generic_proc +module_exec net start | grep "EventLog" | wc -l | tr -d " " +module_end + +module_begin +module_name Free_RAM +module_type generic_data +module_exec mem | grep "XMS" | gawk "{ print $1 }" +module_end \ No newline at end of file diff --git a/pandora_agents/unix/NT4/pandora_agent.exe b/pandora_agents/unix/NT4/pandora_agent.exe new file mode 100644 index 0000000000..9709b849c4 Binary files /dev/null and b/pandora_agents/unix/NT4/pandora_agent.exe differ diff --git a/pandora_agents/unix/NT4/pandora_exec.exe b/pandora_agents/unix/NT4/pandora_exec.exe new file mode 100644 index 0000000000..f4fd0aa32b Binary files /dev/null and b/pandora_agents/unix/NT4/pandora_exec.exe differ diff --git a/pandora_agents/unix/NT4/ps.vbs b/pandora_agents/unix/NT4/ps.vbs new file mode 100644 index 0000000000..9391647234 --- /dev/null +++ b/pandora_agents/unix/NT4/ps.vbs @@ -0,0 +1,34 @@ +' ps.vbs +' Returns the status of the given processes. +' ----------------------------------------- + +Option Explicit +'On Error Resume Next + +' Variables +Dim objWMIService, objItem, colItems, argc, ps, i + +' Get and hash process information +Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2") +Set colItems = objWMIService.ExecQuery ("Select * from Win32_Process") +Set ps = CreateObject("Scripting.Dictionary") +For Each objItem in colItems + if Not ps.Exists(objItem.Name) Then + ps.Add objItem.Name, 1 + End If +Next + +' Parse command line parameters and check each process +argc = Wscript.Arguments.Count +For i = 0 To argc - 1 + Wscript.StdOut.WriteLine "" + Wscript.StdOut.WriteLine " " + Wscript.StdOut.WriteLine " " + If argc = 0 Or ps.Exists(Wscript.Arguments(i)) Then + Wscript.StdOut.WriteLine " " + Else + Wscript.StdOut.WriteLine " " + End If + Wscript.StdOut.WriteLine "" + Wscript.StdOut.flush +Next diff --git a/pandora_agents/unix/NT4/renice.bat b/pandora_agents/unix/NT4/renice.bat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pandora_agents/unix/NT4/sort.exe b/pandora_agents/unix/NT4/sort.exe new file mode 100644 index 0000000000..8b583cff70 Binary files /dev/null and b/pandora_agents/unix/NT4/sort.exe differ diff --git a/pandora_agents/unix/NT4/srvany.exe b/pandora_agents/unix/NT4/srvany.exe new file mode 100644 index 0000000000..c7930cefa6 Binary files /dev/null and b/pandora_agents/unix/NT4/srvany.exe differ diff --git a/pandora_agents/unix/NT4/srvany.wri b/pandora_agents/unix/NT4/srvany.wri new file mode 100644 index 0000000000..466c052fa5 Binary files /dev/null and b/pandora_agents/unix/NT4/srvany.wri differ diff --git a/pandora_agents/unix/NT4/tail.exe b/pandora_agents/unix/NT4/tail.exe new file mode 100644 index 0000000000..36c2abc22f Binary files /dev/null and b/pandora_agents/unix/NT4/tail.exe differ diff --git a/pandora_agents/unix/NT4/tentacle_client.exe b/pandora_agents/unix/NT4/tentacle_client.exe new file mode 100644 index 0000000000..bc609233b5 Binary files /dev/null and b/pandora_agents/unix/NT4/tentacle_client.exe differ diff --git a/pandora_agents/unix/NT4/tr.exe b/pandora_agents/unix/NT4/tr.exe new file mode 100644 index 0000000000..249cc46c09 Binary files /dev/null and b/pandora_agents/unix/NT4/tr.exe differ diff --git a/pandora_agents/unix/NT4/unzip.exe b/pandora_agents/unix/NT4/unzip.exe new file mode 100644 index 0000000000..b10387734a Binary files /dev/null and b/pandora_agents/unix/NT4/unzip.exe differ diff --git a/pandora_agents/unix/NT4/wc.exe b/pandora_agents/unix/NT4/wc.exe new file mode 100644 index 0000000000..c0a2d1cd17 Binary files /dev/null and b/pandora_agents/unix/NT4/wc.exe differ diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index db6fbf3b12..93d2e9926b 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -56,8 +56,8 @@ if (!$@) { $Sem = Thread::Semaphore->new; } -use constant AGENT_VERSION => '3.2dev'; -use constant AGENT_BUILD => '101015'; +use constant AGENT_VERSION => '3.2RC1'; +use constant AGENT_BUILD => '101103'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { @@ -105,6 +105,7 @@ use constant PART_CMDS => { # OS and OS version my $OS = $^O; + my $OS_VERSION; # Used to calculate the MD5 checksum of a string @@ -185,6 +186,12 @@ my %Parts = ( # Collections my %Collections; +# $DevNull +my $DevNull = '/dev/null'; + +# Shell command separator +my $CmdSep = ';'; + ################################################################################ # Print usage information and exit. ################################################################################ @@ -453,14 +460,14 @@ sub send_file { my $output; if ($Conf{'transfer_mode'} eq 'tentacle') { - $output = `tentacle_client -v -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} $file 2>&1 >/dev/null`; + $output = `tentacle_client -v -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} $file 2>&1 >$DevNull`; } elsif ($Conf{'transfer_mode'} eq 'ssh') { - $output = `scp -P $Conf{'server_port'} $file pandora@"$Conf{'server_ip'}:$Conf{'server_path'}" 2>&1 >/dev/null`; + $output = `scp -P $Conf{'server_port'} $file pandora@"$Conf{'server_ip'}:$Conf{'server_path'}" 2>&1 >$DevNull`; } elsif ($Conf{'transfer_mode'} eq 'ftp') { my $base = basename ($file); my $dir = dirname ($file); - $output = `ftp -n $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >/dev/null <&1 >$DevNull <&1 >/dev/null`; + $output = `cp $file $Conf{'server_path'}/ 2>&1 >$DevNull`; } # Get the errorlevel @@ -510,14 +517,14 @@ sub recv_file ($) { my $output; if ($Conf{'transfer_mode'} eq 'tentacle') { - $output = `cd "$Conf{'temporal'}"; tentacle_client -v -g -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} $file 2>&1 >/dev/null` + $output = `cd "$Conf{'temporal'}"$CmdSep tentacle_client -v -g -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} $file 2>&1 >$DevNull` } elsif ($Conf{'transfer_mode'} eq 'ssh') { - $output = `scp -P $Conf{'server_port'} pandora@"$Conf{'server_ip'}:$Conf{'server_path'}/$file" $Conf{'temporal'} 2>&1 >/dev/null`; + $output = `scp -P $Conf{'server_port'} pandora@"$Conf{'server_ip'}:$Conf{'server_path'}/$file" $Conf{'temporal'} 2>&1 >$DevNull`; } elsif ($Conf{'transfer_mode'} eq 'ftp') { my $base = basename ($file); my $dir = dirname ($file); - $output = `ftp -n $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >/dev/null <&1 >$DevNull <&1 >/dev/null`; + $output = `cp $Conf{'server_path'}/$file $Conf{'temporal'} 2>&1 >$DevNull`; } # Get the errorlevel @@ -646,7 +653,7 @@ sub check_collections () { # Download and unzip next unless (recv_file ($collection_file) == 0); rmrf ("$ConfDir/collections/$collection"); - `unzip -d "$ConfDir/collections/$collection" "$Conf{'temporal'}/$collection_file" 2>/dev/null`; + `unzip -d "$ConfDir/collections/$collection" "$Conf{'temporal'}/$collection_file" 2>$DevNull`; unlink ("$Conf{'temporal'}/$collection_file"); # Save the new md5 @@ -780,10 +787,17 @@ sub guess_os_version ($) { # Linux if ($os eq 'linux') { - $os_version = `lsb_release -sd 2>/dev/null`; + $os_version = `lsb_release -sd 2>$DevNull`; # AIX } elsif ($os eq 'aix') { $os_version = "$2.$1" if (`uname -rv` =~ /\s*(\d)\s+(\d)\s*/); + # Windows + } elsif ($os =~ /win/i) { + $os_version = `ver`; + $DevNull = '/Nul'; + $CmdSep = '\&'; + $OS = "windows"; + # Solaris, HP-UX, BSD and others } else { $os_version = `uname -r`; @@ -930,10 +944,10 @@ sub module_exec ($) { # Execute the command if ($module->{'timeout'} == 0) { - @data = `$module->{'params'} 2> /dev/null`; + @data = `$module->{'params'} 2> $DevNull`; } else { my $cmd = quotemeta ($module->{'params'}); - @data = `$Conf{'pandora_exec'} $module->{'timeout'} $cmd 2> /dev/null`; + @data = `$Conf{'pandora_exec'} $module->{'timeout'} $cmd 2> $DevNull`; } # Something went wrong or no data @@ -1037,7 +1051,7 @@ sub module_cpuusage ($) { # Get CPU usage my $cmd = CPUUSAGE_CMDS->{$OS}; - my @data = `$cmd 2> /dev/null`; + my @data = `$cmd 2> $DevNull`; # Something went wrong or no data return () unless ($? eq 0 && defined ($data[0])); @@ -1056,7 +1070,7 @@ sub module_freememory ($) { # Get available memory my $cmd = FREEMEMORY_CMDS->{$OS}; - my @data = `$cmd 2> /dev/null`; + my @data = `$cmd 2> $DevNull`; # Something went wrong or no data return () unless ($? eq 0 && defined ($data[0])); @@ -1075,7 +1089,7 @@ sub module_freepercentmemory ($) { # Get CPU usage my $cmd = TOTALMEMORY_CMDS->{$OS}; - my @data = `$cmd 2> /dev/null`; + my @data = `$cmd 2> $DevNull`; # Something went wrong or no data return () unless ($? eq 0 && defined ($data[0])); @@ -1104,7 +1118,7 @@ sub evaluate_module_conditions ($$) { ($condition->{'operator'} eq '!=' && $data != $condition->{'value_1'}) || ($condition->{'operator'} eq '=~' && $data =~ /$condition->{'value_1'}/) || ($condition->{'operator'} eq '()' && $data > $condition->{'value_1'} && $data < $condition->{'value_2'})) { - `$condition->{'command'} 2> /dev/null`; + `$condition->{'command'} 2> $DevNull`; } } } @@ -1257,7 +1271,7 @@ sub udp_server ($$) { sub exec_plugin ($) { my $plugin = shift; - my $output = `$plugin 2>/dev/null`; + my $output = `$plugin 2>$DevNull`; # Do not save the output if there was an error return unless ($? eq 0);