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
b2c9239d
Commit
b2c9239d
authored
Oct 27, 2015
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check_connectivity: cleanup and improve code
parent
f6613331
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
24 deletions
+53
-24
check_connectivity.sh
router/check_connectivity.sh
+37
-23
get_traffic.sh
router/get_traffic.sh
+16
-1
No files found.
router/check_connectivity.sh
View file @
b2c9239d
...
...
@@ -98,13 +98,6 @@ apply_state()
esac
}
ALTSPEED
=
OLDALTSPEED
=
OLDAVERAGE
=
0
OLDMAINLOAD
=
0
OLDTX
=
0
CURCOUNT
=
0
CURDISCOUNT
=
2
calc_distance
()
{
...
...
@@ -113,20 +106,17 @@ calc_distance()
echo
"
$DISTANCE
"
}
# slow torrent upload on
MAXAVERAGE
=
180
MAXTX
=
9
0
MAXTX
=
10
0
ch
eck_and_wait
()
ch
annel_control
()
{
# AVERAGE and MAINLOAD
# note: sleep 10 inside
eval
$(
./get_traffic.sh
)
######### channel control ##########
# TODO: integrate?
DISTANCE
=
$(
calc_distance
"
$OLDMAINLOAD
"
"
$MAINLOAD
"
)
# delay
if
[
"
$DISTANCE
"
-ge
1
5
]
;
then
if
[
"
$DISTANCE
"
-ge
5
]
;
then
CURCOUNT
=
$((
$CURCOUNT
+
1
))
else
CURCOUNT
=
0
...
...
@@ -141,14 +131,11 @@ check_and_wait()
fi
OLDMAINLOAD
=
$CALCMAINLOAD
fi
}
# force alt speed when we work without reserve channel
if
[
"
$STATE
"
!=
"both"
]
;
then
ALTSPEED
=
1
CURDISCOUNT
=
0
else
# on both channels
torrent_control
()
{
######### torrent control #############
# disable alt speed after timeout
if
[
"
$CURDISCOUNT
"
-gt
0
]
;
then
if
[
"
$CURDISCOUNT
"
=
1
]
;
then
...
...
@@ -170,12 +157,39 @@ check_and_wait()
#fi
fi
fi
}
ALTSPEED
=
OLDALTSPEED
=
OLDAVERAGE
=
0
OLDMAINLOAD
=
0
OLDTX
=
0
CURCOUNT
=
0
CURDISCOUNT
=
2
check_and_wait
()
{
# AVERAGE and MAINLOAD
# note: sleep 10 inside
eval
$(
./get_traffic.sh
)
# force alt speed when we work without reserve channel
if
[
"
$STATE
"
!=
"both"
]
;
then
ALTSPEED
=
1
CURDISCOUNT
=
0
CURCOUNT
=
0
else
# on both channels
channel_control
torrent_control
fi
if
[
"
$OLDALTSPEED
"
!=
"
$ALTSPEED
"
]
;
then
if
[
"
$ALTSPEED
"
=
1
]
;
then
write_log
"
$(
date
)
average trafic
$AVERAGE
>
$MAXAVERAGE
or TX_INET
$TX_INET
>
$MAXTX
, enable alt speed"
write_log
"
$(
date
)
average trafic
$AVERAGE
>
$MAXAVERAGE
or TX_INET
$TX_INET
>
$MAXTX
or some uplink is broken
, enable alt speed"
./transmission.sh
--alt-speed
else
write_log
"
$(
date
)
average traffic
$AVERAGE
is normal, disable alt speed"
...
...
router/get_traffic.sh
View file @
b2c9239d
...
...
@@ -19,8 +19,23 @@ TX_INET2=$tx
#echo $TX_INET $TX_INET2
#echo $(($RX_INET+$RX_INET2)) $(($TX_INET+$TX_INET2))
if
[
-z
"
$TX_INET2
"
]
||
[
-z
"
$RX_INET2
"
]
;
then
TX_INET2
=
0
RX_INET2
=
0
fi
if
[
-z
"
$TX_INET
"
]
||
[
-z
"
$RX_INET
"
]
;
then
TX_INET
=
0
RX_INET
=
0
fi
TXAVERAGE
=
$((
$TX_INET2
+
$TX_INET
))
MAINLOAD
=
$((
(
$TX_INET2
-
$TX_INET
)/
2
+
50
))
#MAINLOAD=$((($TX_INET2-$TX_INET)/2+50))
MAINLOAD
=
$((
100
-
$TX_INET
))
# hack for do not use main channel if overloaded
[
"
$MAINLOAD
"
-lt
15
]
&&
MAINLOAD
=
0
# round to 10
#MAINLOAD=$((($MAINLOAD/10)*10))
...
...
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