Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[READY] - openwrt: disable logd and enable prometheus #643

Merged
merged 13 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions openwrt/configs/common.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ CONFIG_BUSYBOX_CONFIG_FEATURE_DEFAULT_PASSWD_ALGO="sha512"
# CONFIG_BUSYBOX_CONFIG_FEATURE_PASSWD_WEAK_CHECK is not set
CONFIG_BUSYBOX_CONFIG_FEATURE_STAT_FILESYSTEM=y
CONFIG_BUSYBOX_CONFIG_FEATURE_STAT_FORMAT=y
# CONFIG_BUSYBOX_CONFIG_LOGGER is not set
CONFIG_BUSYBOX_CONFIG_STAT=y
CONFIG_LLDPD_WITH_CDP=y
CONFIG_LLDPD_WITH_CUSTOM=y
Expand Down Expand Up @@ -49,24 +50,40 @@ CONFIG_PACKAGE_libevent2=y
CONFIG_PACKAGE_libfastjson=y
CONFIG_PACKAGE_libfido2=y
CONFIG_PACKAGE_libiperf3=y
CONFIG_PACKAGE_libiwinfo=y
CONFIG_PACKAGE_libiwinfo-data=y
CONFIG_PACKAGE_libiwinfo-lua=y
CONFIG_PACKAGE_liblua=y
# CONFIG_PACKAGE_libmnl is not set
CONFIG_PACKAGE_libncurses=y
# CONFIG_PACKAGE_libnftnl is not set
CONFIG_PACKAGE_libopenssl=y
CONFIG_PACKAGE_libpcap=y
CONFIG_PACKAGE_libpopt=y
CONFIG_PACKAGE_libreadline=y
CONFIG_PACKAGE_libubus-lua=y
# CONFIG_PACKAGE_libucode is not set
CONFIG_PACKAGE_libudev-zero=y
CONFIG_PACKAGE_lldpd=y
CONFIG_PACKAGE_logger=y
# CONFIG_PACKAGE_logd is not set
CONFIG_PACKAGE_logrotate=y
CONFIG_PACKAGE_lua=y
CONFIG_PACKAGE_luasocket=y
# CONFIG_PACKAGE_nftables-json is not set
CONFIG_PACKAGE_openssh-client=y
CONFIG_PACKAGE_openssh-client-utils=y
CONFIG_PACKAGE_openssh-keygen=y
CONFIG_PACKAGE_openssh-server=y
CONFIG_PACKAGE_prometheus-node-exporter-lua=y
CONFIG_PACKAGE_prometheus-node-exporter-lua-netstat=y
CONFIG_PACKAGE_prometheus-node-exporter-lua-openwrt=y
CONFIG_PACKAGE_prometheus-node-exporter-lua-wifi=y
CONFIG_PACKAGE_prometheus-node-exporter-lua-wifi_stations=y
CONFIG_PACKAGE_rsyslog=y
CONFIG_PACKAGE_tcpdump=y
CONFIG_PACKAGE_terminfo=y
# CONFIG_PACKAGE_ucode is not set
CONFIG_PACKAGE_uhttpd=y
CONFIG_PACKAGE_uhttpd-mod-lua=y
CONFIG_PACKAGE_zlib=y
4 changes: 4 additions & 0 deletions openwrt/docs/MT7622.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
10. Upload the SCaLE latest image: `openwrt-...-mediatek-mt7622-linksys_e8450-ubi-squashfs-sysupgrade.itb`.
12. The device will reboot, it will come up on the mgmt vlan setup

### Upgrading our image

Immediately after `sysupgrade` the router will close all SSH connections. The power LED will flash, then go solid. The entire flash process is very quick, ~1 minute.

### UBI Force Recovery Mode

Use this section when you have another UBI image on the hardware and you need to get it to accept our image
Expand Down
27 changes: 13 additions & 14 deletions openwrt/files/etc/config/lldpd
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
config lldpd config
option enable_cdp 1
option enable_fdp 1
option enable_sonmp 1
option enable_edp 1
# LLDP frames are link-local frames, do not use any
# network interfaces other than the ones that achieve
# a link with its link partner, and the link partner
# being another networking device. Do not use bridge,
# VLAN, or DSA conduit interfaces.
#
# lldp unable to receive frames on mediatek due to bug
# ref: https://github.com/openwrt/openwrt/issues/13788

option lldp_class 4
# TODO make this mean something
option lldp_location "2:FR:6:Commercial Rd:3:Roseville:19:4"
# lldp will default to listening on all interfaces

# if empty, the distribution description is sent
option lldp_description "OpenWrt System"

# interfaces to listen on
# TODO: This should be dynamic and based on
# yaml config
list interface "eth1"
# Set class of device
option lldp_class 4
# if empty, the distribution description is sent
option lldp_description "OpenWrt System"
4 changes: 4 additions & 0 deletions openwrt/files/etc/config/prometheus-node-exporter-lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config prometheus-node-exporter-lua 'main'
option listen_interface 'mgmt'
option listen_ipv6 '1'
option listen_port '9100'
5 changes: 5 additions & 0 deletions openwrt/files/etc/rc.local
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
# TODO make this a true service
/root/bin/wifi-details.sh >/dev/null 2>/dev/null </dev/null &

# By default anything install in opkg that includes a service will start out
# of the box. Easiest way to disable services that we depend
# on but dont want to start
/etc/init.d/uhttpd stop; /etc/init.d/uhttpd disabled

# apinger initial template population
# this needs to remain in the case where DHCP isnt working initially
# there is also a race condition with the wifi interfaces coming online
Expand Down
24 changes: 0 additions & 24 deletions openwrt/files/etc/zabbix_agentd.conf

This file was deleted.

21 changes: 19 additions & 2 deletions tests/serverspec/spec/shared/openwrt/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
DEFAULT_BINS=["apinger", "awk", "bash", "logrotate",
"rsyslogd", "tcpdump"]

REMOVED_BINS=["snmpd", "dropbear"]
REMOVED_BINS=["snmpd", "dropbear", "logd"]

DEFAULT_SERVICES=["apinger", "crond", "rsyslogd", "lldpd"]
DEFAULT_SERVICES=["apinger", "crond", "rsyslogd", "lldpd",
"ntpd" ]

DEFAULT_BINS.each do |bin|
describe command("which #{bin} 2> /dev/null") do
Expand All @@ -28,10 +29,26 @@
end
end

# make sure uhttpd is actually stopped
describe port(80) do
it { should_not be_listening }
end

# check for prometheus exporter
describe port(9100) do
it { should be_listening }
end

describe command('rsyslogd -N1') do
its(:exit_status) { should eq 0 }
end

# make sure logger is actually working since we had
# an issue with busybox logger in the past
describe command('logger "serverspec test msg"') do
its(:exit_status) { should eq 0 }
end

describe file('/root/bin/wifi-details.sh') do
it { should exist }
it { should be_mode 750 }
Expand Down
27 changes: 13 additions & 14 deletions tests/unit/openwrt/golden/ar71xx/etc/config/lldpd
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
config lldpd config
option enable_cdp 1
option enable_fdp 1
option enable_sonmp 1
option enable_edp 1
# LLDP frames are link-local frames, do not use any
# network interfaces other than the ones that achieve
# a link with its link partner, and the link partner
# being another networking device. Do not use bridge,
# VLAN, or DSA conduit interfaces.
#
# lldp unable to receive frames on mediatek due to bug
# ref: https://github.com/openwrt/openwrt/issues/13788

option lldp_class 4
# TODO make this mean something
option lldp_location "2:FR:6:Commercial Rd:3:Roseville:19:4"
# lldp will default to listening on all interfaces

# if empty, the distribution description is sent
option lldp_description "OpenWrt System"

# interfaces to listen on
# TODO: This should be dynamic and based on
# yaml config
list interface "eth1"
# Set class of device
option lldp_class 4
# if empty, the distribution description is sent
option lldp_description "OpenWrt System"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config prometheus-node-exporter-lua 'main'
option listen_interface 'mgmt'
option listen_ipv6 '1'
option listen_port '9100'
5 changes: 5 additions & 0 deletions tests/unit/openwrt/golden/ar71xx/etc/rc.local
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
# TODO make this a true service
/root/bin/wifi-details.sh >/dev/null 2>/dev/null </dev/null &

# By default anything install in opkg that includes a service will start out
# of the box. Easiest way to disable services that we depend
# on but dont want to start
/etc/init.d/uhttpd stop; /etc/init.d/uhttpd disabled

# apinger initial template population
# this needs to remain in the case where DHCP isnt working initially
# there is also a race condition with the wifi interfaces coming online
Expand Down
24 changes: 0 additions & 24 deletions tests/unit/openwrt/golden/ar71xx/etc/zabbix_agentd.conf

This file was deleted.

Empty file modified tests/unit/openwrt/golden/ar71xx/root/bin/apinger-pop.sh
100644 → 100755
Empty file.
Empty file modified tests/unit/openwrt/golden/ar71xx/root/bin/config-version.sh
100644 → 100755
Empty file.
Empty file modified tests/unit/openwrt/golden/ar71xx/root/bin/wifi-details.sh
100644 → 100755
Empty file.
10 changes: 5 additions & 5 deletions tests/unit/openwrt/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OPTIONS:
-h Show this message
-o specify output for temporary generated templates
-t Target arch to build
-u Update golden templates
-u Update golden templates (no test)

EXAMPLES:
Run tests for all templates against existing golden files:
Expand Down Expand Up @@ -52,17 +52,17 @@ gen_templates(){
# Export to support ENV datasource
export TARGET=$TARGET
export KEYPATH=$KEYPATH
rm -rf "${1}"
gomplate -d openwrt=../../../facts/secrets/${TARGET}-openwrt-example.yaml -d keys_dir=${KEYPATH} --input-dir=../../../openwrt/files --output-dir="${1}"
if [ -d ../../../openwrt/files-${TARGET} ]; then
gomplate -d openwrt=../../../facts/secrets/${TARGET}-openwrt-example.yaml -d keys_dir=${KEYPATH} --input-dir=../../../openwrt/files-${TARGET} --output-dir="${1}"
fi
}

if [ ${UPDATE} -eq 1 ]; then
rm -rf "golden/${TARGET}"
gen_templates "golden/${TARGET}"
else
gen_templates "$TMPLOC"
diff -u -r "golden/${TARGET}" $TMPLOC/
fi

gen_templates "$TMPLOC"

diff -u -r "golden/${TARGET}" $TMPLOC/