Projet

Général

Profil

Netconsole » Historique » Version 1

Laurent GUERBY, 11/08/2017 10:00

1 1 Laurent GUERBY
{{>toc}}
2 1 Laurent GUERBY
3 1 Laurent GUERBY
h1. Netconsole
4 1 Laurent GUERBY
5 1 Laurent GUERBY
h2. nagios
6 1 Laurent GUERBY
7 1 Laurent GUERBY
<pre>
8 1 Laurent GUERBY
root@nucnagios:~/netconsole# more setup-console.sh 
9 1 Laurent GUERBY
#!/bin/bash
10 1 Laurent GUERBY
11 1 Laurent GUERBY
here=$(dirname $(readlink -f $0))
12 1 Laurent GUERBY
cleanup(){
13 1 Laurent GUERBY
	kill $(jobs -p)
14 1 Laurent GUERBY
	exit 0
15 1 Laurent GUERBY
}
16 1 Laurent GUERBY
17 1 Laurent GUERBY
trap cleanup EXIT
18 1 Laurent GUERBY
19 1 Laurent GUERBY
nc -u -l -p 6600 > $here/stri.dmesg 2>&1 &
20 1 Laurent GUERBY
nc -u -l -p 6601 > $here/g1.dmesg 2>&1 &
21 1 Laurent GUERBY
nc -u -l -p 6602 > $here/g2.dmesg 2>&1 &
22 1 Laurent GUERBY
nc -u -l -p 6603 > $here/g3.dmesg 2>&1 &
23 1 Laurent GUERBY
nc -u -l -p 6604 > $here/g4.dmesg 2>&1 &
24 1 Laurent GUERBY
nc -u -l -p 6605 > $here/g5.dmesg 2>&1 &
25 1 Laurent GUERBY
nc -u -l -p 6606 > $here/g6.dmesg 2>&1 &
26 1 Laurent GUERBY
nc -u -l -p 6607 > $here/n7.dmesg 2>&1 &
27 1 Laurent GUERBY
nc -u -l -p 6608 > $here/g8.dmesg 2>&1 &
28 1 Laurent GUERBY
nc -u -l -p 6609 > $here/g9.dmesg 2>&1 &
29 1 Laurent GUERBY
nc -u -l -p 6610 > $here/g10.dmesg 2>&1 &
30 1 Laurent GUERBY
nc -u -l -p 6611 > $here/g11.dmesg 2>&1 &
31 1 Laurent GUERBY
nc -u -l -p 6612 > $here/g12.dmesg 2>&1 &
32 1 Laurent GUERBY
nc -u -l -p 6613 > $here/g13.dmesg 2>&1 &
33 1 Laurent GUERBY
nc -u -l -p 6614 > $here/g14.dmesg 2>&1 &
34 1 Laurent GUERBY
nc -u -l -p 6615 > $here/g15.dmesg 2>&1 &
35 1 Laurent GUERBY
nc -u -l -p 6616 > $here/g16.dmesg 2>&1 &
36 1 Laurent GUERBY
37 1 Laurent GUERBY
echo "netconsole listener running"
38 1 Laurent GUERBY
wait
39 1 Laurent GUERBY
40 1 Laurent GUERBY
root@nucnagios:~/netconsole# nohup ./setup-console.sh >& /dev/null < /dev/null &
41 1 Laurent GUERBY
</pre>
42 1 Laurent GUERBY
43 1 Laurent GUERBY
h3. g1
44 1 Laurent GUERBY
45 1 Laurent GUERBY
<pre>
46 1 Laurent GUERBY
root@g1:~# more /etc/rc.local
47 1 Laurent GUERBY
48 1 Laurent GUERBY
netconsole_cfg["g1"]="192.168.128.201:6601"
49 1 Laurent GUERBY
50 1 Laurent GUERBY
51 1 Laurent GUERBY
# Setup some helper vars
52 1 Laurent GUERBY
h=$(hostname -s)
53 1 Laurent GUERBY
netconsole_path=/sys/kernel/config/netconsole/nagios
54 1 Laurent GUERBY
netconsole_ip=$(echo ${netconsole_cfg[$h]} | awk -F: '{print $1}')
55 1 Laurent GUERBY
netconsole_port=$(echo ${netconsole_cfg[$h]} | awk -F: '{print $2}')
56 1 Laurent GUERBY
netconsole_int=$(echo ${netconsole_cfg[$h]} | awk -F: '{print $3}')
57 1 Laurent GUERBY
netconsole_int=${netconsole_int:-eth2}
58 1 Laurent GUERBY
59 1 Laurent GUERBY
# NETCONSOLE interface
60 1 Laurent GUERBY
[ "${netconsole_cfg[$h]}" ] && ip a a $netconsole_ip/24 dev $netconsole_int
61 1 Laurent GUERBY
62 1 Laurent GUERBY
# Setup netconsole
63 1 Laurent GUERBY
modprobe configfs
64 1 Laurent GUERBY
modprobe netconsole
65 1 Laurent GUERBY
mount | grep -q configfs || mount none -t configfs /sys/kernel/config
66 1 Laurent GUERBY
mkdir -p $netconsole_path
67 1 Laurent GUERBY
if [ "${netconsole_cfg[$h]}" ]; then
68 1 Laurent GUERBY
	echo 0 > $netconsole_path/enabled
69 1 Laurent GUERBY
	echo $netconsole_int > $netconsole_path/dev_name
70 1 Laurent GUERBY
	echo $netconsole_ip > $netconsole_path/local_ip
71 1 Laurent GUERBY
	echo $netconsole_port > $netconsole_path/local_port
72 1 Laurent GUERBY
	echo "192.168.128.248" > $netconsole_path/remote_ip
73 1 Laurent GUERBY
	echo "b8:ae:ed:70:8b:80" > $netconsole_path/remote_mac
74 1 Laurent GUERBY
	echo 1 > $netconsole_path/enabled
75 1 Laurent GUERBY
	sleep 1
76 1 Laurent GUERBY
	echo m > /proc/sysrq-trigger  # test-it
77 1 Laurent GUERBY
fi
78 1 Laurent GUERBY
</pre>