Add tsp/jobs/watch_diskspace.sh 21/69721/13
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Fri, 6 May 2016 09:29:57 +0000 (11:29 +0200)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Mon, 4 Jul 2016 12:36:04 +0000 (14:36 +0200)
Change-Id: Ifeaf25b5a4b06ef7ee19704ac42c682fb4fe96a3
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
tsp/cronfile.example
tsp/jobs/watch_diskspace.sh [new file with mode: 0755]

index 91a0371..e0234f7 100644 (file)
@@ -1 +1,2 @@
 */5 * * * * /opt/testlab-major/tsp/jobs/prerelease_watcher.sh
+0 2 * * * /opt/testlab-major/tsp/jobs/watch_diskspace.sh
diff --git a/tsp/jobs/watch_diskspace.sh b/tsp/jobs/watch_diskspace.sh
new file mode 100755 (executable)
index 0000000..296015e
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
+
+export TSP_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)/.."
+
+. "${TSP_DIR}/common.sh"
+
+# Assume workspaces are stored on root partition.
+# Get diskspace usage for root mountpoint.
+PER=`df -Ph | grep -o "[0-9][0-9]%.*/$"`
+# Leave only numerical value.
+PER=${PER%\%*}
+if [ "$PER" -ge 70 ]
+then
+    nr=$(tsmaster -L DISK_CLEANUP sh "${TSP_DIR}/scripts/free_diskspace.sh")
+    # make the above job urgent
+    tsmaster -u "$nr"
+fi