Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
cab8d7bc
Commit
cab8d7bc
authored
Oct 25, 2015
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update router scripts
parent
85dcdaa6
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
105 additions
and
10 deletions
+105
-10
both_provs.sh
router/both_provs.sh
+8
-2
check_connectivity.sh
router/check_connectivity.sh
+44
-1
get_ips_z-i.sh
router/get_ips_z-i.sh
+2
-2
get_traffic.sh
router/get_traffic.sh
+35
-0
only_ekvant.sh
router/only_ekvant.sh
+1
-1
only_prometey.sh
router/only_prometey.sh
+1
-1
restart_check_connectivity.sh
router/restart_check_connectivity.sh
+4
-0
set_hop.sh
router/set_hop.sh
+6
-0
transmission.sh
router/transmission.sh
+2
-1
update_z-i.sh
router/update_z-i.sh
+2
-2
No files found.
router/both_provs.sh
View file @
cab8d7bc
...
...
@@ -6,14 +6,18 @@ ip route replace default via 212.176.192.226
# Use Ekvant as main defaul
ip route replace default scope global table common via 212.176.192.226
ip route replace default scope global table hop nexthop via 212.176.192.226 weight 40 nexthop via 85.235.198.25 weight 60
./set_hop.sh
# torrent client
ip rule del from 91.232.225.21 lookup hop
ip rule del from 91.232.225.21 lookup hop
ip rule add from 91.232.225.21 lookup hop
# 91.232.225.60-69 lazy-kun
#ip rule del from 91.232.225.21 lookup hop
#ip rule del from 91.232.225.21 lookup hop
#ip rule add from 91.232.225.21 lookup hop
# de01
ip rule del to 144.76.183.114 lookup hop
ip rule del to 144.76.183.114 lookup hop
...
...
@@ -23,3 +27,5 @@ ip rule add to 144.76.183.114 lookup hop
ip rule del to 85.143.133.46 lookup hop
ip rule del to 85.143.133.46 lookup hop
ip rule add to 85.143.133.46 lookup hop
#./transmission.sh --no-alt-speed
router/check_connectivity.sh
View file @
cab8d7bc
...
...
@@ -94,6 +94,48 @@ apply_state()
esac
}
OLDALTSPEED
=
OLDAVERAGE
=
OLDMAINLOAD
=
calc_distance
()
{
local
DISTANCE
=
$((
$1
-
$2
))
[
$DISTANCE
-ge
0
]
||
DISTANCE
=
$((
-
$DISTANCE
))
echo
"
$DISTANCE
"
}
check_and_wait
()
{
# AVERAGE and MAINLOAD
# note: sleep 10 inside
eval
$(
./get_traffic.sh
)
DISTANCE
=
$(
calc_distance
"
$OLDMAINLOAD
"
"
$MAINLOAD
"
)
if
[
"
$DISTANCE
"
-ge
20
]
;
then
write_log
"
$(
date
)
set main procent to
$MAINLOAD
for hop route table"
./set_hop.sh
$MAINLOAD
OLDMAINLOAD
=
$MAINLOAD
fi
if
[
"
$STATE
"
!=
"both"
]
||
[
"
$AVERAGE
"
-ge
170
]
;
then
ALTSPEED
=
1
else
ALTSPEED
=
0
fi
if
[
"
$OLDALTSPEED
"
!=
"
$ALTSPEED
"
]
;
then
if
[
"
$ALTSPEED
"
=
1
]
;
then
write_log
"
$(
date
)
average speed is too hi
$AVERAGE
, enable alt speed"
./transmission.sh
--alt-speed
else
write_log
"
$(
date
)
average speed is normal
$AVERAGE
, disable alt speed"
./transmission.sh
--no-alt-speed
fi
OLDALTSPEED
=
"
$ALTSPEED
"
fi
}
main_cycle
()
{
...
...
@@ -108,7 +150,8 @@ while true ; do
write_log
"
$(
date
)
State changed to
$NEWSTATE
(Ekvant:
$SHEKVANT
-
$SBEKVANT
, Prometey:
$SHPROMETEY
-
$SBPROMETEY
)"
STATE
=
$NEWSTATE
fi
sleep
7
#sleep 7
check_and_wait
done
}
...
...
router/get_ips_z-i.sh
View file @
cab8d7bc
#!/bin/sh
cd
/home/lav/z-i
||
exit
git pull
git pull
>
/dev/null
#cat dump.csv |cut -f1 -d';'|tr '|' '\n'| tr -d ' '|sort -u
cat
dump.csv |cut
-f1
-d
';'
|tr
'|'
'\n'
|
tr
-d
' '
|s
ort
-u
|sed
'$d'
cat
dump.csv |cut
-f1
-d
';'
|tr
'|'
'\n'
|
tr
-d
' '
|s
ed
'1d'
|sort
-u
router/get_traffic.sh
0 → 100755
View file @
cab8d7bc
#!/bin/sh
set_tr
()
{
# rx 4.85 Mbit/s 7066 packets/s
# tx 95.42 Mbit/s 7769 packets/s
vnstat
-tr
-i
"
$1
"
|
grep
Mbit |
sed
-e
's| *\([rt]x\) *\([0-9][0-9]*\)\..*|\1=\2|g'
}
eval
$(
set_tr inet
)
RX_INET
=
$rx
TX_INET
=
$tx
eval
$(
set_tr inet2
)
RX_INET2
=
$rx
TX_INET2
=
$tx
#echo $RX_INET $RX_INET2
#echo $TX_INET $TX_INET2
#echo $(($RX_INET+$RX_INET2)) $(($TX_INET+$TX_INET2))
TXAVERAGE
=
$((
$TX_INET2
+
$TX_INET
))
MAINLOAD
=
$((
(
$TX_INET2
-
$TX_INET
)/
2
+
50
))
# round to 10
#MAINLOAD=$((($MAINLOAD/10)*10))
echo
"AVERAGE=
$TXAVERAGE
"
echo
"MAINLOAD=
$MAINLOAD
"
echo
"TX_INET=
$TX_INET
"
echo
"TX_INET2=
$TX_INET2
"
echo
"RX_INET=
$RX_INET
"
echo
"RX_INET2=
$RX_INET2
"
router/only_ekvant.sh
View file @
cab8d7bc
...
...
@@ -10,4 +10,4 @@ ip route replace default scope global table hop via 212.176.192.226
# TODO: enable shaper for torrent and our remote backup servers
./slow_transmission.sh
#./transmission.sh --alt-speed
router/only_prometey.sh
View file @
cab8d7bc
...
...
@@ -8,4 +8,4 @@ ip route replace default scope global table common via 85.235.198.25
ip route replace default scope global table hop via 85.235.198.25
./slow_transmission.sh
#./transmission.sh --alt-speed
router/restart_check_connectivity.sh
0 → 100755
View file @
cab8d7bc
#!/bin/sh
./check_connectivity.sh stop
monit
-v
validate all
router/set_hop.sh
0 → 100755
View file @
cab8d7bc
#!/bin/sh
[
-n
"
$1
"
]
&&
MAINLOAD
=
"
$1
"
||
MAINLOAD
=
40
RESERLOAD
=
$((
100
-
$MAINLOAD
))
ip route replace default scope global table hop nexthop via 212.176.192.226 weight
$MAINLOAD
nexthop via 85.235.198.25 weight
$RESERLOAD
router/
slow_
transmission.sh
→
router/transmission.sh
View file @
cab8d7bc
#!/bin/sh
transmission-remote http://tr.lav.eterhost.ru:9091/transmission
--auth
lav:nah9suaB
--alt-speed
# --alt-speed
transmission-remote http://tr.lav.eterhost.ru:9091/transmission
--auth
lav:nah9suaB
$@
# Does not work:
# Unexpected response: <h1>404: Not Found</h1>/transmission//rpc/idsb4ItPI
...
...
router/update_z-i.sh
View file @
cab8d7bc
...
...
@@ -3,7 +3,7 @@
cd
$(
dirname
$0
)
||
exit
SETNAME
=
rkz
ipset destroy
$SETNAME
.tmp
||
exit
ipset destroy
$SETNAME
.tmp
ipset create
$SETNAME
.tmp
hash
:ip
||
exit
#ip rule show | grep "lookup openroute" | sed -e "s|.*:||g" | sed -e "s|lookup|table|g" | while read str ; do
...
...
@@ -19,6 +19,6 @@ ipset swap $SETNAME.tmp $SETNAME
# initial
if
!
iptables
-L
-t
mangle |
grep
-q
$SETNAME
;
then
iptables
-t
mangle
-A
PREROUTING
-m
set
--match-set
$SETNAME
dst
-j
MARK
--set-mark
5
iptables
-t
mangle
-A
PREROUTING
-
i
our
-
m
set
--match-set
$SETNAME
dst
-j
MARK
--set-mark
5
ip rule add fwmark 5 table openroute
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment