Erste Version meines Nagios-Scripts zur Überprüfung unserer M- und V-Ginas
Im Grunde lesen die Scripts den Status über die zur Verfügung gestellte SOAP-Schnittstelle direkt von der Gina ab und schreiben das Ergebnis in eine File. Aus dieser File werden dann nur die XML-Teile herausgenommen und in eine extrige XML-File geschrieben. Diese XML-Datei wird dann auch in einem PHP-File verwendet für eine schnelle Übersicht der Ginas – zum Bsp. eingebunden in einem Dokumentationssystem/Wiki. Der Timeout für die Abfrage muss relativ hoch gesetzt werden, da diese sehr lange dauern kann.
Die möglichen Services/Status können je nach Update der Ginas angepasst werden.
check_ecard_mgina.sh
#!/bin/sh # This script checks the status of the E-Card Services # call example: check_ecard_mgina.sh 10.200.200.1 # # Besides it saves the XML into a file in /var/www/ecard-ginas # There the index.php reads needed info for easier administration . /usr/local/nagios/libexec/utils.sh # read given IP-address IP=$1 # possible services SERVICES=("Konsultationsverwaltung (KONV)" "Arzneimittelbewilligungsservice (ABS)" "SV-Nummer abfragen (SAS)" "Therapie Aktiv Verwaltung (TAV)" "Arbeits (un)/faehigkeitsmeldung (AUM))" "Ueber-/Zu-/Einweisung (UZE)" "Dokumentationsblattannahmeservice(DBAS)" "Security Token Service (STS)" "Datenabfrageservice (DAS)" "SW-Verteilung") # define the status of the different services - first look at the read XML POSSIBLE_STATUS_CHECKS=("online" "online" "online" "online" "online" "online" "online" "online" "online" "online") # get the array size of POSSIBLE_STATUS_CHECKS PSC_ARRAY_SIZE=${#POSSIBLE_STATUS_CHECKS[*]} # use check_http in verbose mode to write the output into a temporary file to /tmp --- check_http timeout is set really high (20 seconds) because the box is often not answering fast enough /usr/local/icinga/libexec/check_http -I $IP -t 20 -u /axis/services/soap_base_8.0 -P '' -k 'SOAPAction: getGinaAndServiceavailabilityInformation' -v > /tmp/tmp_ecard_check_$IP # take only the XML part of this file and save it into a file in /var/www/ecard-ginas grep "online" /tmp/tmp_ecard_check_$IP > /var/www/ecard-ginas/xml_$IP.xml # get the status for each service and save it into the ECHOSTATE variable i=0 while [ $i -ne $PSC_ARRAY_SIZE ]; do GREP_CHECK=`grep "${POSSIBLE_STATUS_CHECKS[$i]}" /tmp/tmp_ecard_check_$IP` #echo $GREP_CHECK if [ "$GREP_CHECK" != "" ];then #echo ${SERVICES[$i]} OK ECHOSTATE=$ECHOSTATE"\n${SERVICES[$i]} ------- OK" else #echo ${SERVICES[$i]} NOT OK ECHOSTATE=$ECHOSTATE"\n${SERVICES[$i]} ------- NOT OK" fi i=$(( $i + 1 )) done # grep if there is a "NOT OK" in ECHOSTATE EXIT_STATE=`echo "$ECHOSTATE" | grep "NOT OK"` # if there is a "NOT OK" exit with CRITICAL status - else everything is OK if [ "$EXIT_STATE" != "" ];then ECHOSTATE="PLEASE CLICK ON THE SERVICE TO SEE FURTHER DETAILS!!!\n"$ECHOSTATE echo -e $ECHOSTATE exit $STATE_CRITICAL else ECHOSTATE="ALL SERVICES -- OK\n"$ECHOSTATE echo -e $ECHOSTATE exit $STATE_OK fi
check_ecard_vgina.sh
#!/bin/sh # This script checks the status of the E-Card Services # call example: check_ecard_vgina.sh 10.200.200.5 # # Besides it saves the XML into a file in /var/www/ecard-ginas # There the index.php reads needed info for easier administration . /usr/local/nagios/libexec/utils.sh # read given IP-address IP=$1 # possible services SERVICES=("Konsultationsverwaltung (KONV)" "Arzneimittelbewilligungsservice (ABS)" "SV-Nummer abfragen (SAS)" "Versichertendaten abfragen (VDAS)" "e-Medikation (EMED)" "Therapie Aktiv Verwaltung (TAV)" "Arbeits (un)/faehigkeitsmeldung (AUM))" "Ueber-/Zu-/Einweisung (UZE)" "Dokumentationsblattannahmeservice(DBAS)" "Security Token Service (STS)" "Datenabfrageservice (DAS)" "SW-Verteilung") # define the status of the different services - first look at the read XML POSSIBLE_STATUS_CHECKS=("online" "online" "online" "online" "offline" "online" "online" "online" "online" "online" "online" "online") # get the array size of POSSIBLE_STATUS_CHECKS PSC_ARRAY_SIZE=${#POSSIBLE_STATUS_CHECKS[*]} # use check_http in verbose mode to write the output into a temporary file to /tmp /usr/local/icinga/libexec/check_http -I $IP -t 20 -u /axis/services/soap_base_8.0_ent -P '' -k 'SOAPAction: getGinaAndServiceavailabilityInformation' -v > /tmp/tmp_ecard_check_$IP # take only the XML part of this file and save it into a file in /var/www/ecard-ginas grep "online" /tmp/tmp_ecard_check_$IP > /var/www/ecard-ginas/xml_$IP.xml # get the status for each service and save it into the ECHOSTATE variable i=0 while [ $i -ne $PSC_ARRAY_SIZE ]; do GREP_CHECK=`grep "${POSSIBLE_STATUS_CHECKS[$i]}" /tmp/tmp_ecard_check_$IP` #echo $GREP_CHECK if [ "$GREP_CHECK" != "" ];then #echo ${SERVICES[$i]} OK ECHOSTATE=$ECHOSTATE"\n${SERVICES[$i]} ------- OK" else #echo ${SERVICES[$i]} NOT OK ECHOSTATE=$ECHOSTATE"\n${SERVICES[$i]} ------- NOT OK" fi i=$(( $i + 1 )) done # grep if there is a "NOT OK" in ECHOSTATE EXIT_STATE=`echo "$ECHOSTATE" | grep "NOT OK"` # if there is a "NOT OK" exit with CRITICAL status - else everything is OK if [ "$EXIT_STATE" != "" ];then ECHOSTATE="PLEASE CLICK ON THE SERVICE TO SEE FURTHER DETAILS!!!\n"$ECHOSTATE echo -e $ECHOSTATE exit $STATE_CRITICAL else ECHOSTATE="ALL SERVICES -- OK\n"$ECHOSTATE echo -e $ECHOSTATE exit $STATE_OK fi
example index.php
Update 23.11.2012
Mit Release 12b ändert sich anscheinend etwas bei der SOAP-Schnittstelle – damit das script wieder funktioniert, muss soap_base_8.0_ent durch soap_base_10.0_ent (bzw. soap_base_8.0 durch soap_base_10.0) ersetzt werden
Kommentare