Added named Check and Supernode Status
This commit is contained in:
parent
dca98d3645
commit
8ea4fc5086
@ -1,10 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
/usr/local/sbin/batctl gw off
|
|
||||||
/usr/sbin/service bird6 stop
|
|
||||||
/usr/sbin/service bird stop
|
|
||||||
/usr/sbin/service tunneldigger stop
|
|
||||||
/usr/sbin/service radvd stop
|
|
||||||
/usr/sbin/service isc-dhcp-server stop
|
|
||||||
while [ true ] ; do
|
while [ true ] ; do
|
||||||
online=$(/bin/cat /etc/supernode-status/supernode.status)
|
online=$(/bin/cat /etc/supernode-status/supernode.status)
|
||||||
mode=$(/bin/cat /etc/supernode-status/supernode.mode)
|
mode=$(/bin/cat /etc/supernode-status/supernode.mode)
|
||||||
@ -15,9 +9,25 @@ while [ true ] ; do
|
|||||||
# Names of the 2 Supernodes #
|
# Names of the 2 Supernodes #
|
||||||
SN1=troisdorf5
|
SN1=troisdorf5
|
||||||
SN2=troisdorf6
|
SN2=troisdorf6
|
||||||
active_SN=$(/bin/hostname)
|
|
||||||
# Turn loadbalance on/off #
|
|
||||||
loadbalance=$(cat /etc/supernode-status/loadbalancing.mode)
|
loadbalance=$(cat /etc/supernode-status/loadbalancing.mode)
|
||||||
|
if [ $iam = "troisdorf5" ]; then
|
||||||
|
my_SN_IP=185.66.193.105
|
||||||
|
other_SN_IP=185.66.193.106
|
||||||
|
meship=10.188.255.5
|
||||||
|
else
|
||||||
|
my_SN_IP=185.66.193.106
|
||||||
|
other_SN_IP=185.66.193.105
|
||||||
|
meship=10.188.255.6
|
||||||
|
fi
|
||||||
|
if [ $loadbalance = "1" ] && [ $mode != "0" ]; then
|
||||||
|
if [ $day -gt 15 ]; then
|
||||||
|
active_SN=$SN1
|
||||||
|
else
|
||||||
|
active_SN=$SN2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# functions #
|
# functions #
|
||||||
# Supernode off #
|
# Supernode off #
|
||||||
@ -33,7 +43,7 @@ while [ true ] ; do
|
|||||||
else
|
else
|
||||||
echo 0 > /etc/supernode-status/supernode.status
|
echo 0 > /etc/supernode-status/supernode.status
|
||||||
fi
|
fi
|
||||||
echo "collectd.gateways.{{ sn_hostname }}.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo "collectd.gateways.$iam.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
}
|
}
|
||||||
# Supernode on #
|
# Supernode on #
|
||||||
supernode_on () {
|
supernode_on () {
|
||||||
@ -48,7 +58,7 @@ while [ true ] ; do
|
|||||||
else
|
else
|
||||||
echo 2 > /etc/supernode-status/supernode.status
|
echo 2 > /etc/supernode-status/supernode.status
|
||||||
fi
|
fi
|
||||||
echo "collectd.gateways.{{ sn_hostname }}.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo "collectd.gateways.$iam.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
}
|
}
|
||||||
# Restart Services #
|
# Restart Services #
|
||||||
supernode_fail () {
|
supernode_fail () {
|
||||||
@ -59,28 +69,8 @@ while [ true ] ; do
|
|||||||
/usr/sbin/service radvd restart
|
/usr/sbin/service radvd restart
|
||||||
/usr/sbin/service isc-dhcp-server restart
|
/usr/sbin/service isc-dhcp-server restart
|
||||||
echo 0 > /etc/supernode-status/supernode.status
|
echo 0 > /etc/supernode-status/supernode.status
|
||||||
echo "collectd.gateways.{{ sn_hostname }}.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo "collectd.gateways.$iam.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
}
|
}
|
||||||
# who am i ? #
|
|
||||||
if [ $iam = "troisdorf5" ];
|
|
||||||
then
|
|
||||||
my_SN_IP=185.66.193.105
|
|
||||||
other_SN_IP=185.66.193.106
|
|
||||||
other_SN_IP_EXTERN=46.4.138.189
|
|
||||||
else
|
|
||||||
my_SN_IP=185.66.193.106
|
|
||||||
other_SN_IP=185.66.193.105
|
|
||||||
other_SN_IP_EXTERN=5.9.76.198
|
|
||||||
fi
|
|
||||||
if [ $loadbalance = "1" ] && [ $mode != "0" ];
|
|
||||||
then
|
|
||||||
if [ $day -gt 15 ]
|
|
||||||
then
|
|
||||||
active_SN=$SN1
|
|
||||||
else
|
|
||||||
active_SN=$SN2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
#Check other Supernode
|
#Check other Supernode
|
||||||
if [ $iam != $active_SN ];
|
if [ $iam != $active_SN ];
|
||||||
then
|
then
|
||||||
@ -88,12 +78,12 @@ while [ true ] ; do
|
|||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
if [ $online ==1 ] || [ $online = 2 ]; then
|
if [ $online ==1 ] || [ $online = 2 ]; then
|
||||||
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode wieder online. Ich habe mich wieder ausgeschaltet", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":white_check_mark:"}' https://hooks.slack.com/services/{{ slack_token }}
|
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode wieder online. Ich habe mich wieder ausgeschaltet", "channel": "#technik", "username": "$iam", "icon_emoji": ":white_check_mark:"}' https://hooks.slack.com/services/{{ slack_token }}
|
||||||
fi
|
fi
|
||||||
supernode_off
|
supernode_off
|
||||||
else
|
else
|
||||||
supernode_on
|
supernode_on
|
||||||
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode offline. Ich habe mich eingeschaltet", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":warning:"}' https://hooks.slack.com/services/{{ slack_token }}
|
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode offline. Ich habe mich eingeschaltet", "channel": "#technik", "username": "$iam", "icon_emoji": ":warning:"}' https://hooks.slack.com/services/{{ slack_token }}
|
||||||
sleep 300
|
sleep 300
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -103,32 +93,37 @@ while [ true ] ; do
|
|||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
if [ $online = 0 ] || [ $online = 3 ]; then
|
if [ $online = 0 ] || [ $online = 3 ]; then
|
||||||
curl -X POST --data-urlencode 'payload={"text": "Ich bin jetzt Supernode!", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":white_check_mark:"}' https://hooks.slack.com/services/{{ slack_token }}
|
curl -X POST --data-urlencode 'payload={"text": "Ich bin jetzt Supernode!", "channel": "#technik", "username": "$iam", "icon_emoji": ":white_check_mark:"}' https://hooks.slack.com/services/{{ slack_token }}
|
||||||
fi
|
fi
|
||||||
supernode_on
|
supernode_on
|
||||||
else
|
else
|
||||||
supernode_fail
|
supernode_fail
|
||||||
curl -X POST --data-urlencode 'payload={"text": "Ich konnte mich selbst nicht anpingen. Ich versuche mal die Services neu zu starten", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":warning:"}' https://hooks.slack.com/services/{{ slack_token }}
|
curl -X POST --data-urlencode 'payload={"text": "Ich konnte mich selbst nicht anpingen. Ich versuche mal die Services neu zu starten", "channel": "#technik", "username": "$iam", "icon_emoji": ":warning:"}' https://hooks.slack.com/services/{{ slack_token }}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
# Supernode off
|
||||||
if [ $mode = "0" ]; then
|
if [ $mode = "0" ]; then
|
||||||
supernode_off
|
supernode_off
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
# Write Service Status
|
||||||
for service in bird bird6 dhcpd radvd python named
|
for service in bird bird6 dhcpd radvd python named
|
||||||
do
|
do
|
||||||
x=`pidof $service`;
|
x=`pidof $service`;
|
||||||
if [ "$x" = "" ]; then
|
if [ "$x" = "" ]; then
|
||||||
echo "collectd.gateways.{{ sn_hostname }}.$service 0 `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo "collectd.gateways.$iam.$service 0 `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
echo 0 > /etc/supernode-status/"$service".status
|
echo 0 > /etc/supernode-status/"$service".status
|
||||||
else
|
else
|
||||||
echo "collectd.gateways.{{ sn_hostname }}.$service 1 `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo "collectd.gateways.$iam.$service 1 `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
echo 1 > /etc/supernode-status/"$service".status
|
echo 1 > /etc/supernode-status/"$service".status
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
# Check DNS Server
|
||||||
|
host google.de $meship
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
service bind9 restart
|
||||||
|
fi
|
||||||
#Check Tunneldigger Connections
|
#Check Tunneldigger Connections
|
||||||
#Check if foldes exists
|
|
||||||
if ! [ -d /opt/freifunk/tunneldigger_interfaces ]; then
|
if ! [ -d /opt/freifunk/tunneldigger_interfaces ]; then
|
||||||
mkdir /opt/freifunk/tunneldigger_interfaces
|
mkdir /opt/freifunk/tunneldigger_interfaces
|
||||||
fi
|
fi
|
||||||
|
@ -19,11 +19,14 @@ status () {
|
|||||||
elif [ $supernode_status == 3 ]; then
|
elif [ $supernode_status == 3 ]; then
|
||||||
echo "Supernode Offline (Loadbalancing)"
|
echo "Supernode Offline (Loadbalancing)"
|
||||||
fi
|
fi
|
||||||
if [ $loadbalancing = 1 ]; then
|
for service in bird bird6 dhcpd radvd python named
|
||||||
echo "Loadbalancing ist Aktiv"
|
do
|
||||||
|
if [ "$(/bin/cat /etc/supernode-status/$service.status)" = "1" ]; then
|
||||||
|
echo -e "$service \e[1;4;93mläuft\e[0m"
|
||||||
else
|
else
|
||||||
echo "Loadbalancing ist Deativiert"
|
echo -e "$service \e[1;4;91mläuft nicht\e[0m"
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
off () {
|
off () {
|
||||||
|
Loading…
Reference in New Issue
Block a user