-
Notifications
You must be signed in to change notification settings - Fork 6
/
l2tp
executable file
·83 lines (55 loc) · 2.59 KB
/
l2tp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#/usr/lib/check_mk_agent/local
export LANG=de_DE.UTF-8
function confline # get first line from file $1 mathing $2, stripped of # and ; comment lines, stripped spaces and tabs down to spaces, remove trailing ;
{
echo $(cat $1|grep -v '^$\|^\s*\#'|sed -e "s/[[:space:]]\+/ /g"|sed s/^\ //|sed s/\;//|grep -i "$2"|head -n 1)
}
function conflines # get lines from file $1 mathing $2, stripped of # and ; comment lines, stripped spaces and tabs down to spaces, remove trailing ;
{
echo "$(cat $1|grep -v '^$\|^\s*\#'|sed -e "s/[[:space:]]\+/ /g"|sed s/^\ //|sed s/\;//|grep -i $2)"
}
## static data
kernel=$(uname -r);
release=$(lsb_release -ds);
## ubuntu-Status
echo "0 Ubuntu-Release Ubuntu-Release=$release; $release - Kernel $kernel"
## ubuntu patch status
osversion=$(lsb_release -a|grep Description|cut -d: -f2|xargs)
nupdates=0
supdates=0
if [[ $osversion = "Ubuntu 14.04"* ]] ; then
nupdates=$(/usr/lib/update-notifier/update-motd-updates-available|grep -i 'packages\ can\ be\ updated\|Software-Pakete'|cut -d" " -f1)
supdates=$(/usr/lib/update-notifier/update-motd-updates-available|grep -i 'updates\ are\ security\ updates\|Sicherheitsaktualisierungen'|cut -d" " -f1)
fi
if [[ $osversion = "Ubuntu 16.04"* ]] ; then
nupdates=$(cat /var/lib/update-notifier/updates-available|grep -i 'packages\ can\ be\ updated\|Software-Pakete'|cut -d" " -f1)
supdates=$(cat /var/lib/update-notifier/updates-available|grep -i 'updates\ are\ security\ updates\|Sicherheitsaktualisierungen'|cut -d" " -f1)
fi
reboot=0
if [ -x /usr/lib/update-notifier/update-motd-reboot-required ]; then
reboot=$(/usr/lib/update-notifier/update-motd-reboot-required|grep \*\*\**\*\*\*|wc -l)
fi
echo "P Ubuntu-Patchstatus SecurityUpdates-waiting=$supdates.0;0:0.9;0:2|RegularUpdates-waiting=$nupdates.0;0:10;0:15|Reboot-waiting=$reboot.0;0:0.9;0:1"
## logins
logincount=$(who|wc -l)
logout="0 LocalUser CurrentLogins=$logincount.0; CurrentLogins:$logincount"
i=0
TFILE="/tmp/$(basename $0).$$.tmp"
who -u>$TFILE
while read line; do
i=$(( i + 1))
line=$(echo $line|sed s/\ +//|tr -s " ")
user=$(echo $line|cut -d" " -f1)
tty=$(echo $line|cut -d" " -f2)
idle=$(echo $line|cut -d" " -f6)
ip=$(echo $line|cut -d" " -f8)
logout="$logout\n login-$i-user:$user login-$i-tty:$tty login-$i-idle:$idle login-$i-source:$ip"
done<$TFILE
rm $TFILE
echo "$logout"
#Get data
l_tunnel=$(ip a |grep l2tp|grep tunneldigger -c);
tunneldigger=$(ifconfig|grep tunneldigger -c);
#Output
echo "P L2TP Clients=$l_tunnel.0;1:30;0:80|Tunneldiggerbridges=$tunneldigger.0;0.1:1;0.1:2; L2TP-Clients:$l_tunnel Tunneldiggerbridges:$tunneldigger"