Projet

Général

Profil

Netconsole » Historique » Version 5

Version 4 (Laurent GUERBY, 11/08/2017 10:08) → Version 5/17 (Laurent GUERBY, 11/08/2017 10:12)

{{>toc}}

h1. Netconsole

h2. nagios

<pre>
root@nucnagios:~/netconsole# more setup-console.sh
#!/bin/bash

here=$(dirname $(readlink -f $0))
cleanup(){
kill $(jobs -p)
exit 0
}

trap cleanup EXIT

nc -u -l -p 6600 > $here/stri.dmesg 2>&1 &
nc -u -l -p 6601 > $here/g1.dmesg 2>&1 &
nc -u -l -p 6602 > $here/g2.dmesg 2>&1 &
nc -u -l -p 6603 > $here/g3.dmesg 2>&1 &
nc -u -l -p 6604 > $here/g4.dmesg 2>&1 &
nc -u -l -p 6605 > $here/g5.dmesg 2>&1 &
nc -u -l -p 6606 > $here/g6.dmesg 2>&1 &
nc -u -l -p 6607 > $here/n7.dmesg 2>&1 &
nc -u -l -p 6608 > $here/g8.dmesg 2>&1 &
nc -u -l -p 6609 > $here/g9.dmesg 2>&1 &
nc -u -l -p 6610 > $here/g10.dmesg 2>&1 &
nc -u -l -p 6611 > $here/g11.dmesg 2>&1 &
nc -u -l -p 6612 > $here/g12.dmesg 2>&1 &
nc -u -l -p 6613 > $here/g13.dmesg 2>&1 &
nc -u -l -p 6614 > $here/g14.dmesg 2>&1 &
nc -u -l -p 6615 > $here/g15.dmesg 2>&1 &
nc -u -l -p 6616 > $here/g16.dmesg 2>&1 &

echo "netconsole listener running"
wait

root@nucnagios:~/netconsole# nohup ./setup-console.sh >& /dev/null < /dev/null &
</pre>

h2. g1

<pre>
root@g1:~# more /etc/rc.local

declare -A netconsole_cfg

netconsole_cfg["g1"]="192.168.128.201:6601"

# Setup some helper vars
h=$(hostname -s)
netconsole_path=/sys/kernel/config/netconsole/nagios
netconsole_ip=$(echo ${netconsole_cfg[$h]} | awk -F: '{print $1}')
netconsole_port=$(echo ${netconsole_cfg[$h]} | awk -F: '{print $2}')
netconsole_int=$(echo ${netconsole_cfg[$h]} | awk -F: '{print $3}')
netconsole_int=${netconsole_int:-eth2}

# NETCONSOLE interface
[ "${netconsole_cfg[$h]}" ] && ip a a $netconsole_ip/24 dev $netconsole_int

# Setup netconsole
modprobe configfs
modprobe netconsole
mount | grep -q configfs || mount none -t configfs /sys/kernel/config
mkdir -p $netconsole_path
if [ "${netconsole_cfg[$h]}" ]; then
echo 0 > $netconsole_path/enabled
echo $netconsole_int > $netconsole_path/dev_name
echo $netconsole_ip > $netconsole_path/local_ip
echo $netconsole_port > $netconsole_path/local_port
echo "192.168.128.248" > $netconsole_path/remote_ip
echo "b8:ae:ed:70:8b:80" > $netconsole_path/remote_mac
echo 1 > $netconsole_path/enabled
sleep 1
echo m > /proc/sysrq-trigger # test-it
fi
</pre>

h2. gcc67

<pre>
modprobe configfs
modprobe netconsole
#mount none -t configfs /sys/kernel/config
netconsole_path=/sys/kernel/config/netconsole/nagios
mkdir -p $netconsole_path
echo 0 > $netconsole_path/enabled
echo enp10s0 > $netconsole_path/dev_name
echo 91.224.148.12 > $netconsole_path/local_ip
echo 6615 > $netconsole_path/local_port
echo 6615 > $netconsole_path/remote_port
echo
"89.234.156.171" > $netconsole_path/remote_ip
echo "b8:ae:ed:70:8b:80" > $netconsole_path/remote_mac
echo 1 > $netconsole_path/enabled
sleep 1
echo m > /proc/sysrq-trigger # test-it
</pre> <pre>