Direkt zum Hauptinhalt

Endian VPN Überwachung

Beschreibung:

Ein Custom Check für ein python Script zur endian VPN überwachung.
Dieses script gibt Graphen mit Anzahl der Verbindung für jede VPN Instanzen aus.
und eine Gesamtverbindungsübersicht für alle VPN Instanzen.

Das Script:

#!/bin/bash

STRING=$(python /root/checkmk_setup/check_metrics4.py openvpn_users | grep openvpn)
IFS=' ' read -ra vpn_array <<< "$STRING"
LEN=${#vpn_array[@]}
printf "0 \"OPENVPN Users\" "
for (( i=5; i<$LEN; i++))
do
	  IFS='=' read -ra part <<< ${vpn_array[$i]}
	  printf "VPNCONF-${part[0]}=${part[1]}"
	  if [ $i -lt $(expr $LEN - 1) ]
          then
          	printf "|"
	  fi
done
printf "\n"



#echo "0 \"OpenVPN Users\" metric=10|metric1=20|metric3=40"

Es ruft

python /root/checkmk_setup/check_metrics4.py openvpn_users | grep openvpn

Ausgabe:

openvpn_users_total: 7 users (OK) | openvpn.2.conf_rvs6test_UDP_tecmata=6 openvpn.1.conf_rvs6test_TCP_tecmata=1 total_vpn_users=7

Diese Ausgabe muss dann nur noch in das Checkmk Format gebracht werden. Das macht das Script.
Die Ausgabe vom Script sieht dann so aus.
Befehl

. /usr/lib/check_mk_agent/local/vpn

Ausgabe:
0 "OPENVPN Users" VPNCONF-openvpn.2.conf_rvs6test_UDP_tecmata=6|VPNCONF-openvpn.1.conf_rvs6test_TCP_tecmata=1|VPNCONF-total_vpn_users=7

 

Überarbeitet Script mit Metriken für Schwellwerte. Der Doppelpuntk hinter einem Wert heißt darunter und nicht darüber.

#!/bin/bash
WARN=8
CRIT=1
STRING=$(python /root/checkmk_setup/check_metrics4.py openvpn_users | grep openvpn)
IFS=' ' read -ra vpn_array <<< "$STRING"
LEN=${#vpn_array[@]}
printf "P \"OPENVPN Users Metrik\" "
for (( i=5; i<$LEN; i++))
do
          IFS='=' read -ra part <<< ${vpn_array[$i]}
          printf "VPNCONF-${part[0]}=${part[1]}"
          if [ $i -lt $(expr $LEN - 1) ]
          then
              	printf "|"
          else
              	printf ";$WARN:;$CRIT:;$MIN"
          fi
done
printf "\n"



#echo "0 \"OpenVPN Users\" metric=10|metric1=20|metric3=40;8:;1:"

Installation des VPN Python Script im System

In endian RVS5

Das Script erstellen mit

nano /usr/lib/check_mk_agent/local/vpnmetrik

Das das Script rein, mit oder Ohne Metrik. Halt was gewünscht ist.
Und den Pfad zur VPn Python File anpassen.

 

 



In endian RVS6