summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorHolger Levsen <holger@layer-acht.org>2012-12-10 14:47:06 +0100
committerHolger Levsen <holger@layer-acht.org>2012-12-10 14:47:06 +0100
commit4f63fe71687cf49a9204370f59ad16b3d6f369a9 (patch)
treebb4fc0f7d1dca62c6cfff444a6dfcfffc0900673 /bin
parent3d1b9640710f6b10feaa89ce95d4c9527030daef (diff)
downloadjenkins.debian.net-4f63fe71687cf49a9204370f59ad16b3d6f369a9.tar.xz
refactor housekeeping.sh, update README and TODO
Diffstat (limited to 'bin')
-rwxr-xr-xbin/housekeeping.sh74
1 files changed, 49 insertions, 25 deletions
diff --git a/bin/housekeeping.sh b/bin/housekeeping.sh
index 3af8ee7b..9e0534d3 100755
--- a/bin/housekeeping.sh
+++ b/bin/housekeeping.sh
@@ -1,5 +1,4 @@
#/bin/bash
-# FIXME: make this a general and a specific housekeeping job:
# Copyright 2012 Holger Levsen <holger@layer-acht.org>
# released under the GPLv=2
@@ -8,38 +7,63 @@
# default settings
#
export LC_ALL=C
+set -e
-echo
-uptime
+check_for_mounted_chroots() {
+ CHROOT_PATTERN="/chroots/$1-*"
+ OUTPUT=$(ls $CHROOT_PATTERN 2>/dev/null)
+ if [ "$OUTPUT" != "" ] ; then
+ figlet "Warning:"
+ echo
+ echo "Probably manual cleanup needed:"
+ echo
+ echo "$ ls -la $CHROOT_PATTERN"
+ # List the processes using the partition
+ echo
+ fuser -mv $CHROOT_TARGET
+ echo $OUTPUT
+ exit 1
+ fi
+}
-echo
-df -h
-
-echo
-for DIR in /var/cache/apt/archives/ /var/spool/squid/ /var/cache/pbuilder/build/ /var/lib/jenkins/jobs/ ; do
- sudo du -sh $DIR 2>/dev/null
-done
-
-echo
-vnstat
+report_disk_usage() {
+ du -schx /var/lib/jenkins/jobs/$1_* |grep total |sed -s "s#total#$1 jobs#"
+ # FIXME: if $2 is given check, that disk usage is below $2 GB
+}
+general_housekeeping() {
+ echo
+ uptime
-CHROOT_PATTERN="/chroots/chroot-installation-*"
-HOUSE=$(ls $CHROOT_PATTERN 2>/dev/null)
-if [ "$HOUSE" != "" ] ; then
- figlet "Warning:"
echo
- echo "Probably manual cleanup needed:"
+ df -h
+
echo
- echo "$ ls -la $CHROOT_PATTERN"
- # List the processes using the partition
+ for DIR in /var/cache/apt/archives/ /var/spool/squid/ /var/cache/pbuilder/build/ /var/lib/jenkins/jobs/ ; do
+ sudo du -shx $DIR 2>/dev/null
+ done
+ JOB_PREFIXES=$(ls -1 /var/lib/jenkins/jobs/|cut -d "_" -f1|sort -f -u)
+ for PREFIX in $JOB_PREFIXES ; do
+ report_disk_usage $PREFIX
+ done
+
echo
- fuser -mv $CHROOT_TARGET
- echo $HOUSE
- exit 1
-fi
+ vnstat
+
+ df |grep tmpfs > /dev/null || ( echo ; echo "Warning: no tmpfs mounts in use. Please investigate the host system." ; exit 1 )
+}
-df |grep tmpfs > /dev/null || ( echo "Warning: no tmpfs mounts in use. Please investigate the host system." ; exit 1 )
+#
+# if $1 is set, we do housekeeping for a group of jobs, else general
+#
+if [ -n $1 ] ; then
+ report_disk_usage $1
+ if [ "$1" = "chroot-installation" ] ; then
+ check_for_mounted_chroots $1
+ fi
+else
+ general_housekeeping
+fi
echo
echo "No problems found, all seems good."