summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2011-09-02 12:27:07 -0500
committerJohn Southworth <john.southworth@vyatta.com>2011-10-27 17:11:28 -0500
commit12b09b2a196a00389d4e1b1996fcf29689141920 (patch)
tree912da53f472d43176641cde17f4db688d18a86f7
parent7106043d374852bd104d0a4e41a0d23562533731 (diff)
downloadvyatta-op-12b09b2a196a00389d4e1b1996fcf29689141920.tar.gz
vyatta-op-12b09b2a196a00389d4e1b1996fcf29689141920.zip
Initial monitor vpn implementation. Other montior commands will be build on these scripts
(cherry picked from commit 334a6fab05b5e51097010b1da41fca32df7b8959)
-rw-r--r--Makefile.am3
-rwxr-xr-xscripts/vyatta-monitor7
-rwxr-xr-xscripts/vyatta-monitor-background19
-rwxr-xr-xscripts/vyatta-monitor-background-stop13
-rw-r--r--templates/monitor/vpn/all/node.def3
-rw-r--r--templates/monitor/vpn/background/list/node.def7
-rw-r--r--templates/monitor/vpn/background/node.def1
-rw-r--r--templates/monitor/vpn/background/start/all/node.def3
-rw-r--r--templates/monitor/vpn/background/start/ipsec/node.def2
-rw-r--r--templates/monitor/vpn/background/start/l2tp/node.def2
-rw-r--r--templates/monitor/vpn/background/start/node.def1
-rw-r--r--templates/monitor/vpn/background/start/pptp/node.def2
-rw-r--r--templates/monitor/vpn/background/stop/all/node.def3
-rw-r--r--templates/monitor/vpn/background/stop/ipsec/node.def2
-rw-r--r--templates/monitor/vpn/background/stop/l2tp/node.def2
-rw-r--r--templates/monitor/vpn/background/stop/node.def1
-rw-r--r--templates/monitor/vpn/background/stop/pptp/node.def2
-rw-r--r--templates/monitor/vpn/ipsec/node.def2
-rw-r--r--templates/monitor/vpn/l2tp/node.def2
-rw-r--r--templates/monitor/vpn/node.def1
-rw-r--r--templates/monitor/vpn/pptp/node.def2
21 files changed, 80 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 6ad0386..8999c97 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,6 +41,9 @@ bin_SCRIPTS += scripts/tech-support-archive
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-background
+bin_SCRIPTS += scripts/vyatta-monitor-background-stop
sbin_SCRIPTS = scripts/dhcpv6-client-show-leases.pl
sbin_SCRIPTS += scripts/vyatta-image-tools.pl
diff --git a/scripts/vyatta-monitor b/scripts/vyatta-monitor
new file mode 100755
index 0000000..22867e8
--- /dev/null
+++ b/scripts/vyatta-monitor
@@ -0,0 +1,7 @@
+#!/bin/bash
+declare awkmatch="$2"
+for i in "${@:3}"; do
+ awkmatch+="|$i"
+done
+tail -f /var/log/messages \
+ | awk "/$awkmatch/{ \$5=\" $1:\"; for (f=5; f<=NF; ++f) {printf(\"%s \", \$f);}; printf(\"\n\") }"
diff --git a/scripts/vyatta-monitor-background b/scripts/vyatta-monitor-background
new file mode 100755
index 0000000..fc6c19c
--- /dev/null
+++ b/scripts/vyatta-monitor-background
@@ -0,0 +1,19 @@
+#!/bin/bash
+declare awkmatch="$2"
+declare pidname="$1"
+for i in "${@:3}"; do
+ awkmatch+="|$i"
+done
+pidfile="/var/run/vyatta/monitor/$pidname-`tty| sed -e s-/--g -e s/dev//g`.pid"
+if [ -f $pidfile ]; then
+ pid=$(cat $pidfile)
+ processname=$(cat /proc/$pid/cmdline 2>/dev/null)
+ if [[ $processname =~ "tail" ]];then
+ echo -ne "\n You are already monitoring this service\n\n"
+ exit 0
+ fi
+fi
+{ ( tail -f -n0 /var/log/messages & echo $! >&3) 3> \
+ $pidfile \
+ | awk "/$awkmatch/{ \$5=\" $1:\"; for (f=5; f<=NF; ++f) {printf(\"%s \", \$f);}; printf(\"\n\") }" 2>&3 & \
+} 3>&2 2>/dev/null; disown
diff --git a/scripts/vyatta-monitor-background-stop b/scripts/vyatta-monitor-background-stop
new file mode 100755
index 0000000..c10528f
--- /dev/null
+++ b/scripts/vyatta-monitor-background-stop
@@ -0,0 +1,13 @@
+#!/bin/bash
+declare pidname="$1"
+pidfile="/var/run/vyatta/monitor/$pidname-`tty| sed -e s-/--g -e s/dev//g`.pid"
+if [ -f $pidfile ]; then
+ pid=$(cat $pidfile)
+ processname=$(cat /proc/$pid/cmdline 2>/dev/null)
+ if [[ $processname =~ "tail" ]];then
+ kill -9 $pid
+ rm -f $pidfile
+ exit 0
+ fi
+fi
+echo -ne "\n You are not currently monitoring this service\n\n"
diff --git a/templates/monitor/vpn/all/node.def b/templates/monitor/vpn/all/node.def
new file mode 100644
index 0000000..c06a666
--- /dev/null
+++ b/templates/monitor/vpn/all/node.def
@@ -0,0 +1,3 @@
+help: Monitor VPN
+run: ${vyatta_bindir}/vyatta-monitor 'VPN-ALL' pluto pptp l2tp ppp
+
diff --git a/templates/monitor/vpn/background/list/node.def b/templates/monitor/vpn/background/list/node.def
new file mode 100644
index 0000000..2fe1507
--- /dev/null
+++ b/templates/monitor/vpn/background/list/node.def
@@ -0,0 +1,7 @@
+help: List currently running VPN background montioring processes
+run: ARR=$(ls /var/run/vyatta/monitor/VPN*"$(tty| sed -e s-/--g -e s/dev//g)"*.pid)
+ ARR=${ARR[@]##*/}
+ ARR=${ARR[@]%%-pts*}
+ for i in "${ARR[@]}";do
+ echo $i
+ done
diff --git a/templates/monitor/vpn/background/node.def b/templates/monitor/vpn/background/node.def
new file mode 100644
index 0000000..7fbfd18
--- /dev/null
+++ b/templates/monitor/vpn/background/node.def
@@ -0,0 +1 @@
+help: Montior VPN in the background
diff --git a/templates/monitor/vpn/background/start/all/node.def b/templates/monitor/vpn/background/start/all/node.def
new file mode 100644
index 0000000..ac100e8
--- /dev/null
+++ b/templates/monitor/vpn/background/start/all/node.def
@@ -0,0 +1,3 @@
+help: Start background VPN monitoring
+run: ${vyatta_bindir}/vyatta-monitor-background "VPN-ALL" pluto pptp l2tp ppp
+
diff --git a/templates/monitor/vpn/background/start/ipsec/node.def b/templates/monitor/vpn/background/start/ipsec/node.def
new file mode 100644
index 0000000..7ba2631
--- /dev/null
+++ b/templates/monitor/vpn/background/start/ipsec/node.def
@@ -0,0 +1,2 @@
+help: Start background monitoring for IPSec VPN
+run: ${vyatta_bindir}/vyatta-monitor-background "VPN-IPSEC" pluto
diff --git a/templates/monitor/vpn/background/start/l2tp/node.def b/templates/monitor/vpn/background/start/l2tp/node.def
new file mode 100644
index 0000000..a43440e
--- /dev/null
+++ b/templates/monitor/vpn/background/start/l2tp/node.def
@@ -0,0 +1,2 @@
+help: Start background monitoring for L2TP VPN
+run: ${vyatta_bindir}/vyatta-monitor-background "VPN-L2TP:" l2tp ppp remote-access-aaa-win remote-access-zzz-mac
diff --git a/templates/monitor/vpn/background/start/node.def b/templates/monitor/vpn/background/start/node.def
new file mode 100644
index 0000000..dc17ca0
--- /dev/null
+++ b/templates/monitor/vpn/background/start/node.def
@@ -0,0 +1 @@
+help: Start VPN background monitoring
diff --git a/templates/monitor/vpn/background/start/pptp/node.def b/templates/monitor/vpn/background/start/pptp/node.def
new file mode 100644
index 0000000..7659282
--- /dev/null
+++ b/templates/monitor/vpn/background/start/pptp/node.def
@@ -0,0 +1,2 @@
+help: Start background monitoring for PPTP VPN
+run: ${vyatta_bindir}/vyatta-monitor-background "VPN-PPTP" pptp ppp
diff --git a/templates/monitor/vpn/background/stop/all/node.def b/templates/monitor/vpn/background/stop/all/node.def
new file mode 100644
index 0000000..8d735cd
--- /dev/null
+++ b/templates/monitor/vpn/background/stop/all/node.def
@@ -0,0 +1,3 @@
+help: Start background VPN monitoring
+run: ${vyatta_bindir}/vyatta-monitor-background-stop "VPN-ALL"
+
diff --git a/templates/monitor/vpn/background/stop/ipsec/node.def b/templates/monitor/vpn/background/stop/ipsec/node.def
new file mode 100644
index 0000000..d6ea71c
--- /dev/null
+++ b/templates/monitor/vpn/background/stop/ipsec/node.def
@@ -0,0 +1,2 @@
+help: Stop background monitoring for IPSec VPN
+run: ${vyatta_bindir}/vyatta-monitor-background-stop "VPN-IPSEC" pluto
diff --git a/templates/monitor/vpn/background/stop/l2tp/node.def b/templates/monitor/vpn/background/stop/l2tp/node.def
new file mode 100644
index 0000000..2173baf
--- /dev/null
+++ b/templates/monitor/vpn/background/stop/l2tp/node.def
@@ -0,0 +1,2 @@
+help: Stop background monitoring for L2TP VPN
+run: ${vyatta_bindir}/vyatta-monitor-background-stop "VPN-L2TP:" l2tp ppp remote-access-aaa-win remote-access-zzz-mac
diff --git a/templates/monitor/vpn/background/stop/node.def b/templates/monitor/vpn/background/stop/node.def
new file mode 100644
index 0000000..e0b76b2
--- /dev/null
+++ b/templates/monitor/vpn/background/stop/node.def
@@ -0,0 +1 @@
+help: Stop VPN background monitoring
diff --git a/templates/monitor/vpn/background/stop/pptp/node.def b/templates/monitor/vpn/background/stop/pptp/node.def
new file mode 100644
index 0000000..d1879e4
--- /dev/null
+++ b/templates/monitor/vpn/background/stop/pptp/node.def
@@ -0,0 +1,2 @@
+help: Stop background monitoring for PPTP VPN
+run: ${vyatta_bindir}/vyatta-monitor-background-stop "VPN-PPTP" pptp ppp
diff --git a/templates/monitor/vpn/ipsec/node.def b/templates/monitor/vpn/ipsec/node.def
new file mode 100644
index 0000000..b44f8bc
--- /dev/null
+++ b/templates/monitor/vpn/ipsec/node.def
@@ -0,0 +1,2 @@
+help: Monitor IPSec VPN
+run: ${vyatta_bindir}/vyatta-monitor "VPN-IPSEC" pluto pptp l2tp ppp
diff --git a/templates/monitor/vpn/l2tp/node.def b/templates/monitor/vpn/l2tp/node.def
new file mode 100644
index 0000000..2ede83c
--- /dev/null
+++ b/templates/monitor/vpn/l2tp/node.def
@@ -0,0 +1,2 @@
+help: Monitor L2TP VPN
+run: ${vyatta_bindir}/vyatta-monitor "VPN-L2TP" l2tp ppp remote-access-aaa-win remote-access-zzz-mac
diff --git a/templates/monitor/vpn/node.def b/templates/monitor/vpn/node.def
new file mode 100644
index 0000000..671edea
--- /dev/null
+++ b/templates/monitor/vpn/node.def
@@ -0,0 +1 @@
+help: Monitor VPN
diff --git a/templates/monitor/vpn/pptp/node.def b/templates/monitor/vpn/pptp/node.def
new file mode 100644
index 0000000..c8eb043
--- /dev/null
+++ b/templates/monitor/vpn/pptp/node.def
@@ -0,0 +1,2 @@
+help: Monitor PPTP VPN
+run: ${vyatta_bindir}/vyatta-monitor "VPN-PPTP" pptp ppp