summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Mistewicz <a.mistewicz@samsung.com>2017-10-20 13:51:37 (GMT)
committerAleksander Mistewicz <a.mistewicz@samsung.com>2017-10-25 16:47:42 (GMT)
commit4c5ef1c47ab5783ba43e5f51019025df70ce9fbc (patch)
treed18a1d62fad2545ebb5c91e0446015e7af0fcb95
parent887e0082ab2afe570d7c8ff8d958c04d3e855da1 (diff)
downloadmajor-4c5ef1c47ab5783ba43e5f51019025df70ce9fbc.zip
major-4c5ef1c47ab5783ba43e5f51019025df70ce9fbc.tar.gz
major-4c5ef1c47ab5783ba43e5f51019025df70ce9fbc.tar.bz2
Add tsp/watchers/watch_processes.shrefs/changes/42/181842/1
Change-Id: Ia27b04af3513906bb84fe3df721c551c817ed080
-rw-r--r--tsp/cronfile.example1
-rwxr-xr-xtsp/watchers/watch_processes.sh36
2 files changed, 37 insertions, 0 deletions
diff --git a/tsp/cronfile.example b/tsp/cronfile.example
index 3706888..aff3c11 100644
--- a/tsp/cronfile.example
+++ b/tsp/cronfile.example
@@ -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
index 0000000..7e0c506
--- /dev/null
+++ b/tsp/watchers/watch_processes.sh
@@ -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"