#!/bin/bash
[ $(id -u) -ne 0 ] && exec sudo $0 $*

#========================================
echo "Sysctl Calls"
sysctl -w net.core.somaxconn=1048576
sysctl -w net.ipv4.tcp_max_syn_backlog=262144
sysctl -w net.ipv4.tcp_tw_reuse=1
sysctl -w net.ipv4.ip_local_port_range="1024 65535"
sysctl -w vm.max_map_count=2097152
cpupower frequency-set -g performance

# sysctl net.core.somaxconn
# sysctl net.ipv4.tcp_max_syn_backlog
# sysctl net.ipv4.tcp_tw_reuse
# sysctl net.ipv4.ip_local_port_range
# sysctl vm.max_map_count

#========================================
echo "Check what we can debug/trace"

echo "/proc/sys/kernel/yama/ptrace_scope"
cat /proc/sys/kernel/yama/ptrace_scope
echo "/proc/sys/kernel/kptr_restrict"
cat /proc/sys/kernel/kptr_restrict
echo "/proc/sys/kernel/nmi_watchdog"
cat /proc/sys/kernel/nmi_watchdog
echo "/proc/sys/kernel/perf_event_paranoid"
cat /proc/sys/kernel/perf_event_paranoid

#========================================
echo "User Limits"
ulimit -a