check_bird6_sessions 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. #
  3. #exitcodes
  4. #OK=0
  5. #WARNING=1
  6. #CRITICAL=2
  7. #########################################################################
  8. # Ausgabe von birdc show proto überprüfen, ob OSPF „running“ und alle bgp „established“ sind
  9. #########################################################################
  10. BGPSTATUSLIST=$(birdc6 show proto | grep BGP | sed -e 's/.* BGP .*[0-9][0-9]* *//g')
  11. if [ $? -gt 0 ] ; then
  12. echo "CRITICAL: 'birdc show proto' exits with errorcode"
  13. exit 2
  14. fi
  15. BGPCOUNTESTABLISHED=$(echo "$BGPSTATUSLIST" | grep Established | wc -l)
  16. BGPCOUNTNOTESTABLISHED=$(echo "$BGPSTATUSLIST" | grep -v Established | wc -l)
  17. OSPFSTATUSLIST=$(birdc show proto | grep OSPF | sed -e 's/.* OSPF .*[0-9][0-9]* *//g')
  18. OSPFCOUNTRUNNING=$(echo "$OSPFSTATUSLIST" | grep Running | wc -l)
  19. OSPFCOUNTNOTRUNNING=$(echo "$OSPFSTATUSLIST" | grep -v Running | wc -l)
  20. #echo $BGPCOUNTESTABLISHED
  21. #echo $BGPCOUNTNOTESTABLISHED
  22. #echo OSPFRUN $OSPFCOUNTRUNNING
  23. #echo OSPFNOT $OSPFCOUNTNOTRUNNING
  24. if [ $BGPCOUNTNOTESTABLISHED -gt 0 ] || [ $OSPFCOUNTNOTRUNNING -gt 0 ]; then
  25. echo "CRITICAL: BGP not Established:$BGPCOUNTNOTESTABLISHED; OSPF not Running:$OSPFCOUNTNOTRUNNING"
  26. exit 2
  27. else
  28. echo "OK: BGP Established: $BGPCOUNTESTABLISHED; OSPF running:$OSPFCOUNTRUNNING"
  29. exit 0
  30. fi