dmidecode | awk '
BEGIN {
printf "{"
first_entry = 0
is_array = 0
array_first_entry = 0
}
{
if ($0 ~ /^Handle/) {
if (is_array) {
printf "]"
is_array = 0
}
if (first_entry) {
printf "},"
}
first_entry = 1
gsub(/,$/, "", $2);
printf "\"%s\": {", $2
getline line
printf "\"_description\": \"%s\"", line
gsub(/,$/, "", $5);
printf ",\"_type\": \"%s\"", $5
gsub(/,$/, "", $6);
printf ",\"_bytes\": \"%s\"", $6
} else if ($0 ~ /:/) {
if (is_array) {
printf "]"
is_array = 0
}
gsub(/^[[:space:]]+/, "", $0)
split($0, a, ": ");
if (length(a) > 1) {
gsub(/"/, "\\\"", a[2])
gsub(/[[:space:]]+$/, "", a[2])
printf ",\"%s\": \"%s\"", a[1], a[2]
}
else if (length(a) == 1) {
gsub(/:$/, "", a[1])
printf ",\"%s\": [", a[1]
is_array = 1
array_first_entry = 0
}
}
else if (is_array && NF > 0) {
if (array_first_entry) {
printf ","
}
array_first_entry = 1
gsub(/^[[:space:]]+/, "", $0)
gsub(/"/, "\\\"", $0)
printf "\"%s\"", $0
}
}
END {
if (is_array) {
printf "]"
}
print "}}"
}'
Tag Archives: debian
recover drbd split brain
Define one node as secondary and discard data on this
drbdadm secondary all drbdadm disconnect all drbdadm -- --discard-my-data connect all
Define anoher node as primary and connect
drbdadm primary all drbdadm disconnect all drbdadm connect all
Test Jumbo Frames / MTU 9000
Linux:
ping -M do -s 8972 xxx.xxx.xxx.xxx
OSX/BSD:
ping -D -s 8184 xxx.xxx.xxx.xxx
Windows:
ping -f -l 9000 xxx.xxx.xxx.xxx
Example results on Linux
If you’ve forgotten to enable jumbo frames/9k MTU on your client device you’re sending the ping from:
PING xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx): 8184 data bytes ping: sendto: Message too long
If you have enabled jumbo frames on your client but not the destination (or a switch in between):
PING xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx): 8184 data bytes Request timeout for icmp_seq 0
If you’ve done everything righ:
PING xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx): 8184 data bytes 8192 bytes from xxx.xxx.xxx.xxx: icmp_seq=0 ttl=128 time=0.714 ms
bash DNSDIST dashboard
Static network config with dhcp fallback
/etc/network/interfaces:
auto wan iface wan inet manual up ifup eth0=eth0-static post-up /etc/network/checkConnectivity.sh eth0 192.168.0.1 10.10.0.2 iface eth0 inet manual #static eth0 config iface eth0-static inet static address 192.168.0.97 netmask 255.255.255.0 gateway 192.168.0.1 dns-nameservers 192.168.0.1 10.10.0.2 dns-search example.net #dhcp eth0 config iface eth0-dhcp inet dhcp
/etc/network/checkConnectivity.sh:
#!/bin/bash
nif=${1}
shift
sleep 1
for i in ${@}; do
ping -c 2 ${i} \
&& exit 0
done
# if nothing responds
ifdown ${nif}
ifup ${nif}=${nif}-dhcp
manually override:
ifup eth0=eth0-staticifup eth0=eth0-dhcp