Установка Monitorix в Alpine Linux
2020-04-14
Подготовка
Скачиваем, и распаковываем куда-нибудь, актуальную версию monitorix:
$ wget https://www.monitorix.org/monitorix-3.12.0.tar.gz
$ tar xvf monitorix-3.12.0.tar.gz
Содержимое распакованного каталога раскидываем по папкам. Схема размещения приведена ниже:
Перед раскидыванием файлов мониторикса по соответствующим каталогам, зададим им правильного владельца:
# cd monitorix-3.12.0 && chown root:root * -R
Добавление в систему необходимых пакетов
Установка perl-пакетов, необходимых для работы monitorix:
# apk add perl perl-cgi perl-libwww perl-mailtools perl-mime-lite perl-dbi perl-xml-simple perl-xml-libxml perl-http-server-simple perl-io-socket-ssl rrdtool perl-rrd
Пакет perl-config-general отсутствует в репозиториях Alpine Linux, поэтому скачал General.pm из metacpan.org в каталог /usr/share/perl5/vendor_perl/Config
:
# mkdir -p /usr/share/perl5/vendor_perl/Config/
# wget -O /usr/share/perl5/vendor_perl/Config/General.pm https://metacpan.org/release/Bundle-PBib/source/lib/Config/General.pm?raw=1
Необходимо установит шрифт ttf-dejavu, ttf-freefont или font-noto, иначе вместо символов, на графиках будут видны квадраты.
# apk add ttf-dejavu
Включение автозапуска
Готовый скрипт для openrc взял из генту https://gitweb.gentoo.org/repo/gentoo.git/tree/www-misc/monitorix/files/monitorix
слегка подредактировав строку command=/usr/sbin/monitorix
:
#!/sbin/openrc-run
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
name="Monitorix"
description="Monitorix is a lightweight system monitoring tool"
command=/usr/bin/monitorix
command_args="-c /etc/monitorix/monitorix.conf -p /var/run/$name.pid"
pidfile=/var/run/monitorix.pid
checkconfig() {
if [[ ! -e /etc/monitorix/monitorix.conf ]]; then
eerror "Please check that the configuration file exists."
return 1
fi
}
start() {
checkconfig || return 1
ebegin "Starting $name"
start-stop-daemon --start --name $name --pidfile /var/run/$name.pid --exec $command -- $command_args
eend $?
}
stop() {
ebegin "Stopping $name"
start-stop-daemon --stop --pidfile /var/run/$name.pid
eend $?
}
Добавляем в автозагрузку:
# rc-update add monitorix default
Замечено
Users using the system (user.pm)
В musl нет реализации wtmp, utmp, lastlog. По этой причине модуль user.pm
не работает.
Process statistics (process.pm)
Для правильно отображения Process statistics, добавляем полноценную версию утилиты ps
, вместо встроенной в busybox:
# apk add procps
Netstat statistics (netstat.pm)
Требует установки утилиты ss
или некастрированной netstat
(вместо кастрированной из busybox, которая присутствует в Alpine Linux по умолчанию):
apk add net-tools