Projet

Général

Profil

Netconsole » Historique » Version 10

« Précédent - Version 10/17 (diff) - Suivant » - Version actuelle
Laurent GUERBY, 11/08/2017 16:53


Netconsole

nagios

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 &

g1

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

gcc67

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

gcc68

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.13 > $netconsole_path/local_ip
echo 6616  > $netconsole_path/local_port
echo 6616  > $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

New

echo 0 > /sys/kernel/config/netconsole/nagios/enabled 
rmdir /sys/kernel/config/netconsole/nagios/
rmmod netconsole

#h8
modprobe netconsole netconsole=@192.168.128.53/eth0,6666@192.168.128.248/b8:ae:ed:70:8b:80
#gcc67
modprobe netconsole netconsole=@91.224.148.12/enp10s0,6666@89.234.156.171/b8:ae:ed:70:8b:80
#gcc68
modprobe netconsole netconsole=@91.224.148.13/enp10s0,6666@89.234.156.171/b8:ae:ed:70:8b:80
#gcc68 ipv6 link local
modprobe netconsole netconsole=@fe80::7285:c2ff:fe3a:167e/enp10s0,6666@fe80::baae:edff:fe70:8b80/b8:ae:ed:70:8b:80

On nagios:

# if not managed by supervisord see root@nucnagios:/etc/supervisor/conf.d/*
root@nucnagios:~/netconsole# nohup python3 pyudplogger.py >& log.txt < /dev/null &
root@nucnagios:~/netconsole# nohup python3 pyudplogger6.py >& log6.txt < /dev/null &