source: hybrid/branches/releng-9.0/nanobsd/files/usr/local/sbin/check-inet-alive@ 10481

Last change on this file since 10481 was 10481, checked in by rick, 13 years ago

Logging configs and check fixes:

  • Network Status file.
  • SNMPD syslog logging.
  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#!/bin/sh
2#
3# Internet Connection Wrapper From Cron
4#
5# a) Disable lvrouted if the internet is down.
6# b) Re-enable lvrouted if the internet is back up.
7#
8# XXX: Do we need build an fail-save for flapping states?
9# XXX: Do we need to manage state, like DHCP here?
10# XXX: Check if page output is actually the output expected and not some weird captive portal somewhere.
11# XXX: For effiently reasons this should be combined with the nagios check_inet check
12#
13# Rick van der Zwet <info@rickvanderzwet.nl>
14#
15
16TAG=`basename $0`
17INET_STATUS=down
18service lvrouted onestatus > /dev/null && LVROUTED_STATUS="running" || LVROUTED_STATUS="stopped"
19
20check_http() {
21 fetch -o /dev/null -q $* 2>/dev/null
22}
23
24# Main I-net check
25check_http http://proxy-test.wirelessleiden.nl && INET_STATUS=up
26
27if [ $INET_STATUS = "down" ]; then
28 # Failback internet check
29 check_http http://ams-ix.net && INET_STATUS=up
30fi
31
32if [ $LVROUTED_STATUS = "stopped" ] && [ $INET_STATUS = "up" ]; then
33 service lvrouted start | logger -t "$TAG"
34elif [ $LVROUTED_STATUS = "running" ] && [ $INET_STATUS = "down" ]; then
35 service lvrouted stop | logger -t "$TAG"
36fi
37
38# Retrieve proxy status
39export HTTP_PROXY=${HTTP_PROXY-:http://proxy.wleiden.net:3128}
40PROXY_STATUS=down
41check_http http://proxy-test.wirelessleiden.nl && PROXY_STATUS=down
42
43if [ $INET_STATUS = "down" ]; then
44 # Failback internet check
45 check_http http://ams-ix.net && PROXY_STATUS=up
46fi
47
48echo -e "internet=$INET_STATUS\nproxy=$PROXY_STATUS" > /tmp/network.status
Note: See TracBrowser for help on using the repository browser.