summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2011-09-09 19:54:09 -0500
committerJohn Southworth <john.southworth@vyatta.com>2011-10-27 17:11:29 -0500
commit5ffdcf0fce813c75443dad86a2537d3fe6036c66 (patch)
tree83ea798553608bb55b34abe4f16c0e7e9782b007
parent2c00e7d0ad36351ebbf2721800f28815a71b5294 (diff)
downloadvyatta-op-5ffdcf0fce813c75443dad86a2537d3fe6036c66.tar.gz
vyatta-op-5ffdcf0fce813c75443dad86a2537d3fe6036c66.zip
Add 'show monitoring' script to list active background monitoring
(cherry picked from commit 7789cf5e792174aff5c127eb90859c46608a937b)
-rw-r--r--Makefile.am1
-rw-r--r--scripts/vyatta-monitor-list21
-rw-r--r--templates/show/monitoring/node.def1
3 files changed, 23 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 9cfdfa8..f69190e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -42,6 +42,7 @@ bin_SCRIPTS += scripts/vyatta-op-cmd-wrapper
bin_SCRIPTS += scripts/vyatta-ping
bin_SCRIPTS += scripts/vyatta-traceroute
bin_SCRIPTS += scripts/vyatta-monitor
+bin_SCRIPTS += scripts/vyatta-monitor-list
bin_SCRIPTS += scripts/vyatta-monitor-cleanup
bin_SCRIPTS += scripts/vyatta-monitor-background
bin_SCRIPTS += scripts/vyatta-monitor-background-stop
diff --git a/scripts/vyatta-monitor-list b/scripts/vyatta-monitor-list
new file mode 100644
index 0000000..6862f03
--- /dev/null
+++ b/scripts/vyatta-monitor-list
@@ -0,0 +1,21 @@
+#!/bin/bash
+declare CURRENT_PTS=$(tty | sed -e s-/--g -e s/dev//g)
+declare CURRENT_UID=$(id -u)
+declare -a MPIDS
+MPIDS=( $(ls /var/run/vyatta/monitor/*.pid 2>/dev/null) )
+
+for pidfile in "${MPIDS[@]}"; do
+ pid=$(<$pidfile)
+ procname=$(cat /proc/$pid/cmdline 2>/dev/null)
+ if [[ "$procname" =~ "tail" ]] ; then
+ pts=${pidfile##*-pts}
+ pts=${pts%%.pid}
+ if [[ "pts$pts" == "$CURRENT_PTS" ]]; then
+ if cat /proc/$pid/status | grep -q "Uid:.*$CURRENT_UID" ; then
+ print=${pidfile##*/}
+ print=${print%%-pts$pts*}
+ echo $print
+ fi
+ fi
+ fi
+done
diff --git a/templates/show/monitoring/node.def b/templates/show/monitoring/node.def
index 33a9848..9c16edc 100644
--- a/templates/show/monitoring/node.def
+++ b/templates/show/monitoring/node.def
@@ -1 +1,2 @@
help: Show currently monitored services
+run: ${vyatta_bindir}/vyatta-monitor-list