Add tsp/watchers/watch_processes.sh 42/181842/1
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Fri, 20 Oct 2017 13:51:37 +0000 (15:51 +0200)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Wed, 25 Oct 2017 16:47:42 +0000 (18:47 +0200)
Change-Id: Ia27b04af3513906bb84fe3df721c551c817ed080

tsp/cronfile.example
tsp/watchers/watch_processes.sh [new file with mode: 0755]

index 3706888..aff3c11 100644 (file)
@@ -4,4 +4,5 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 0 * * * * /opt/testlab-major/tsp/watchers/watch_sdb.sh
 */10 * * * * /opt/testlab-major/tsp/watchers/watch_usb.sh
 */2 * * * * /opt/testlab-major/tsp/watchers/watch_target_queues.sh
+*/2 * * * * /opt/testlab-major/tsp/watchers/watch_processes.sh
 0 */8 * * * /opt/testlab-major/tsp/watchers/watch_symlinks.sh
diff --git a/tsp/watchers/watch_processes.sh b/tsp/watchers/watch_processes.sh
new file mode 100755 (executable)
index 0000000..7e0c506
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# Copyright (c) 2017 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"
+
+EXEC_NAME="exec_count"
+EXEC="$(mktemp)"
+{
+    echo "# HELP $EXEC_NAME Number of processes present in the system"
+    echo "# TYPE $EXEC_NAME gauge"
+} > "$EXEC"
+
+for cmd in "tsp" "wget" "sh" "python" "watcher" "dd"
+do
+    COUNT="$(ps -C "${cmd}" | wc -l)"
+    echo "${EXEC_NAME}{target=\"${cmd}\"} $((COUNT-1))" >> "$EXEC"
+done
+
+chmod 644 "$EXEC"
+mv "$EXEC" "$PROM_DIR/exec_count.prom"