summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-09-28 07:19:46 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2012-09-28 07:24:30 +0000
commit5edcfa2d670fc76bb50839832a6180c9bcd38cd3 (patch)
tree8701de0b3f3d2dc296e66dbe21e3bc2cd7e38bbf
parent8c0797b46cf2728c99d1699f25a0cbfc4cde0fb5 (diff)
downloadaports-5edcfa2d670fc76bb50839832a6180c9bcd38cd3.tar.bz2
aports-5edcfa2d670fc76bb50839832a6180c9bcd38cd3.tar.xz
main/logrotate: add support for cpulimit
If package cpulimit is installed, then apply the cpulimit specified in CPULIMIT in /etc/conf.d/logrotate This helps monitoring software to not trigger high CPU load alarms when rotating logs.
-rw-r--r--main/logrotate/APKBUILD15
-rw-r--r--main/logrotate/logrotate.confd4
-rw-r--r--main/logrotate/logrotate.cron16
3 files changed, 31 insertions, 4 deletions
diff --git a/main/logrotate/APKBUILD b/main/logrotate/APKBUILD
index 43599797d..cd73cf47c 100644
--- a/main/logrotate/APKBUILD
+++ b/main/logrotate/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=logrotate
pkgver=3.8.2
-pkgrel=0
+pkgrel=1
pkgdesc="Tool to rotate logfiles"
url="https://fedorahosted.org/logrotate/"
arch="all"
@@ -14,7 +14,9 @@ source="https://fedorahosted.org/releases/l/o/logrotate/logrotate-$pkgver.tar.gz
logrotate-3.7.9-atomic-create.patch
logrotate-3.7.9-shred.patch
logrotate-3.7.9-statefile.patch
- logrotate.conf"
+ logrotate.cron
+ logrotate.conf
+ logrotate.confd"
build() {
cd "$srcdir/$pkgname-$pkgver"
@@ -27,11 +29,16 @@ package() {
install -Dm755 logrotate "$pkgdir"/usr/sbin/logrotate
install -Dm644 logrotate.8 "$pkgdir"/usr/share/man/man8/logrotate.8
install -Dm644 ../logrotate.conf "$pkgdir"/etc/logrotate.conf
- install -Dm755 examples/logrotate.cron "$pkgdir"/etc/periodic/daily/logrotate
+ install -Dm755 "$srcdir"/logrotate.cron \
+ "$pkgdir"/etc/periodic/daily/logrotate || return 1
+ install -Dm644 "$srcdir"/logrotate.confd \
+ "$pkgdir"/etc/conf.d/logrotate
}
md5sums="ddd4dcf28c38b3ac6bc6ff4e0148308a logrotate-3.8.2.tar.gz
0273f868dc4208eed0a442759d86e77c logrotate-3.7.9-atomic-create.patch
74216579397b03c44d1d85dd233306d8 logrotate-3.7.9-shred.patch
82ebd23da8a7f0650a4c80577dbdc739 logrotate-3.7.9-statefile.patch
-fef6415a79a6fede8cf9b9b6b8410090 logrotate.conf"
+7e9fad2c9b382a2370c11ef0c89f61c7 logrotate.cron
+fef6415a79a6fede8cf9b9b6b8410090 logrotate.conf
+e7e4b67d5c4bda49ff3c041834180c1e logrotate.confd"
diff --git a/main/logrotate/logrotate.confd b/main/logrotate/logrotate.confd
new file mode 100644
index 000000000..4bdd72700
--- /dev/null
+++ b/main/logrotate/logrotate.confd
@@ -0,0 +1,4 @@
+# Limit cpu usage so monitoring software does not trigger CPU alarms
+# This will only be used if package "cpulimit" is installed
+CPULIMIT=50
+
diff --git a/main/logrotate/logrotate.cron b/main/logrotate/logrotate.cron
new file mode 100644
index 000000000..ad7b3da1a
--- /dev/null
+++ b/main/logrotate/logrotate.cron
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+if [ -f /etc/conf.d/logrotate ]; then
+ . /etc/conf.d/logrotate
+fi
+
+if [ -x /usr/bin/cpulimit ] && [ -n "$CPULIMIT" ]; then
+ _cpulimit="/usr/bin/cpulimit --limit=$CPULIMIT"
+fi
+
+$_cpulimit /usr/sbin/logrotate /etc/logrotate.conf
+EXITVALUE=$?
+if [ $EXITVALUE != 0 ]; then
+ /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
+fi
+exit 0