Skip to content

Instantly share code, notes, and snippets.

@c0m4r
Last active September 29, 2024 23:35
Show Gist options
  • Save c0m4r/6c814d42bfa01b120370e34d20912b81 to your computer and use it in GitHub Desktop.
Save c0m4r/6c814d42bfa01b120370e34d20912b81 to your computer and use it in GitHub Desktop.
Observium on Alpine Linux

Observium on Alpine Linux

WARNING: It's a draft. It doesn't cover security, permissions and other stuff.

Tested on Alpine Linux v3.20 / Observium CE 24.4

Installation

Derived from https://docs.observium.org/install_debian/

Alpine packages

apk add php82-cli php82-mysqli php82-pecl-mcrypt php82-ctype php82-gd php82-bcmath php82-mbstring php82-opcache php82-apcu php82-curl php82-fpm php82-pear php82-snmp php82-session php82-apache2
apk add net-snmp net-snmp-tools fping rrdtool subversion whois mtr ipmitool graphviz imagemagick
apk add apache2
apk add mariadb mariadb-client py3-pymysql

MariaDB

https://docs.observium.org/install_debian/#create-the-mysql-database-and-user

rc-update add mariadb
/etc/init.d/mariadb setup
rc-service mariadb start
mariadb
#> CREATE DATABASE observium DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
#> CREATE USER 'observium'@'localhost' identified by '<db password>';
#> GRANT ALL ON observium.* TO 'observium'@'localhost';

Edit /etc/my.cnf.d/mariadb-server.cnf: set bind-address=127.0.0.1 and comment out skip-networking

SNMP daemon

rc-update add snmpd
sed -i 's/#rocommunity public/rocommunity public/g;' /etc/snmp/snmpd.conf
# replace agentAddress  udp:127.0.0.1:161 with udp:161,udp6:[::1]:161 for ipv6 support
rc-service snmpd start

Observium

mkdir -p /opt/observium && cd /opt
wget http://www.observium.org/observium-community-latest.tar.gz
tar zxvf observium-community-latest.tar.gz
cd observium
cp config.php.default config.php
# edit config.php and change db user/pass
./discovery.php -u
mkdir logs rrd
./adduser.php admin password 10
ln -s /usr/sbin/fping /usr/bin/fping
./add_device.php localhost public v2c
./discovery.php -h all
./poller.php -h all

Apache + PHP

https://docs.observium.org/install_debian/#apache-configuration

rc-update add apache2
cat <<EOF > /etc/apache2/conf.d/observium.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /opt/observium/html
    <FilesMatch \.php$>
      SetHandler application/x-httpd-php
    </FilesMatch>
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /opt/observium/html/>
            DirectoryIndex index.php
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted
    </Directory>
    ErrorLog  /var/log/apache2/error.log
    LogLevel warn
    CustomLog  /var/log/apache2/access.log combined
    ServerSignature On
</VirtualHost>
EOF
rc-service apache2 start

Cron

33 */6 * * * /opt/observium/observium-wrapper discovery >> /dev/null 2>&1
*/5 * * * * /opt/observium/observium-wrapper discovery --host new >> /dev/null 2>&1
*/5 * * * * /opt/observium/observium-wrapper poller >> /dev/null 2>&1
13 5 * * * /opt/observium/housekeeping.php -ysel >> /dev/null 2>&1
47 4 * * * /opt/observium/housekeeping.php -yrptb >> /dev/null 2>&1

nginx considerations

I was hoping for nginx instead of apache2, but Observium heavily relies on htaccess, which is pain in the ass to convert into nginx configuration so for now it is what it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment