diff options
author | John Southworth <john.southworth@vyatta.com> | 2011-09-09 19:54:09 -0500 |
---|---|---|
committer | John Southworth <john.southworth@vyatta.com> | 2011-09-09 19:54:09 -0500 |
commit | 7789cf5e792174aff5c127eb90859c46608a937b (patch) | |
tree | 5be8b2fe8a2bf6cb6e167598ccd936ca749ec716 /scripts | |
parent | 8f4406f107b6f93eb9e868018150e1f4687aef68 (diff) | |
download | vyatta-op-7789cf5e792174aff5c127eb90859c46608a937b.tar.gz vyatta-op-7789cf5e792174aff5c127eb90859c46608a937b.zip |
Add 'show monitoring' script to list active background monitoring
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/vyatta-monitor-list | 21 |
1 files changed, 21 insertions, 0 deletions
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 |