Netconsole » Historique » Version 8
Laurent GUERBY, 11/08/2017 16:08
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 | 2 | Laurent GUERBY | h2. 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 | 2 | Laurent GUERBY | declare -A netconsole_cfg |
49 | 2 | Laurent GUERBY | |
50 | 1 | Laurent GUERBY | netconsole_cfg["g1"]="192.168.128.201:6601" |
51 | 1 | Laurent GUERBY | |
52 | 1 | Laurent GUERBY | |
53 | 1 | Laurent GUERBY | # Setup some helper vars |
54 | 1 | Laurent GUERBY | h=$(hostname -s) |
55 | 1 | Laurent GUERBY | netconsole_path=/sys/kernel/config/netconsole/nagios |
56 | 1 | Laurent GUERBY | netconsole_ip=$(echo ${netconsole_cfg[$h]} | awk -F: '{print $1}') |
57 | 1 | Laurent GUERBY | netconsole_port=$(echo ${netconsole_cfg[$h]} | awk -F: '{print $2}') |
58 | 1 | Laurent GUERBY | netconsole_int=$(echo ${netconsole_cfg[$h]} | awk -F: '{print $3}') |
59 | 1 | Laurent GUERBY | netconsole_int=${netconsole_int:-eth2} |
60 | 1 | Laurent GUERBY | |
61 | 1 | Laurent GUERBY | # NETCONSOLE interface |
62 | 1 | Laurent GUERBY | [ "${netconsole_cfg[$h]}" ] && ip a a $netconsole_ip/24 dev $netconsole_int |
63 | 1 | Laurent GUERBY | |
64 | 1 | Laurent GUERBY | # Setup netconsole |
65 | 1 | Laurent GUERBY | modprobe configfs |
66 | 1 | Laurent GUERBY | modprobe netconsole |
67 | 1 | Laurent GUERBY | mount | grep -q configfs || mount none -t configfs /sys/kernel/config |
68 | 1 | Laurent GUERBY | mkdir -p $netconsole_path |
69 | 1 | Laurent GUERBY | if [ "${netconsole_cfg[$h]}" ]; then |
70 | 1 | Laurent GUERBY | echo 0 > $netconsole_path/enabled |
71 | 1 | Laurent GUERBY | echo $netconsole_int > $netconsole_path/dev_name |
72 | 1 | Laurent GUERBY | echo $netconsole_ip > $netconsole_path/local_ip |
73 | 1 | Laurent GUERBY | echo $netconsole_port > $netconsole_path/local_port |
74 | 1 | Laurent GUERBY | echo "192.168.128.248" > $netconsole_path/remote_ip |
75 | 1 | Laurent GUERBY | echo "b8:ae:ed:70:8b:80" > $netconsole_path/remote_mac |
76 | 1 | Laurent GUERBY | echo 1 > $netconsole_path/enabled |
77 | 1 | Laurent GUERBY | sleep 1 |
78 | 1 | Laurent GUERBY | echo m > /proc/sysrq-trigger # test-it |
79 | 1 | Laurent GUERBY | fi |
80 | 1 | Laurent GUERBY | </pre> |
81 | 2 | Laurent GUERBY | |
82 | 2 | Laurent GUERBY | h2. gcc67 |
83 | 2 | Laurent GUERBY | |
84 | 2 | Laurent GUERBY | <pre> |
85 | 2 | Laurent GUERBY | modprobe configfs |
86 | 2 | Laurent GUERBY | modprobe netconsole |
87 | 4 | Laurent GUERBY | #mount none -t configfs /sys/kernel/config |
88 | 2 | Laurent GUERBY | netconsole_path=/sys/kernel/config/netconsole/nagios |
89 | 2 | Laurent GUERBY | mkdir -p $netconsole_path |
90 | 2 | Laurent GUERBY | echo 0 > $netconsole_path/enabled |
91 | 3 | Laurent GUERBY | echo enp10s0 > $netconsole_path/dev_name |
92 | 2 | Laurent GUERBY | echo 91.224.148.12 > $netconsole_path/local_ip |
93 | 3 | Laurent GUERBY | echo 6615 > $netconsole_path/local_port |
94 | 5 | Laurent GUERBY | echo 6615 > $netconsole_path/remote_port |
95 | 3 | Laurent GUERBY | echo "89.234.156.171" > $netconsole_path/remote_ip |
96 | 2 | Laurent GUERBY | echo "b8:ae:ed:70:8b:80" > $netconsole_path/remote_mac |
97 | 2 | Laurent GUERBY | echo 1 > $netconsole_path/enabled |
98 | 2 | Laurent GUERBY | sleep 1 |
99 | 1 | Laurent GUERBY | echo m > /proc/sysrq-trigger # test-it |
100 | 5 | Laurent GUERBY | </pre> |
101 | 6 | Laurent GUERBY | |
102 | 6 | Laurent GUERBY | h2. gcc68 |
103 | 6 | Laurent GUERBY | |
104 | 6 | Laurent GUERBY | <pre> |
105 | 6 | Laurent GUERBY | modprobe configfs |
106 | 6 | Laurent GUERBY | modprobe netconsole |
107 | 7 | Laurent GUERBY | mount none -t configfs /sys/kernel/config |
108 | 6 | Laurent GUERBY | netconsole_path=/sys/kernel/config/netconsole/nagios |
109 | 6 | Laurent GUERBY | mkdir -p $netconsole_path |
110 | 6 | Laurent GUERBY | echo 0 > $netconsole_path/enabled |
111 | 6 | Laurent GUERBY | echo enp10s0 > $netconsole_path/dev_name |
112 | 6 | Laurent GUERBY | echo 91.224.148.13 > $netconsole_path/local_ip |
113 | 6 | Laurent GUERBY | echo 6616 > $netconsole_path/local_port |
114 | 6 | Laurent GUERBY | echo 6616 > $netconsole_path/remote_port |
115 | 6 | Laurent GUERBY | echo "89.234.156.171" > $netconsole_path/remote_ip |
116 | 6 | Laurent GUERBY | echo "b8:ae:ed:70:8b:80" > $netconsole_path/remote_mac |
117 | 6 | Laurent GUERBY | echo 1 > $netconsole_path/enabled |
118 | 6 | Laurent GUERBY | sleep 1 |
119 | 6 | Laurent GUERBY | echo m > /proc/sysrq-trigger # test-it |
120 | 6 | Laurent GUERBY | </pre> |
121 | 8 | Laurent GUERBY | |
122 | 8 | Laurent GUERBY | h2. New |
123 | 8 | Laurent GUERBY | |
124 | 8 | Laurent GUERBY | <pre> |
125 | 8 | Laurent GUERBY | echo 0 > /sys/kernel/config/netconsole/nagios/enabled |
126 | 8 | Laurent GUERBY | rmdir /sys/kernel/config/netconsole/nagios/ |
127 | 8 | Laurent GUERBY | rmmod netconsole |
128 | 8 | Laurent GUERBY | |
129 | 8 | Laurent GUERBY | #gcc67 |
130 | 8 | Laurent GUERBY | modprobe netconsole netconsole=@91.224.148.12/enp10s0,6666@89.234.156.171/b8:ae:ed:70:8b:80 |
131 | 8 | Laurent GUERBY | #gcc68 |
132 | 8 | Laurent GUERBY | modprobe netconsole netconsole=@91.224.148.13/enp10s0,6666@89.234.156.171/b8:ae:ed:70:8b:80 |
133 | 8 | Laurent GUERBY | </pre> |
134 | 8 | Laurent GUERBY | |
135 | 8 | Laurent GUERBY | On nagios: |
136 | 8 | Laurent GUERBY | |
137 | 8 | Laurent GUERBY | <pre> |
138 | 8 | Laurent GUERBY | root@nucnagios:~/netconsole# nohup python3 pyudplogger.py >& log.txt < /dev/null & |
139 | 8 | Laurent GUERBY | </pre> |