Changeset 10829 in hybrid for branches/releng-9.0


Ignore:
Timestamp:
May 13, 2012, 2:08:23 PM (13 years ago)
Author:
rick
Message:

Control the right daemons with the right function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/releng-9.0/nanobsd/files/tools/check-inet-alive

    r10720 r10829  
    1111# XXX: For effiently reasons this should be combined with the nagios check_inet check
    1212#
    13 # Rick van der Zwet <info@rickvanderzwet.nl>
     13# Rick van der Zwet <rick@wirelessleiden.nl>
    1414#
    1515
     
    2121# Check if we need to check inet at all
    2222. /etc/rc.subr
     23
    2324load_rc_config "lvrouted"
    2425load_rc_config "tinyproxy"
     26
    2527: ${lvouted_enable="NO"}
    2628: ${tinyproxy_enable="NO"}
     
    2830: ${service_proxy="NO"}
    2931
    30 control_lvrouted="yes"
    31 control_tinyproxy="yes"
    32 (( checkyesno service_ileiden || checkyesno service_proxy ) && checkyesno lvouted_enable ) || control_lvrouted="no"
    33 (( checkyesno service_ileiden || checkyesno service_proxy ) && checkyesno tinyproxy_enable ) || control_tinyproxy="no"
     32control_lvrouted=false
     33control_tinyproxy=false
     34checkyesno service_proxy_ileiden && checkyesno lvouted_enable control_lvrouted=true
     35checkyesno service_proxy_normal && checkyesno tinyproxy_enable || control_tinyproxy=false
    3436
    3537
    36 service lvrouted onestatus > /dev/null && LVROUTED_STATUS="running" || LVROUTED_STATUS="stopped"
    37 service tinyproxy onestatus > /dev/null && TINYPROXY_STATUS="running" || TINYPROXY_STATUS="stopped"
     38# Get current state of the daemons
     39lvouted_status="stopped"
     40tinyproxy_status="stopped"
     41service lvrouted onestatus > /dev/null && lvouted_status="running"
     42service tinyproxy onestatus > /dev/null && tinyproxy_status="running"
    3843
    3944check_http() {
     
    4146}
    4247
    43 # Get connection stats for internet
    44 INET_STATUS=up && check_http http://proxy-test.wirelessleiden.nl || check_http http://ams-ix.net || INET_STATUS=down
    45 # Connections statistics for proxy
     48# Get connection stats for internet direct and via proxy
     49inet_status=up
     50proxy_status=up
     51check_http http://proxy-test.wirelessleiden.nl || check_http http://ams-ix.net || inet_status=down
    4652export HTTP_PROXY=${HTTP_PROXY-:http://proxy.wleiden.net:3128}
    47 PROXY_STATUS=up && check_http http://tinyproxy.stats || check_http http://ams-ix.net || PROXY_STATUS=down
     53check_http http://tinyproxy.stats || check_http http://ams-ix.net || proxy_status=down
    4854
    4955# Log Network Status
    5056cat <<EOF > /tmp/network.status
    51 internet=$INET_STATUS
    52 proxy=$PROXY_STATUS
     57internet=$inet_status
     58proxy=$proxy_status
    5359EOF
    5460
    5561# Control connections
    56 if checkyesno control_lvrouted; then
    57   if [ $LVROUTED_STATUS = "stopped" ] && [ $INET_STATUS = "up" ]; then
     62if $control_lvrouted; then
     63  if [ $lvrouted_status = "stopped" ] && [ $inet_status = "up" ]; then
    5864    service lvrouted start | logit
    59   elif [ $LVROUTED_STATUS = "running" ] && [ $INET_STATUS = "down" ]; then
     65  elif [ $lvrouted_status = "running" ] && [ $inet_status = "down" ]; then
    6066    service lvrouted stop | logit
    6167  fi
    6268fi
    6369
    64 if checkyesno control_tinyproxy; then
    65   if [ $TINYPROXY_STATUS_STATUS = "stopped" ] && [ $INET_STATUS = "up" ]; then
     70if $control_tinyproxy; then
     71  if [ $tinyproxy_status = "stopped" ] && [ $inet_status = "up" ]; then
    6672    service tinyproxy start | logit
    67   elif [ $TINYPROXY_STATUS = "running" ] && [ $INET_STATUS = "down" ]; then
     73  elif [ $tinyproxy_status = "running" ] && [ $inet_status = "down" ]; then
    6874    service tinyproxy stop | logit
    6975  fi
Note: See TracChangeset for help on using the changeset viewer.