Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added(autotune-reductor): backport from carbon reductor 7 #215

Merged
merged 2 commits into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def read(*paths):

setuptools.setup(
name='netutils-linux',
version='2.7.9',
version='2.7.10',
author='Oleg Strizhechenko',
author_email='[email protected]',
license='MIT',
Expand Down
67 changes: 56 additions & 11 deletions utils/autotune-reductor
Original file line number Diff line number Diff line change
@@ -1,39 +1,84 @@
#!/usr/bin/env bash
#!/bin/bash

set -euo pipefail
set -euE

if [ -f /usr/local/Reductor/etc/const ]; then
. /usr/local/Reductor/etc/const
elif [ -f /app/reductor/usr/local/Reductor/etc/const ]; then
. /app/reductor/usr/local/Reductor/etc/const
else
echo "$0 $@ [$$] FAILURE no etc/const" >&2
exit 1
fi

echo "$0 $@ [$$] START" >&2


if [ "${1:-}" = "--help" ]; then
echo "Info: автоматические настраивает сетевые карты для приёма зеркала"
echo "Usage: $0 без аргументов"
echo "Example: $0 без аргументов"
exit 0
fi

find_mirror_conf() {
local CR7=/usr/local/Reductor/userinfo/mirror_info.conf
local CR8_INNER=/cfg/userinfo/mirror_info.conf
local CR8_OUTER=/app/reductor/$CR8_INNER
set -e
local cr7="/usr/local/Reductor/userinfo/mirror_info.conf"
local cr8_inner="/cfg/userinfo/mirror_info.conf"
local cr8_outer="/app/reductor/$cr8_inner"
local conf
for conf in $CR7 $CR8_INNER $CR8_OUTER; do
[ -f $conf ] || continue
echo $conf
for conf in "$cr7" "$cr8_inner" "$cr8_outer"; do
[ ! -f "$conf" ] && continue
echo "$conf"
break
done
return 0
}

mirror_devices_bridge() {
brctl show | tail -n +2 | awk '{print $4}'
# skip strongbash034
brctl show | tail -n +2 | awk '{print $4}' | cut -d '.' -f1 | sort -u
return 0
}

mirror_devices() {
set -e
local mirror_conf
mirror_conf="$(find_mirror_conf)"
if [ -n "${mirror_conf:-}" ]; then
awk '{print $1}' "$mirror_conf" | sort -u
else
mirror_devices_bridge
fi
return 0
}

main() {
maximize-cpu-freq
local device
# virtualenv нужен только для CR7
if [ ! -f /cfg/config ]; then
if [ ! -f ${VENVBIN}/activate ]; then
echo "$0 $@ [$$] FAILURE no virtualenv" >&2
exit 2
fi
set +eu
. ${VENVBIN}/activate
set -eu
fi
maximize-cpu-freq || true
for device in $(mirror_devices); do
autorps "$device" || true
echo "$0 $@ [$$] Настройка $device" >&2
autorps "$device" 2>/dev/null || true
rx-buffers-increase "$device" || true
done
if [ ! -f /cfg/config ]; then
set +eu
deactivate
set -eu
fi
return 0
}

main "$@"
echo "$0 $@ [$$] SUCCESS" >&2
exit 0