[-]
[+]
|
Added |
check_updates.changes
|
|
[-]
[+]
|
Changed |
check_updates.spec
^
|
|
|
Deleted |
check_updates-1.4.8.tar.gz
^
|
|
Deleted |
check_updates-1.4.9.tar.gz
^
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/AUTHORS
^
|
@@ -4,9 +4,10 @@
* Peter Bircher & Cristian Tuduce for several bug fixes
* Mark Greenheigh for the prompt and precise bug reports
* Jose Pedro Oliveira for the build and release fixes
+ * Tomas Edwardsson for a patch fixing the detection of RH EL 6 systems
# File version information:
-# $Id: AUTHORS 1200 2010-10-31 14:55:05Z corti $
-# $Revision: 1200 $
+# $Id: AUTHORS 1245 2011-05-24 10:09:00Z corti $
+# $Revision: 1245 $
# $HeadURL: https://svn.id.ethz.ch/nagios_plugins/check_updates/AUTHORS $
-# $Date: 2010-10-31 15:55:05 +0100 (Sun, 31 Oct 2010) $
+# $Date: 2011-05-24 12:09:00 +0200 (Tue, 24 May 2011) $
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/Changes
^
|
@@ -1,3 +1,30 @@
+2011-10-03 Matteo Corti <matteo.corti@id.ethz.ch>
+
+ * Version 1.5.0
+ * check_updates: fixed a bug which caused the -w and -c options to be ignored
+
+2011-09-23 Matteo Corti <matteo.corti@id.ethz.ch>
+
+ * Version 1.4.15
+ * check_updates: using /etc/redhat-release instead of /etc/issue
+
+2011-05-25 Matteo Corti <matteo.corti@id.ethz.ch>
+
+ * Version 1.4.14
+ * check_updates: fixed a problem when checking if a piped command was successful
+
+2011-05-24 Matteo Corti <matteo.corti@id.ethz.ch>
+
+ * Version 1.4.13
+ * check_updates: fixed the unit tests on systems with older Test::Simple
+ versions
+
+ * Version 1.4.12
+ * check_updates: fixed the detection of RH 6 and Scientific Linux Systems
+ (thanks to J. Oliveira and T. Edwardsson)
+ * check_updates: several style fixes (cleaned with Perl::Critic)
+ * t: some unit tests (to be extended)
+
2010-11-18 Matteo Corti <matteo.corti@id.ethz.ch>
* Version 1.4.11
@@ -151,7 +178,7 @@
* check_updates: recognizes CentOS
# File version information:
-# $Id: Changes 1207 2010-11-18 10:17:33Z corti $
-# $Revision: 1207 $
+# $Id: Changes 1269 2011-10-03 08:00:30Z corti $
+# $Revision: 1269 $
# $HeadURL: https://svn.id.ethz.ch/nagios_plugins/check_updates/Changes $
-# $Date: 2010-11-18 11:17:33 +0100 (Thu, 18 Nov 2010) $
+# $Date: 2011-10-03 10:00:30 +0200 (Mon, 03 Oct 2011) $
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/MANIFEST
^
|
@@ -20,4 +20,11 @@
META.yml
NEWS
README
+t/00_modules.t
+t/01_functions.t
+t/examples/fedora_14
+t/examples/fedora_15
+t/examples/rhel_4
+t/examples/rhel_6
+t/examples/scientific_linux_6
TODO
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/META.yml
^
|
@@ -4,10 +4,12 @@
- 'Matteo Corti <matteo.corti@id.ethz.ch>'
build_requires:
ExtUtils::MakeMaker: 6.42
+ File::Spec: 0
+ Test::More: 0
configure_requires:
ExtUtils::MakeMaker: 6.42
distribution_type: module
-generated_by: 'Module::Install version 0.95'
+generated_by: 'Module::Install version 1.01'
license: gpl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -16,6 +18,7 @@
no_index:
directory:
- inc
+ - t
requires:
Carp: 0
English: 0
@@ -23,7 +26,9 @@
Nagios::Plugin::Getopt: 0
Nagios::Plugin::Threshold: 0
POSIX: 0
+ Readonly: 0
Sort::Versions: 0
+ perl: 5.8.0
resources:
license: http://opensource.org/licenses/gpl-license.php
-version: 1.4.11
+version: 1.5.0
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/Makefile.PL
^
|
@@ -4,18 +4,19 @@
################################################################################
# Version information:
#
-# $Id: Makefile.PL 1202 2010-11-01 06:12:28Z corti $
-# $Revision: 1202 $
+# $Id: Makefile.PL 1265 2011-07-22 16:18:04Z corti $
+# $Revision: 1265 $
# $HeadURL: https://svn.id.ethz.ch/nagios_plugins/check_updates/Makefile.PL $
-# $Date: 2010-11-01 07:12:28 +0100 (Mon, 01 Nov 2010) $
+# $Date: 2011-07-22 18:18:04 +0200 (Fri, 22 Jul 2011) $
#
##############################################################################
# Define metadata (we read it from the binary)
-name 'check_updates';
-version_from 'check_updates';
-all_from 'check_updates.pod';
+name 'check_updates';
+version_from 'check_updates';
+perl_version_from 'check_updates';
+all_from 'check_updates.pod';
##############################################################################
# Specific dependencies
@@ -28,10 +29,15 @@
requires 'Nagios::Plugin::Getopt' => 0;
requires 'Nagios::Plugin::Threshold' => 0;
requires 'POSIX' => 0;
+requires 'Readonly' => 0;
requires 'Sort::Versions' => 0;
install_script 'check_updates';
+tests 't/*.t';
+test_requires 'Test::More' => 0;
+test_requires 'File::Spec' => 0;
+
WriteMakefile(
INSTALLSCRIPT => '/usr/lib/nagios/plugins/contrib',
INSTALLSITESCRIPT => '/usr/lib/nagios/plugins/contrib',
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/NEWS
^
|
@@ -1,3 +1,8 @@
+2011-10-03: 1.5.0 - fixed a bug which caused -w and -c to be ignored
+2011-09-23: 1.4.15 - using /etc/redhat-release instead of /etc/issue
+2011-05-25: 1.4.14 - fixed a bug introduced in 1.4.13 (check on closed pipes)
+2011-05-24: 1.4.13 - fixed the unit tests on RH systems with old Test::Simple versions
+2011-05-24: 1.4.12 - fixed the detection of RH 6 and Scientific Linux Systems
2010-11-18: 1.4.11 - fixed the processing of Xen kernels
2010-11-15: 1.4.10 - fixed the licensing information in the POD documentation
and changed the RPM package name to nagios-plugins-check-updates
@@ -36,7 +41,7 @@
First stable release
2008-02-21: 0.9.9 - checks if the running kernel is the latest installed
-# $Id: NEWS 1207 2010-11-18 10:17:33Z corti $
-# $Revision: 1207 $
+# $Id: NEWS 1269 2011-10-03 08:00:30Z corti $
+# $Revision: 1269 $
# $HeadURL: https://svn.id.ethz.ch/nagios_plugins/check_updates/NEWS $
-# $Date: 2010-11-18 11:17:33 +0100 (Thu, 18 Nov 2010) $
+# $Date: 2011-10-03 10:00:30 +0200 (Mon, 03 Oct 2011) $
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/README
^
|
@@ -20,13 +20,15 @@
Use one of the following commands to install the yum security plugin:
- Fedora systems:
- * yum install yum-plugin-security
+ Fedora, Red Hat Enterprise Linux 6.x, Scientific Linux 6.x systems:
- Red Hat / CentOS 5.x systems:
- * yum install yum-security
+ * yum install yum-plugin-security
-# $Id: README 1103 2009-12-07 07:49:19Z corti $
-# $Revision: 1103 $
+ Red Hat Enterprise Linux 5.x, CentOS 5.x and Scientific Linux 5.x systems:
+
+ * yum install yum-security
+
+# $Id: README 1238 2011-05-24 06:40:44Z corti $
+# $Revision: 1238 $
# $HeadURL: https://svn.id.ethz.ch/nagios_plugins/check_updates/README $
-# $Date: 2009-12-07 08:49:19 +0100 (Mon, 07 Dec 2009) $
+# $Date: 2011-05-24 08:40:44 +0200 (Tue, 24 May 2011) $
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/TODO
^
|
@@ -1,9 +1,8 @@
-
+* add more unit tests
* Should check for up2date errors (return code?)
-
* Check for updates on Mac OS X / macports systems
-# $Id: TODO 1126 2010-02-16 20:06:11Z corti $
-# $Revision: 1126 $
+# $Id: TODO 1240 2011-05-24 08:35:50Z corti $
+# $Revision: 1240 $
# $HeadURL: https://svn.id.ethz.ch/nagios_plugins/check_updates/TODO $
-# $Date: 2010-02-16 21:06:11 +0100 (Tue, 16 Feb 2010) $
+# $Date: 2011-05-24 10:35:50 +0200 (Tue, 24 May 2011) $
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/check_updates
^
|
@@ -1,5 +1,7 @@
#!perl
+package main;
+
# check_updates is a Nagios plugin to check if RedHat or Fedora system
# is up-to-date
#
@@ -16,17 +18,19 @@
# enable substitution with:
# $ svn propset svn:keywords "Id Revision HeadURL Source Date"
#
-# $Id: check_updates 1207 2010-11-18 10:17:33Z corti $
-# $Revision: 1207 $
+# $Id: check_updates 1270 2011-10-03 08:01:52Z corti $
+# $Revision: 1270 $
# $HeadURL: https://svn.id.ethz.ch/nagios_plugins/check_updates/check_updates $
-# $Date: 2010-11-18 11:17:33 +0100 (Thu, 18 Nov 2010) $
+# $Date: 2011-10-03 10:01:52 +0200 (Mon, 03 Oct 2011) $
+
+use 5.00800;
use strict;
use warnings;
-use Carp;
-our $VERSION = '1.4.11';
+our $VERSION = '1.5.0';
+use Carp;
use English qw(-no_match_vars);
use Nagios::Plugin::Getopt;
use Nagios::Plugin::Threshold;
@@ -38,6 +42,9 @@
Readonly our $EXIT_UNKNOWN => 3;
Readonly our $YUM_RETURN_UPDATES_AVAILABLE => 100;
+Readonly our $BITS_PER_BYTE => 8;
+
+Readonly our $VERSION_FILE => '/etc/redhat-release';
# IMPORTANT: Nagios plugins could be executed using embedded perl in this case
# the main routine would be executed as a subroutine and all the
@@ -47,6 +54,7 @@
#
# All variables are therefore declared as package variables...
#
+## no critic (ProhibitPackageVars)
use vars qw(
$bootcheck
$exit_message
@@ -59,13 +67,46 @@
$status
@status_lines
);
+## use critic
-$status = OK;
+# the script is declared as a package so that it can be unit tested
+# but it should not be used as a module
+if ( !caller ) {
+ run();
+}
##############################################################################
# subroutines
##############################################################################
+# Usage : exit_with_error( $status, $message)
+# Purpose : if a plugin object is available exits via ->nagios_exit
+# otherwise prints to the shell and exit normally
+# Returns : n/a
+# Arguments : n/a
+# Throws : n/a
+# Comments : n/a
+# See also : n/a
+sub exit_with_error {
+
+ my $status = shift;
+ my $message = shift;
+
+ if ($plugin) {
+ $plugin->nagios_exit( $status, $message );
+ }
+ else {
+ #<<<
+ print "Error: $message"; ## no critic (RequireCheckedSyscalls)
+ #>>>
+ exit $status;
+ }
+
+ return;
+
+}
+
+##############################################################################
# Usage : whoami()
# Purpose : retrieve the user runnging the process
# Returns : username
@@ -76,15 +117,21 @@
sub whoami {
my $output;
my $pid = open $output, q{-|}, 'whoami'
- or
- $plugin->nagios_exit( UNKNOWN, "Cannot determine the user: $OS_ERROR" );
+ or exit_with_error( UNKNOWN, "Cannot determine the user: $OS_ERROR" );
while (<$output>) {
chomp;
return $_;
}
- close $output;
+ if ( !( close $output ) && ( $OS_ERROR != 0 ) ) {
- $plugin->nagios_exit( UNKNOWN, 'Cannot determine the user' );
+ # close to a piped open return false if the command with non-zero
+ # status. In this case $! is set to 0
+ exit_with_error( UNKNOWN,
+ "Error while closing pipe to whoami: $OS_ERROR\n" );
+
+ }
+
+ exit_with_error( UNKNOWN, 'Cannot determine the user' );
return;
}
@@ -104,7 +151,7 @@
my $level = shift;
if ( !defined $message ) {
- $plugin->nagios_exit( UNKNOWN,
+ exit_with_error( UNKNOWN,
q{Internal error: not enough parameters for 'verbose'} );
}
@@ -113,7 +160,9 @@
}
if ( $level < $options->verbose ) {
- print $message;
+ #<<<
+ print $message; ## no critic (RequireCheckedSyscalls)
+ #>>>
}
return;
@@ -125,26 +174,26 @@
my $kernel = shift;
# remove PAE
-
- $kernel =~ s/\.[\w]*PAE//imxs;
+
+ $kernel =~ s/[.][\w]*PAE//imxs;
$kernel =~ s/PAE-//imxs;
# remove Xen
$kernel =~ s/xen-//imxs;
-
+
# remove architecture
-
- $kernel =~ s/\.(i[3-6]86|ppc|x86_64)$//mxs;
+
+ $kernel =~ s/[.](i[3-6]86|ppc|x86_64)$//mxs;
# remove smp
$kernel =~ s/smp$//mxs;
$kernel =~ s/smp-//imxs;
- # remove RH, Fedora and CentOSflavours
+ # remove RHEL, CentOS, Scientific Linux and Fedora flavours
- $kernel =~ s/\.el\d+.*//imxs;
- $kernel =~ s/.fc\d+.*//imxs;
+ $kernel =~ s/[.]el\d+.*//imxs;
+ $kernel =~ s/[.]fc\d+.*//imxs;
return $kernel;
@@ -180,14 +229,17 @@
my @versions;
- for my $rpm ( ( "$package", "$package-smp", "$package-PAE", "$package-xen" ) ) {
+ for
+ my $rpm ( ( "$package", "$package-smp", "$package-PAE", "$package-xen" ) )
+ {
my $output;
- my $pid = open $output, q{-|}, "rpm -q $rpm"
- or $plugin->nagios_exit( UNKNOWN,
+ #<<<
+ my $pid = open $output, q{-|}, "rpm -q $rpm" ## no critic (RequireBriefOpen)
+ or exit_with_error( UNKNOWN,
"Cannot list installed kernels: $OS_ERROR" );
-
+ #>>>
# there could be multiple versions of the same package installed
my @rpm_versions;
while (<$output>) {
@@ -199,7 +251,7 @@
# close to a piped open return false if the command with non-zero
# status. In this case $! is set to 0
- $plugin->nagios_exit( UNKNOWN,
+ exit_with_error( UNKNOWN,
"Error while closing pipe to rpm: $OS_ERROR\n" );
}
@@ -265,9 +317,10 @@
my $command = "yum $arguments check-update";
- my $pid = open $OUTPUT_HANDLER, q{-|}, $command
- or $plugin->nagios_exit( UNKNOWN, "Cannot list updates: $OS_ERROR" );
-
+ #<<<
+ my $pid = open $OUTPUT_HANDLER, q{-|}, $command ## no critic (RequireBriefOpen)
+ or exit_with_error( UNKNOWN, "Cannot list updates: $OS_ERROR" );
+ #>>>
while (<$OUTPUT_HANDLER>) {
my $line = $_;
@@ -281,7 +334,7 @@
next;
}
- if ( $line =~ m{^Loaded\ plugins:.*\ security.*}mxs ) {
+ if ( $line =~ m{^Loaded[ ]plugins:.*[ ]security.*}mxs ) {
if ( !$security_plugin ) {
@@ -291,25 +344,32 @@
$security_plugin = 1;
}
-
+
if ($blank_line) {
# some lines are wrapped and result and the second part
# is erroneously interpreted as a new update
- if ($line =~ m/^\ / ) {
+ if ( $line =~ m/^[ ]/mxs ) {
next;
}
- $line =~ s{\ .*}{}mxs;
+ $line =~ s{[ ].*}{}mxs;
push @updates, $line;
}
}
- close $OUTPUT_HANDLER;
+ if ( !( close $OUTPUT_HANDLER ) && ( $OS_ERROR != 0 ) ) {
+
+ # close to a piped open return false if the command with non-zero
+ # status. In this case $! is set to 0
+ exit_with_error( UNKNOWN,
+ "Error while closing pipe to rpm: $OS_ERROR\n" );
+
+ }
- if ( ( $CHILD_ERROR >> 8 ) == $YUM_RETURN_UPDATES_AVAILABLE ) {
+ if ( ( $CHILD_ERROR >> $BITS_PER_BYTE ) == $YUM_RETURN_UPDATES_AVAILABLE ) {
if ($security_plugin) {
verbose "Security updates available\n";
}
@@ -363,7 +423,12 @@
}
else {
- $status = WARNING;
+ if ( @outdated >= $options->get('warning') ) {
+ $status = WARNING;
+ }
+ if ( @outdated >= $options->get('critical') ) {
+ $status = CRITICAL;
+ }
@security_updates = run_yum('--security');
@@ -457,7 +522,7 @@
# parsing the output of up2date -l
if ( whoami() ne 'root' ) {
- $plugin->nagios_exit( CRITICAL,
+ exit_with_error( CRITICAL,
q{must be root to execute 'up2date -l': use sudo} );
}
@@ -466,17 +531,24 @@
my $command =
q{/usr/sbin/up2date -lf | /bin/grep -A 64 -- '----------------------------------------------------------' | /bin/grep '[[:alpha:]]'};
- my $pid = open $output, q{-|}, $command
- or $plugin->nagios_exit( UNKNOWN, "Cannot list updates: $OS_ERROR" );
+ my $pid = open $output, q{-|}, $command ## no critic (RequireBriefOpen)
+ or exit_with_error( UNKNOWN, "Cannot list updates: $OS_ERROR" );
while (<$output>) {
chomp;
my $line = $_;
- $line =~ s/\ .*//mxs;
+ $line =~ s/[ ].*//mxs;
push @status_lines, $line;
}
- close $output;
+ if ( !( close $output ) && ( $OS_ERROR != 0 ) ) {
+
+ # close to a piped open return false if the command with non-zero
+ # status. In this case $! is set to 0
+ exit_with_error( UNKNOWN,
+ "Error while closing pipe to yum (listing updates): $OS_ERROR\n" );
+
+ }
my $message;
@@ -484,7 +556,12 @@
$message = ( scalar @status_lines ) . ' update';
- $status = CRITICAL;
+ if ( @status_lines >= $options->get('warning') ) {
+ $status = WARNING;
+ }
+ if ( @status_lines >= $options->get('critical') ) {
+ $status = CRITICAL;
+ }
if ( @status_lines > 1 ) {
$message = $message . q{s};
@@ -523,115 +600,188 @@
}
##############################################################################
-# main
-#
+# Usage : my $system = get_os_name_and_version();
+# Purpose : returns the name of the system by parsing $VERSION_FILE
+# Returns : name of the system
+# Arguments : n/a
+# Throws : CRITICAL if not able to read $VERSION_FILE
+# Comments : n/a
+# See also : n/a
+sub get_os_name_and_version {
-################
-# initialization
-$help = q{};
-$bootcheck = 1;
-$wrong_kernel = 0;
-$plugin = Nagios::Plugin->new( shortname => 'CHECK_UPDATES' );
-
-########################
-# Command line arguments
-
-$options = Nagios::Plugin::Getopt->new(
- usage => 'Usage: %s [OPTIONS]',
- version => $VERSION,
- url => 'https://trac.id.ethz.ch/projects/nagios_plugins',
- blurb => 'Checks if RedHat or Fedora system is up-to-date',
-);
+ my $filename = shift;
+ if ( !$filename ) {
-$options->arg(
- spec => 'boot-check',
- help => 'Check if the machine was booted with the newest kernel (default)',
-);
+ # default
+ $filename = $VERSION_FILE;
+ }
-$options->arg(
- spec => 'no-boot-check',
- help => 'do not complain if the machine was booted with an old kernel',
-);
+ my $header;
-$options->arg(
- spec => 'warning|w=i',
- help =>
- 'Exit with WARNING status if more than INTEGER updates are available',
- default => 0
-);
+ if ( -r $filename ) {
-$options->arg(
- spec => 'critical|c=i',
- help =>
- 'Exit with CRITICAL status if more than INTEGER updates are available',
- default => 0
-);
+ my $TMP;
+
+ open $TMP, q{<}, $filename
+ or exit_with_error( CRITICAL, "Error opening $filename: $OS_ERROR" );
+ while (<$TMP>) {
+ chomp;
+ $header = $_;
+ last;
+ }
+ close $TMP
+ or exit_with_error( CRITICAL, "Error closing $filename: $OS_ERROR" );
-$options->getopts();
+ }
+ else {
+ exit_with_error( UNKNOWN,
+ "Cannot detect Linux distribution (no $filename file)" );
+ }
-$threshold = Nagios::Plugin::Threshold->set_thresholds(
- warning => $options->get('warning'),
- critical => $options->get('critical'),
-);
+ return $header;
-# check bootcheck consistency
-if ( $options->get('boot-check') && $options->get('no-boot-check') ) {
- $plugin->nagios_exit( CRITICAL,
- 'Error --boot-check and --no-boot-check specified at the same time' );
}
-if ( $options->get('no-boot-check') ) {
- $bootcheck = 0;
+##############################################################################
+# Usage : my $updater = get_updated()
+# Purpose : returns the name of updating system (yum or up2date)
+# Returns : name of updating system or undef if not found
+# Arguments : n/a
+# Throws : n/a
+# Comments : n/a
+# See also : n/a
+sub get_updater {
+
+ my $name = shift;
+
+ if ( $name =~ /Fedora/mxs
+ || $name =~ /CentOS/mxs
+ || $name =~ /Scientific[ ]Linux/mxs
+ || $name =~ /Red[ ]Hat.*[ ][56]/mxs )
+ {
+ return 'yum';
+ }
+ elsif ( $name =~ /Red[ ]Hat.*[ ]4/mxs ) {
+ return 'up2date';
+ }
+ return;
+
}
-#########
-# Timeout
+##############################################################################
+# Usage : run();
+# Purpose : main method
+# Returns : n/a
+# Arguments : n/a
+# Throws : n/a
+# Comments : n/a
+# See also : n/a
+sub run {
-alarm $options->timeout;
+ $status = OK;
-verbose "Checking a $OSNAME system\n";
+ ##############################################################################
+ # main
+ #
+
+ ################
+ # initialization
+ $help = q{};
+ $bootcheck = 1;
+ $wrong_kernel = 0;
+ $plugin = Nagios::Plugin->new( shortname => 'CHECK_UPDATES' );
+
+ ########################
+ # Command line arguments
+
+ $options = Nagios::Plugin::Getopt->new(
+ usage => 'Usage: %s [OPTIONS]',
+ version => $VERSION,
+ url => 'https://trac.id.ethz.ch/projects/nagios_plugins',
+ blurb => 'Checks if RedHat or Fedora system is up-to-date',
+ );
-if ( $OSNAME eq 'linux' ) {
+ $options->arg(
+ spec => 'boot-check',
+ help =>
+ 'Check if the machine was booted with the newest kernel (default)',
+ );
- if ( -r '/etc/issue' ) {
+ $options->arg(
+ spec => 'no-boot-check',
+ help => 'do not complain if the machine was booted with an old kernel',
+ );
- my $header;
- my $TMP;
+ $options->arg(
+ spec => 'warning|w=i',
+ help =>
+ 'Exit with WARNING status if more than INTEGER updates are available',
+ default => 0
+ );
- open $TMP, q{<}, '/etc/issue'
- or $plugin->nagios_exit( CRITICAL,
- "Error opening /etc/issue: $OS_ERROR" );
- while (<$TMP>) {
- chomp;
- $header = $_;
- last;
- }
- close $TMP
- or $plugin->nagios_exit( CRITICAL,
- "Error closing /etc/issue: $OS_ERROR" );
+ $options->arg(
+ spec => 'critical|c=i',
+ help =>
+'Exit with CRITICAL status if more than INTEGER updates are available',
+ default => 0
+ );
- if ( $header =~ /Fedora/mxs ) {
- verbose "Fedora detected: using yum\n";
- check_running_kernel();
- check_yum();
- }
- elsif ( $header =~ /CentOS/mxs ) {
- verbose "CentOS detected: using yum\n";
+ $options->getopts();
+
+ ###############
+ # Sanity checks
+
+ if ( $options->get('warning') > $options->get('critical') ) {
+ exit_with_error( UNKNOWN,
+ q{'critical' (}
+ . $options->get('critical')
+ . q{) must not be lower than 'warning' (}
+ . $options->get('warning')
+ . q{)} );
+ }
+
+ $threshold = Nagios::Plugin::Threshold->set_thresholds(
+ warning => $options->get('warning'),
+ critical => $options->get('critical'),
+ );
+
+ # check bootcheck consistency
+ if ( $options->get('boot-check') && $options->get('no-boot-check') ) {
+ exit_with_error( CRITICAL,
+ 'Error --boot-check and --no-boot-check specified at the same time'
+ );
+ }
+
+ if ( $options->get('no-boot-check') ) {
+ $bootcheck = 0;
+ }
+
+ #########
+ # Timeout
+
+ alarm $options->timeout;
+
+ verbose "Checking a $OSNAME system\n";
+
+ if ( $OSNAME eq 'linux' ) {
+
+ my $name = get_os_name_and_version();
+ verbose "Running on $name\n";
+
+ my $updater = get_updater($name);
+
+ if ( $updater eq 'yum' ) {
+ verbose "Using yum\n";
check_running_kernel();
check_yum();
}
- elsif ( $header =~ /Red\ Hat.*\ 4/mxs ) {
- verbose "RedHat 4 detected: using up2date\n";
+ elsif ( $updater eq 'up2date' ) {
+ verbose "Using up2date\n";
check_running_kernel();
check_up2date();
}
- elsif ( $header =~ /Red\ Hat.*\ 5/mxs ) {
- verbose "RedHat 5 detected: using yum\n";
- check_running_kernel();
- check_yum();
- }
else {
- $plugin->nagios_exit( UNKNOWN, 'unknown Linux distribution' );
+ exit_with_error( UNKNOWN, 'unknown Linux distribution' );
}
if ( $bootcheck && $wrong_kernel ) {
@@ -641,28 +791,35 @@
# Nagios::Plugin does not support the addition Nagios 3 status lines
# -> we do it manually
- print 'CHECK_UPDATES '
- . $Nagios::Plugin::STATUS_TEXT{$status}
- . " - $exit_message |";
-
+ #<<<
+ print 'CHECK_UPDATES ' ## no critic (RequireCheckedSyscalls)
+ . $Nagios::Plugin::STATUS_TEXT{$status}
+ . " - $exit_message |";
+ #>>>
for my $pdata ( @{ $plugin->perfdata } ) {
- print q{ } . $pdata->perfoutput;
+ #<<<
+ print q{ } . $pdata->perfoutput; ## no critic (RequireCheckedSyscalls)
+ #>>>
}
- print "\n";
-
+ #<<<
+ print "\n"; ## no critic (RequireCheckedSyscalls)
+ #>>>
for my $package (@status_lines) {
- print "$package\n";
+ #<<<
+ print "$package\n"; ## no critic (RequireCheckedSyscalls)
+ #>>>
}
exit $status;
}
else {
- $plugin->nagios_exit( UNKNOWN,
- 'Cannot detect Linux distribution (no /etc/issue file)' );
+ exit_with_error( UNKNOWN, 'Cannot detect Linux system' );
}
+ return;
+
}
1;
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/check_updates.pod
^
|
@@ -1,9 +1,9 @@
################################################################################
# File version information:
-# $Id: check_updates.pod 1207 2010-11-18 10:17:33Z corti $
-# $Revision: 1207 $
+# $Id: check_updates.pod 1269 2011-10-03 08:00:30Z corti $
+# $Revision: 1269 $
# $HeadURL: https://svn.id.ethz.ch/nagios_plugins/check_updates/check_updates.pod $
-# $Date: 2010-11-18 11:17:33 +0100 (Thu, 18 Nov 2010) $
+# $Date: 2011-10-03 10:00:30 +0200 (Mon, 03 Oct 2011) $
################################################################################
=pod
@@ -20,7 +20,7 @@
=head1 VERSION
-Version 1.4.11
+Version 1.5.0
=head1 SYNOPSIS
@@ -69,6 +69,8 @@
-v, --verbose Show details for command-line debugging (can repeat up to 3 times)
+Security updates always force a CRITICAL state
+
=head1 EXAMPLE
check_updates
@@ -127,6 +129,10 @@
or through the web interface at
http://trac.id.ethz.ch/projects/nagios_plugins/newticket?component=check_updates
+Be sure to include the output produced by the plugin with the --verbose option:
+
+ check_updates -v -v -v
+
=head1 AUTHOR
Matteo Corti <matteo.corti@id.ethz.ch>
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/check_updates.spec
^
|
@@ -1,12 +1,12 @@
################################################################################
# File version information:
-# $Id: check_updates.spec 1207 2010-11-18 10:17:33Z corti $
-# $Revision: 1207 $
+# $Id: check_updates.spec 1269 2011-10-03 08:00:30Z corti $
+# $Revision: 1269 $
# $HeadURL: https://svn.id.ethz.ch/nagios_plugins/check_updates/check_updates.spec $
-# $Date: 2010-11-18 11:17:33 +0100 (Thu, 18 Nov 2010) $
+# $Date: 2011-10-03 10:00:30 +0200 (Mon, 03 Oct 2011) $
################################################################################
-%define version 1.4.11
+%define version 1.5.0
%define release 0
%define sourcename check_updates
%define packagename nagios-plugins-check-updates
@@ -29,6 +29,10 @@
# Fedora build requirement (not needed for EPEL{4,5})
BuildRequires: perl(ExtUtils::MakeMaker)
+BuildRequires: perl(Test::More)
+BuildRequires: perl(Nagios::Plugin)
+BuildRequires: perl(Readonly)
+BuildRequires: perl(Sort::Versions)
Requires: nagios-plugins
# Yum security plugin RPM:
@@ -56,6 +60,9 @@
find %{buildroot} -depth -type d -exec rmdir {} 2>/dev/null \;
%{_fixperms} %{buildroot}/*
+%check
+make test
+
%clean
rm -rf %{buildroot}
@@ -66,6 +73,22 @@
%{_mandir}/man1/%{sourcename}.1*
%changelog
+* Mon Oct 3 2011 Matteo Corti <matteo.corti@id.ethz.ch> - 1.5.0-0
+- Updated to 1.5.0 (fixed a bug which caused -w and -c to be ignored)
+
+* Fri Sep 23 2011 Matteo Corti <matteo.corti@id.ethz.ch> - 1.4.15-0
+- Updated to 1.4.15 (which now uses /etc/redhat-release instead of /etc/issue)
+
+* Wed May 25 2011 Matteo Corti <matteo.corti@id.ethz.ch> - 1.4.14-0
+- Fixed a runtime check on correct command execution
+
+* Tue May 24 2011 Matteo Corti <matteo.corti@id.ethz.ch> - 1.4.13-0
+- fixed the unit tests on RH systems (old Test::Simple version)
+- added the unit tests to the build process
+
+* Tue May 24 2011 Matteo Corti <matteo.corti@id.ethz.ch> - 1.4.12-0
+- fixed the detection of RH 6 and Scientific Linux Systems
+
* Thu Nov 18 2010 Matteo Corti <matteo.corti@id.ethz.ch> - 1.4.11-0
- fixed the processing of Xen kernels
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/inc/Module/Install.pm
^
|
@@ -22,7 +22,6 @@
use Cwd ();
use File::Find ();
use File::Path ();
-use FindBin;
use vars qw{$VERSION $MAIN};
BEGIN {
@@ -32,7 +31,7 @@
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
- $VERSION = '0.95';
+ $VERSION = '1.01';
# Storage for the pseudo-singleton
$MAIN = undef;
@@ -127,6 +126,11 @@
#-------------------------------------------------------------
unless ( -f $self->{file} ) {
+ foreach my $key (keys %INC) {
+ delete $INC{$key} if $key =~ /Module\/Install/;
+ }
+
+ local $^W;
require "$self->{path}/$self->{dispatch}.pm";
File::Path::mkpath("$self->{prefix}/$self->{author}");
$self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self );
@@ -135,12 +139,13 @@
goto &{"$self->{name}::import"};
}
+ local $^W;
*{"${who}::AUTOLOAD"} = $self->autoload;
$self->preload;
# Unregister loader and worker packages so subdirs can use them again
- delete $INC{"$self->{file}"};
- delete $INC{"$self->{path}.pm"};
+ delete $INC{'inc/Module/Install.pm'};
+ delete $INC{'Module/Install.pm'};
# Save to the singleton
$MAIN = $self;
@@ -159,7 +164,21 @@
# Delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
}
- $$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
+ unless ($$sym =~ s/([^:]+)$//) {
+ # XXX: it looks like we can't retrieve the missing function
+ # via $$sym (usually $main::AUTOLOAD) in this case.
+ # I'm still wondering if we should slurp Makefile.PL to
+ # get some context or not ...
+ my ($package, $file, $line) = caller;
+ die <<"EOT";
+Unknown function is found at $file line $line.
+Execution of $file aborted due to runtime errors.
+
+If you're a contributor to a project, you may need to install
+some Module::Install extensions from CPAN (or other repository).
+If you're a user of a module, please contact the author.
+EOT
+ }
my $method = $1;
if ( uc($method) eq $method ) {
# Do nothing
@@ -200,6 +219,7 @@
my $who = $self->_caller;
foreach my $name ( sort keys %seen ) {
+ local $^W;
*{"${who}::$name"} = sub {
${"${who}::AUTOLOAD"} = "${who}::$name";
goto &{"${who}::AUTOLOAD"};
@@ -210,12 +230,18 @@
sub new {
my ($class, %args) = @_;
+ delete $INC{'FindBin.pm'};
+ {
+ # to suppress the redefine warning
+ local $SIG{__WARN__} = sub {};
+ require FindBin;
+ }
+
# ignore the prefix on extension modules built from top level.
my $base_path = Cwd::abs_path($FindBin::Bin);
unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) {
delete $args{prefix};
}
-
return $args{_self} if $args{_self};
$args{dispatch} ||= 'Admin';
@@ -268,8 +294,10 @@
sub load_extensions {
my ($self, $path, $top) = @_;
+ my $should_reload = 0;
unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) {
unshift @INC, $self->{prefix};
+ $should_reload = 1;
}
foreach my $rv ( $self->find_extensions($path) ) {
@@ -277,12 +305,13 @@
next if $self->{pathnames}{$pkg};
local $@;
- my $new = eval { require $file; $pkg->can('new') };
+ my $new = eval { local $^W; require $file; $pkg->can('new') };
unless ( $new ) {
warn $@ if $@;
next;
}
- $self->{pathnames}{$pkg} = delete $INC{$file};
+ $self->{pathnames}{$pkg} =
+ $should_reload ? delete $INC{$file} : $INC{$file};
push @{$self->{extensions}}, &{$new}($pkg, _top => $top );
}
@@ -438,4 +467,4 @@
1;
-# Copyright 2008 - 2010 Adam Kennedy.
+# Copyright 2008 - 2011 Adam Kennedy.
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/inc/Module/Install/Base.pm
^
|
@@ -4,7 +4,7 @@
use strict 'vars';
use vars qw{$VERSION};
BEGIN {
- $VERSION = '0.95';
+ $VERSION = '1.01';
}
# Suspend handler for "redefined" warnings
@@ -51,13 +51,18 @@
#line 106
sub is_admin {
- $_[0]->admin->VERSION;
+ ! $_[0]->admin->isa('Module::Install::Base::FakeAdmin');
}
sub DESTROY {}
package Module::Install::Base::FakeAdmin;
+use vars qw{$VERSION};
+BEGIN {
+ $VERSION = $Module::Install::Base::VERSION;
+}
+
my $fake;
sub new {
@@ -75,4 +80,4 @@
1;
-#line 154
+#line 159
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/inc/Module/Install/Include.pm
^
|
@@ -6,7 +6,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.95';
+ $VERSION = '1.01';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/inc/Module/Install/MakeMaker.pm
^
|
@@ -7,7 +7,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.95';
+ $VERSION = '1.01';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/inc/Module/Install/Makefile.pm
^
|
@@ -4,10 +4,11 @@
use strict 'vars';
use ExtUtils::MakeMaker ();
use Module::Install::Base ();
+use Fcntl qw/:flock :seek/;
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.95';
+ $VERSION = '1.01';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -101,24 +102,26 @@
my ($self, %new_args) = @_;
my $args = ( $self->{makemaker_args} ||= {} );
foreach my $key (keys %new_args) {
- if ($makemaker_argtype{$key} eq 'ARRAY') {
- $args->{$key} = [] unless defined $args->{$key};
- unless (ref $args->{$key} eq 'ARRAY') {
- $args->{$key} = [$args->{$key}]
+ if ($makemaker_argtype{$key}) {
+ if ($makemaker_argtype{$key} eq 'ARRAY') {
+ $args->{$key} = [] unless defined $args->{$key};
+ unless (ref $args->{$key} eq 'ARRAY') {
+ $args->{$key} = [$args->{$key}]
+ }
+ push @{$args->{$key}},
+ ref $new_args{$key} eq 'ARRAY'
+ ? @{$new_args{$key}}
+ : $new_args{$key};
}
- push @{$args->{$key}},
- ref $new_args{$key} eq 'ARRAY'
- ? @{$new_args{$key}}
- : $new_args{$key};
- }
- elsif ($makemaker_argtype{$key} eq 'HASH') {
- $args->{$key} = {} unless defined $args->{$key};
- foreach my $skey (keys %{ $new_args{$key} }) {
- $args->{$key}{$skey} = $new_args{$key}{$skey};
+ elsif ($makemaker_argtype{$key} eq 'HASH') {
+ $args->{$key} = {} unless defined $args->{$key};
+ foreach my $skey (keys %{ $new_args{$key} }) {
+ $args->{$key}{$skey} = $new_args{$key}{$skey};
+ }
+ }
+ elsif ($makemaker_argtype{$key} eq 'APPENDABLE') {
+ $self->makemaker_append($key => $new_args{$key});
}
- }
- elsif ($makemaker_argtype{$key} eq 'APPENDABLE') {
- $self->makemaker_append($key => $new_args{$key});
}
else {
if (defined $args->{$key}) {
@@ -178,28 +181,22 @@
$self->makemaker_args( INC => shift );
}
-my %test_dir = ();
-
sub _wanted_t {
- /\.t$/ and -f $_ and $test_dir{$File::Find::dir} = 1;
}
sub tests_recursive {
my $self = shift;
- if ( $self->tests ) {
- die "tests_recursive will not work if tests are already defined";
- }
my $dir = shift || 't';
unless ( -d $dir ) {
die "tests_recursive dir '$dir' does not exist";
}
- %test_dir = ();
+ my %tests = map { $_ => 1 } split / /, ($self->tests || '');
require File::Find;
- File::Find::find( \&_wanted_t, $dir );
- if ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) {
- File::Find::find( \&_wanted_t, 'xt' );
- }
- $self->tests( join ' ', map { "$_/*.t" } sort keys %test_dir );
+ File::Find::find(
+ sub { /\.t$/ and -f $_ and $tests{"$File::Find::dir/*.t"} = 1 },
+ $dir
+ );
+ $self->tests( join ' ', sort keys %tests );
}
sub write {
@@ -251,6 +248,9 @@
$args->{test} = {
TESTS => (join ' ', grep {!$seen{$_}++} @tests),
};
+ } elsif ( $Module::Install::ExtraTests::use_extratests ) {
+ # Module::Install::ExtraTests doesn't set $self->tests and does its own tests via harness.
+ # So, just ignore our xt tests here.
} elsif ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) {
$args->{test} = {
TESTS => join( ' ', map { "$_/*.t" } grep { -d $_ } qw{ t xt } ),
@@ -297,13 +297,22 @@
# Remove any reference to perl, BUILD_REQUIRES doesn't support it
delete $args->{BUILD_REQUIRES}->{perl};
- # Delete bundled dists from prereq_pm
- my $subdirs = ($args->{DIR} ||= []);
+ # Delete bundled dists from prereq_pm, add it to Makefile DIR
+ my $subdirs = ($args->{DIR} || []);
if ($self->bundles) {
+ my %processed;
foreach my $bundle (@{ $self->bundles }) {
- my ($file, $dir) = @$bundle;
- push @$subdirs, $dir if -d $dir;
- delete $build_prereq->{$file}; #Delete from build prereqs only
+ my ($mod_name, $dist_dir) = @$bundle;
+ delete $prereq->{$mod_name};
+ $dist_dir = File::Basename::basename($dist_dir); # dir for building this module
+ if (not exists $processed{$dist_dir}) {
+ if (-d $dist_dir) {
+ # List as sub-directory to be processed by make
+ push @$subdirs, $dist_dir;
+ }
+ # Else do nothing: the module is already present on the system
+ $processed{$dist_dir} = undef;
+ }
}
}
@@ -356,9 +365,9 @@
. ($self->postamble || '');
local *MAKEFILE;
- open MAKEFILE, "< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
+ open MAKEFILE, "+< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
+ eval { flock MAKEFILE, LOCK_EX };
my $makefile = do { local $/; <MAKEFILE> };
- close MAKEFILE or die $!;
$makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
$makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
@@ -378,7 +387,8 @@
# XXX - This is currently unused; not sure if it breaks other MM-users
# $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg;
- open MAKEFILE, "> $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
+ seek MAKEFILE, 0, SEEK_SET;
+ truncate MAKEFILE, 0;
print MAKEFILE "$preamble$makefile$postamble" or die $!;
close MAKEFILE or die $!;
@@ -402,4 +412,4 @@
__END__
-#line 531
+#line 541
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/inc/Module/Install/Metadata.pm
^
|
@@ -6,7 +6,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.95';
+ $VERSION = '1.01';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -178,43 +178,6 @@
$self->{values}->{perl_version} = $version;
}
-#Stolen from M::B
-my %license_urls = (
- perl => 'http://dev.perl.org/licenses/',
- apache => 'http://apache.org/licenses/LICENSE-2.0',
- artistic => 'http://opensource.org/licenses/artistic-license.php',
- artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php',
- lgpl => 'http://opensource.org/licenses/lgpl-license.php',
- lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php',
- lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html',
- bsd => 'http://opensource.org/licenses/bsd-license.php',
- gpl => 'http://opensource.org/licenses/gpl-license.php',
- gpl2 => 'http://opensource.org/licenses/gpl-2.0.php',
- gpl3 => 'http://opensource.org/licenses/gpl-3.0.html',
- mit => 'http://opensource.org/licenses/mit-license.php',
- mozilla => 'http://opensource.org/licenses/mozilla1.1.php',
- open_source => undef,
- unrestricted => undef,
- restrictive => undef,
- unknown => undef,
-);
-
-sub license {
- my $self = shift;
- return $self->{values}->{license} unless @_;
- my $license = shift or die(
- 'Did not provide a value to license()'
- );
- $self->{values}->{license} = $license;
-
- # Automatically fill in license URLs
- if ( $license_urls{$license} ) {
- $self->resources( license => $license_urls{$license} );
- }
-
- return 1;
-}
-
sub all_from {
my ( $self, $file ) = @_;
@@ -354,6 +317,9 @@
require ExtUtils::MM_Unix;
my ( $self, $file ) = @_;
$self->version( ExtUtils::MM_Unix->parse_version($file) );
+
+ # for version integrity check
+ $self->makemaker_args( VERSION_FROM => $file );
}
sub abstract_from {
@@ -364,7 +330,7 @@
{ DISTNAME => $self->name },
'ExtUtils::MM_Unix'
)->parse_abstract($file)
- );
+ );
}
# Add both distribution and module name
@@ -479,42 +445,90 @@
}
}
+#Stolen from M::B
+my %license_urls = (
+ perl => 'http://dev.perl.org/licenses/',
+ apache => 'http://apache.org/licenses/LICENSE-2.0',
+ apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1',
+ artistic => 'http://opensource.org/licenses/artistic-license.php',
+ artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php',
+ lgpl => 'http://opensource.org/licenses/lgpl-license.php',
+ lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php',
+ lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html',
+ bsd => 'http://opensource.org/licenses/bsd-license.php',
+ gpl => 'http://opensource.org/licenses/gpl-license.php',
+ gpl2 => 'http://opensource.org/licenses/gpl-2.0.php',
+ gpl3 => 'http://opensource.org/licenses/gpl-3.0.html',
+ mit => 'http://opensource.org/licenses/mit-license.php',
+ mozilla => 'http://opensource.org/licenses/mozilla1.1.php',
+ open_source => undef,
+ unrestricted => undef,
+ restrictive => undef,
+ unknown => undef,
+);
+
+sub license {
+ my $self = shift;
+ return $self->{values}->{license} unless @_;
+ my $license = shift or die(
+ 'Did not provide a value to license()'
+ );
+ $license = __extract_license($license) || lc $license;
+ $self->{values}->{license} = $license;
+
+ # Automatically fill in license URLs
+ if ( $license_urls{$license} ) {
+ $self->resources( license => $license_urls{$license} );
+ }
+
+ return 1;
+}
+
sub _extract_license {
my $pod = shift;
my $matched;
return __extract_license(
($matched) = $pod =~ m/
- (=head \d \s+ (?:licen[cs]e|licensing)\b.*?)
+ (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?)
(=head \d.*|=cut.*|)\z
- /ixms
+ /xms
) || __extract_license(
($matched) = $pod =~ m/
- (=head \d \s+ (?:copyrights?|legal)\b.*?)
+ (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?)
(=head \d.*|=cut.*|)\z
- /ixms
+ /xms
);
}
sub __extract_license {
my $license_text = shift or return;
my @phrases = (
- 'under the same (?:terms|license) as (?:perl|the perl programming language)' => 'perl', 1,
- 'under the terms of (?:perl|the perl programming language) itself' => 'perl', 1,
- 'Artistic and GPL' => 'perl', 1,
- 'GNU general public license' => 'gpl', 1,
- 'GNU public license' => 'gpl', 1,
- 'GNU lesser general public license' => 'lgpl', 1,
- 'GNU lesser public license' => 'lgpl', 1,
- 'GNU library general public license' => 'lgpl', 1,
- 'GNU library public license' => 'lgpl', 1,
- 'BSD license' => 'bsd', 1,
- 'Artistic license' => 'artistic', 1,
- 'GPL' => 'gpl', 1,
- 'LGPL' => 'lgpl', 1,
- 'BSD' => 'bsd', 1,
- 'Artistic' => 'artistic', 1,
- 'MIT' => 'mit', 1,
- 'proprietary' => 'proprietary', 0,
+ '(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1,
+ '(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1,
+ 'Artistic and GPL' => 'perl', 1,
+ 'GNU general public license' => 'gpl', 1,
+ 'GNU public license' => 'gpl', 1,
+ 'GNU lesser general public license' => 'lgpl', 1,
+ 'GNU lesser public license' => 'lgpl', 1,
+ 'GNU library general public license' => 'lgpl', 1,
+ 'GNU library public license' => 'lgpl', 1,
+ 'GNU Free Documentation license' => 'unrestricted', 1,
+ 'GNU Affero General Public License' => 'open_source', 1,
+ '(?:Free)?BSD license' => 'bsd', 1,
+ 'Artistic license 2\.0' => 'artistic_2', 1,
+ 'Artistic license' => 'artistic', 1,
+ 'Apache (?:Software )?license' => 'apache', 1,
+ 'GPL' => 'gpl', 1,
+ 'LGPL' => 'lgpl', 1,
+ 'BSD' => 'bsd', 1,
+ 'Artistic' => 'artistic', 1,
+ 'MIT' => 'mit', 1,
+ 'Mozilla Public License' => 'mozilla', 1,
+ 'Q Public License' => 'open_source', 1,
+ 'OpenSSL License' => 'unrestricted', 1,
+ 'SSLeay License' => 'unrestricted', 1,
+ 'zlib License' => 'open_source', 1,
+ 'proprietary' => 'proprietary', 0,
);
while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) {
$pattern =~ s#\s+#\\s+#gs;
@@ -522,6 +536,7 @@
return $license;
}
}
+ return '';
}
sub license_from {
@@ -536,9 +551,9 @@
sub _extract_bugtracker {
my @links = $_[0] =~ m#L<(
- \Qhttp://rt.cpan.org/\E[^>]+|
- \Qhttp://github.com/\E[\w_]+/[\w_]+/issues|
- \Qhttp://code.google.com/p/\E[\w_\-]+/issues/list
+ https?\Q://rt.cpan.org/\E[^>]+|
+ https?\Q://github.com/\E[\w_]+/[\w_]+/issues|
+ https?\Q://code.google.com/p/\E[\w_\-]+/issues/list
)>#gx;
my %links;
@links{@links}=();
@@ -602,8 +617,15 @@
return $v;
}
-
-
+sub add_metadata {
+ my $self = shift;
+ my %hash = @_;
+ for my $key (keys %hash) {
+ warn "add_metadata: $key is not prefixed with 'x_'.\n" .
+ "Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/;
+ $self->{values}->{$key} = $hash{$key};
+ }
+}
######################################################################
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/inc/Module/Install/Scripts.pm
^
|
@@ -6,7 +6,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.95';
+ $VERSION = '1.01';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
|
[-]
[+]
|
Changed |
check_updates-1.5.0.tar.bz2/inc/version.pm
^
|
@@ -7,7 +7,7 @@
use vars qw(@ISA $VERSION $CLASS $STRICT $LAX *declare *qv);
-$VERSION = 0.82;
+$VERSION = 0.88;
$CLASS = 'version';
@@ -115,6 +115,40 @@
#--------------------------------------------------------------------------#
+eval "use version::vxs $VERSION";
+if ( $@ ) { # don't have the XS version installed
+ eval "use version::vpp $VERSION"; # don't tempt fate
+ die "$@" if ( $@ );
+ push @ISA, "version::vpp";
+ local $^W;
+ *version::qv = \&version::vpp::qv;
+ *version::declare = \&version::vpp::declare;
+ *version::_VERSION = \&version::vpp::_VERSION;
+ if ($] >= 5.009000 && $] < 5.011004) {
+ no strict 'refs';
+ *version::stringify = \&version::vpp::stringify;
+ *{'version::(""'} = \&version::vpp::stringify;
+ *version::new = \&version::vpp::new;
+ *version::parse = \&version::vpp::parse;
+ }
+}
+else { # use XS module
+ push @ISA, "version::vxs";
+ local $^W;
+ *version::declare = \&version::vxs::declare;
+ *version::qv = \&version::vxs::qv;
+ *version::_VERSION = \&version::vxs::_VERSION;
+ *version::vcmp = \&version::vxs::VCMP;
+ if ($] >= 5.009000 && $] < 5.011004) {
+ no strict 'refs';
+ *version::stringify = \&version::vxs::stringify;
+ *{'version::(""'} = \&version::vxs::stringify;
+ *version::new = \&version::vxs::new;
+ *version::parse = \&version::vxs::parse;
+ }
+
+}
+
# Preloaded methods go here.
sub import {
no strict 'refs';
@@ -153,16 +187,24 @@
unless defined(&{$callpkg.'::qv'});
}
+ if (exists($args{'UNIVERSAL::VERSION'})) {
+ local $^W;
+ *UNIVERSAL::VERSION
+ = \&version::_VERSION;
+ }
+
if (exists($args{'VERSION'})) {
*{$callpkg.'::VERSION'} = \&version::_VERSION;
}
if (exists($args{'is_strict'})) {
- *{$callpkg.'::is_strict'} = \&version::is_strict;
+ *{$callpkg.'::is_strict'} = \&version::is_strict
+ unless defined(&{$callpkg.'::is_strict'});
}
if (exists($args{'is_lax'})) {
- *{$callpkg.'::is_lax'} = \&version::is_lax;
+ *{$callpkg.'::is_lax'} = \&version::is_lax
+ unless defined(&{$callpkg.'::is_lax'});
}
}
|
[-]
[+]
|
Added |
check_updates-1.5.0.tar.bz2/t
^
|
+(directory)
|
[-]
[+]
|
Added |
check_updates-1.5.0.tar.bz2/t/00_modules.t
^
|
@@ -0,0 +1,43 @@
+#!perl
+
+# $Id: README 1103 2009-12-07 07:49:19Z corti $
+# $Revision: 1103 $
+# $HeadURL: https://svn.id.ethz.ch/nagios_plugins/check_updates/README $
+# $Date: 2009-12-07 08:49:19 +0100 (Mon, 07 Dec 2009) $
+
+use 5.00800;
+
+use strict;
+use warnings;
+
+use Test::More tests => 19;
+
+our $VERSION = '1.4.15';
+
+use_ok('Carp');
+
+use_ok('English');
+
+use_ok('Nagios::Plugin');
+can_ok( 'Nagios::Plugin', 'new' );
+can_ok( 'Nagios::Plugin', 'nagios_exit' );
+can_ok( 'Nagios::Plugin', 'add_perfdata' );
+can_ok( 'Nagios::Plugin', 'perfdata' );
+
+use_ok('Nagios::Plugin::Getopt');
+can_ok( 'Nagios::Plugin::Getopt', 'new' );
+can_ok( 'Nagios::Plugin::Getopt', 'arg' );
+can_ok( 'Nagios::Plugin::Getopt', 'getopts' );
+can_ok( 'Nagios::Plugin::Getopt', 'get' );
+
+use_ok('Nagios::Plugin::Threshold');
+can_ok( 'Nagios::Plugin::Threshold', 'new' );
+can_ok( 'Nagios::Plugin::Threshold', 'set_thresholds' );
+
+use_ok('POSIX');
+can_ok( 'POSIX', 'uname' );
+
+use_ok('Sort::Versions');
+can_ok( 'Sort::Versions', 'versioncmp' );
+
+1;
|
[-]
[+]
|
Added |
check_updates-1.5.0.tar.bz2/t/01_functions.t
^
|
@@ -0,0 +1,67 @@
+#!perl
+
+# $Id: README 1103 2009-12-07 07:49:19Z corti $
+# $Revision: 1103 $
+# $HeadURL: https://svn.id.ethz.ch/nagios_plugins/check_updates/README $
+# $Date: 2009-12-07 08:49:19 +0100 (Mon, 07 Dec 2009) $
+
+use 5.00800;
+
+use strict;
+use warnings;
+
+use Test::More tests => 14;
+
+use File::Spec;
+
+our $VERSION = '1.4.15';
+
+my $check_updates = File::Spec->catfile(qw(blib script check_updates));
+
+require_ok($check_updates);
+
+# any user is OK
+like( whoami(), '/[\w]/mxs', 'whoami' );
+
+is( clean_kernel_version('kernel-2.6.35.13-91.fc14.i686'),
+ 'kernel-2.6.35.13-91', 'kernel version Fedora' );
+is( clean_kernel_version('kernel-2.6.18-194.3.1.el5'),
+ 'kernel-2.6.18-194.3.1', 'kernel version RHEL' );
+
+# TODO: should be extended with mock files
+is(
+ get_os_name_and_version('t/examples/fedora_14'),
+ 'Fedora release 14 (Laughlin)',
+ '/etc/redhat-release Fedora'
+);
+is(
+ get_os_name_and_version('t/examples/fedora_15'),
+ 'Fedora release 15 (Lovelock)',
+ '/etc/redhat-release Fedora'
+);
+is(
+ get_os_name_and_version('t/examples/rhel_4'),
+ 'Red Hat Enterprise Linux AS release 4 (Nahant Update 9)',
+ '/etc/redhat-release RHEL 4'
+);
+is(
+ get_os_name_and_version('t/examples/rhel_6'),
+ 'Red Hat Enterprise Linux Server release 6.1 (Santiago)',
+ '/etc/redhat-release RHEL 6'
+);
+is(
+ get_os_name_and_version('t/examples/scientific_linux_6'),
+ 'Scientific Linux release 6.0 (Carbon)',
+ '/etc/redhat-release Scientific Linux'
+);
+
+is( get_updater('Fedora release 14 (Laughlin)'), 'yum', 'updater Fedora' );
+is( get_updater('Fedora release 15 (Lovelock)'), 'yum', 'updater Fedora' );
+is( get_updater('Red Hat Enterprise Linux Server release 6.1 (Santiago)'),
+ 'yum', 'updater FedorRHEL 6' );
+is( get_updater('Scientific Linux release 6.0 (Carbon)'),
+ 'yum', 'updater Scientific Linux' );
+is( get_updater('Red Hat Enterprise Linux AS release 4 (Nahant Update 9)'),
+ 'up2date', 'updater RHEL 4' );
+
+1;
|
[-]
[+]
|
Added |
check_updates-1.5.0.tar.bz2/t/examples
^
|
+(directory)
|
[-]
[+]
|
Added |
check_updates-1.5.0.tar.bz2/t/examples/fedora_14
^
|
@@ -0,0 +1,3 @@
+Fedora release 14 (Laughlin)
+Kernel \r on an \m (\l)
+
|
[-]
[+]
|
Added |
check_updates-1.5.0.tar.bz2/t/examples/fedora_15
^
|
@@ -0,0 +1,3 @@
+Fedora release 15 (Lovelock)
+Kernel \r on an \m (\l)
+
|
[-]
[+]
|
Added |
check_updates-1.5.0.tar.bz2/t/examples/rhel_4
^
|
@@ -0,0 +1,3 @@
+Red Hat Enterprise Linux AS release 4 (Nahant Update 9)
+Kernel \r on an \m
+
|
[-]
[+]
|
Added |
check_updates-1.5.0.tar.bz2/t/examples/rhel_6
^
|
@@ -0,0 +1,3 @@
+Red Hat Enterprise Linux Server release 6.1 (Santiago)
+Kernel \r on an \m
+
|
[-]
[+]
|
Added |
check_updates-1.5.0.tar.bz2/t/examples/scientific_linux_6
^
|
@@ -0,0 +1,3 @@
+Scientific Linux release 6.0 (Carbon)
+Kernel \r on an \m
+
|