From be75c98a06d569fbaa2d86f92676af961795d094 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Fri, 21 Oct 2011 01:28:48 +0100 Subject: Add the mdkconf patch --- mandriva/partmon/Makefile | 14 +++++++++ mandriva/partmon/partmon | 59 +++++++++++++++++++++++++++++++++++ mandriva/partmon/partmon.pl | 64 ++++++++++++++++++++++++++++++++++++++ mandriva/partmon/partmon.sysconfig | 5 +++ 4 files changed, 142 insertions(+) create mode 100644 mandriva/partmon/Makefile create mode 100644 mandriva/partmon/partmon create mode 100644 mandriva/partmon/partmon.pl create mode 100644 mandriva/partmon/partmon.sysconfig (limited to 'mandriva/partmon') diff --git a/mandriva/partmon/Makefile b/mandriva/partmon/Makefile new file mode 100644 index 00000000..7aaa5489 --- /dev/null +++ b/mandriva/partmon/Makefile @@ -0,0 +1,14 @@ +SH=partmon +PL=partmon.pl + +all: check + +check: + @for i in $(SH);do /bin/bash -n $$i || exit 1;echo $$i syntax OK;done + @for i in $(PL);do perl -wc $$i || exit 1;done + +install: + mkdir -p $(ROOT)/usr/bin $(ROOT)/etc/rc.d/init.d + install -D -m755 partmon $(ROOT)/etc/rc.d/init.d/partmon + install -D -m755 partmon.pl $(ROOT)/usr/bin/partmon + install -D -m644 partmon.sysconfig $(ROOT)/etc/sysconfig/partmon diff --git a/mandriva/partmon/partmon b/mandriva/partmon/partmon new file mode 100644 index 00000000..60405d8f --- /dev/null +++ b/mandriva/partmon/partmon @@ -0,0 +1,59 @@ +#!/bin/sh +# +# Checks if a partition is close to full up +# +# description: Checks if a partition is close to full up +# chkconfig: 345 13 20 +# +### BEGIN INIT INFO +# Provides: partmon +# Default-Start: 3 4 5 +# Short-Description: Checks if a partition is close to full up +# Description: Checks if a partition is close to full up +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +# The following file prevents from "starting" again when changing +# runlevel +SYSCONF_FILE=/var/lock/subsys/partmon + +# See how we were called. +case "$1" in + start) + gprintf "Checking if partitions have enough free diskspace: " + str=`/usr/bin/partmon` + if [ "$str" = "" ]; then + echo_success + touch $SYSCONF_FILE + else + echo # to start to print problems at column 0 + echo $str + echo_failure + echo + exit 1 + fi + echo + ;; + stop) + rm -f $SYSCONF_FILE + ;; + status) + if [ -f $SYSCONF_FILE ] + then + gprintf "partmon has been started" + else + gprintf "partmon has not been started, or check gave a failure" + fi + ;; + restart) + $0 stop + $0 start + ;; + *) + gprintf "Usage: %s\n" "$0 {start|stop|restart|status}" + exit 1 +esac + +exit 0 diff --git a/mandriva/partmon/partmon.pl b/mandriva/partmon/partmon.pl new file mode 100644 index 00000000..d6d297b6 --- /dev/null +++ b/mandriva/partmon/partmon.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl +# +# Guillaume Cottenceau (gc@mandriva.com) +# +# Copyright 2002 Mandriva +# +# This software may be freely redistributed under the terms of the GNU +# public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# +#use strict; +use MDK::Common; + +my ($verbose); + +sub free_space { + my ($mntpoint) = @_; + my ($blocksize, $size, $avail); + my $buf = ' ' x 20000; + syscall_('statfs', $mntpoint, $buf) or return; + (undef, $blocksize, $size, undef, $avail, undef) = unpack "L!6", $buf; + return $avail * ($blocksize / 1024); +} + +my %partlimits = map { if_(/^(.*\S)(?:\s+?)(\d+)$/, $1 => $2 ) } cat_('/etc/sysconfig/partmon'); + + +my $params = join '', @ARGV; + +$params =~ /-h/ and die "usage: partmon [-v]\n"; +$params =~ /-v/ and $verbose = 1; + + +my $ok = 1; +foreach (cat_('/etc/fstab')) { + /^\s*#/ and next; + my (undef, $mountpoint, undef, undef, undef, undef) = split or next; #- I want at least 6 fields to consider it a valid entry + member($mountpoint, keys %partlimits) or next; + my $free = free_space($mountpoint); + $verbose and print "Free space of <$mountpoint> is <$free>\n"; + if ($free < $partlimits{$mountpoint}) { + print "Warning, free space for <$mountpoint> is only <", free_space($mountpoint), "> (which is inferior to <$partlimits{$mountpoint}>\n"; + $ok = 0; + } +} + +$ok or exit -1; + + +#------------------------------------------------- +#- $Log$ +#- Revision 1.3 2006/05/11 12:45:38 tvignaud +#- more s/Mandrakesoft/mandriva/ +#- +#- Revision 1.2 2002/01/15 13:45:24 chmouel +#- Fix warnings. +#- +#- Revision 1.1 2002/01/15 13:44:15 chmouel +#- Add partition monitor from GC +#- diff --git a/mandriva/partmon/partmon.sysconfig b/mandriva/partmon/partmon.sysconfig new file mode 100644 index 00000000..622e4492 --- /dev/null +++ b/mandriva/partmon/partmon.sysconfig @@ -0,0 +1,5 @@ +/ 20000 +/tmp 20000 +/usr 50000 +/var 50000 +/boot 5000 -- cgit v1.2.1