NEW: moved observium to rocky

This commit is contained in:
xpk 2022-04-07 15:01:34 +08:00
parent 25dfa849e9
commit 3e2016d6f2
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
11 changed files with 158 additions and 0 deletions

5
alpine/ping/Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM alpine:latest
LABEL description="ping test on alpine"
LABEL maintainer="racken@one27.cf"
ENV container docker
CMD ["ping", "-qi5", "210.0.248.38"]

View File

@ -0,0 +1,2 @@
app.data/
app.data.tgz

View File

@ -0,0 +1,29 @@
FROM rockylinux/rockylinux
LABEL description="Observium 19.8.10000 on RockyLinux"
LABEL maintainer="xpk@headdesk.me"
LABEL notes="Initial user/pass = observium/observium. Mount /opt/observium and /var/lib/mysql on persistent storage."
LABEL exposed-port="80"
ENV container docker
RUN dnf -y install epel-release
RUN dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
RUN dnf module enable php:remi-8.1 -y
# RUN dnf -y install http://yum.opennms.org/repofiles/opennms-repo-stable-rhel7.noarch.rpm
#RUN dnf -y install wget httpd php php-opcache php-mysqlnd php-gd php-posix php-pear cronie net-snmp net-snmp-utils fping mariadb rrdtool ipmitool graphviz ImageMagick php-json python3-PyMySQL libsodium libsodium-devel php-devel make supervisor --nobest
RUN dnf -y install wget httpd php php-opcache php-mysqlnd php-gd php-sodium php-posix php-pear cronie net-snmp net-snmp-utils fping mariadb rrdtool ipmitool graphviz ImageMagick php-json python3-PyMySQL libsodium php-devel supervisor --nobest
#RUN mysql_install_db -u mysql
#RUN pecl install libsodium; echo "extension=sodium.so" > /etc/php.d/sodium.ini
RUN ln -s /usr/bin/python3 /usr/bin/python; mkdir -p /opt/observium /run/supervisor /run/php-fpm
WORKDIR /opt/observium
# RUN wget -qq -O- http://www.observium.org/observium-community-latest.tar.gz | tar zxf - --strip-components=1
# for upgrade, see upgrade.md
COPY config.php /opt/observium/config.php
COPY observium.ini /etc/supervisord.d/observium.ini
COPY crontab /var/spool/cron/root
#RUN mkdir -p /opt/observium/rrd /opt/observium/logs; chown apache:apache /opt/observium/{rrd,logs}
RUN sed -i -e 's@/var/www/html@/opt/observium/html@g' -e 's/AllowOverride.*/AllowOverride All/g' /etc/httpd/conf/httpd.conf
#ADD initialise.sh /opt/observium/initialise.sh
#RUN chmod 755 /opt/observium/initialise.sh && /opt/observium/initialise.sh
# Add static route
# RUN ip route add 192.168.167.0/24 via 192.168.86.2
EXPOSE 80
CMD ["/usr/bin/supervisord", "-n"]

View File

@ -0,0 +1,25 @@
FROM centos:8
LABEL description="Observium 19.8.10000 on CentOS8"
LABEL maintainer="xpk@headdesk.me"
LABEL notes="Initial user/pass = observium/observium. Mount /opt/observium and /var/lib/mysql on persistent storage."
LABEL exposed-port="80"
LABEL git="https://xpk.headdesk.me/git/centos8-observium"
ENV container docker
RUN yum -y install epel-release
RUN yum -y install http://yum.opennms.org/repofiles/opennms-repo-stable-rhel7.noarch.rpm
RUN yum -y install wget httpd php php-opcache php-mysqlnd php-gd php-posix php-pear cronie net-snmp net-snmp-utils fping mariadb-server mariadb rrdtool ipmitool graphviz ImageMagick php-json python3-PyMySQL libsodium libsodium-devel php-devel make supervisor --nobest
RUN mysql_install_db -u mysql
RUN pecl install libsodium; echo "extension=sodium.so" > /etc/php.d/sodium.ini
RUN ln -s /usr/bin/python3 /usr/bin/python; mkdir -p /opt/observium /run/supervisor /run/php-fpm
WORKDIR /opt/observium
RUN wget -qq -O- http://www.observium.org/observium-community-latest.tar.gz | tar zxf - --strip-components=1
COPY config.php /opt/observium/config.php
COPY observium.ini /etc/supervisord.d/observium.ini
COPY crontab /var/spool/cron/root
RUN mkdir -p /opt/observium/rrd /opt/observium/logs; chown apache:apache /opt/observium/{rrd,logs}
RUN sed -i -e 's@/var/www/html@/opt/observium/html@g' /etc/httpd/conf/httpd.conf
RUN sed -i -e 's/AllowOverride.*/AllowOverride All/g' /etc/httpd/conf/httpd.conf
ADD initialise.sh /opt/observium/initialise.sh
RUN chmod 755 /opt/observium/initialise.sh && /opt/observium/initialise.sh
EXPOSE 80
CMD ["/usr/bin/supervisord", "-n"]

1
rocky/observium/build.sh Executable file
View File

@ -0,0 +1 @@
docker build -t rocky/observium --network macvlan .

View File

@ -0,0 +1,37 @@
<?php
## Check http://www.observium.org/docs/config_options/ for documentation of possible settings
## It's recommended that settings are edited in the web interface at /settings/ on your observium installation.
## Authentication and Database settings must be hardcoded here because they need to work before you can reach the web-based configuration interface
// Database config --- This MUST be configured
$config['db_extension'] = 'mysqli';
$config['db_host'] = '192.168.86.10';
$config['db_user'] = 'observium';
$config['db_pass'] = '25d38c2b7ffa43d94621b578';
$config['db_name'] = 'observium';
// Base directory
#$config['install_dir'] = "/opt/observium";
// Default community list to use when adding/discovering
$config['snmp']['community'] = array("public");
// Authentication Model
$config['auth_mechanism'] = "mysql"; // default, other options: ldap, http-auth, please see documentation for config help
// Enable alerter
// $config['poller-wrapper']['alerter'] = TRUE;
//$config['web_show_disabled'] = FALSE; // Show or not disabled devices on major pages.
// Set up a default alerter (email to a single address)
//$config['email']['default'] = "user@your-domain";
//$config['email']['from'] = "Observium <observium@your-domain>";
//$config['email']['default_only'] = TRUE;
// End config.php
$config['fping'] = "/usr/sbin/fping";
$config['housekeeping']['rrd']['age'] = 5184000;

14
rocky/observium/crontab Normal file
View File

@ -0,0 +1,14 @@
# Run a complete discovery of all devices once every 6 hours
33 */6 * * * /opt/observium/discovery.php -h all >> /dev/null 2>&1
# Run automated discovery of newly added devices every 3 minutes
*/3 * * * * /opt/observium/discovery.php -h new >> /dev/null 2>&1
# Run multithreaded poller wrapper every 5 minutes
*/5 * * * * /opt/observium/poller-wrapper.py >> /dev/null 2>&1
# Run housekeeping script daily for syslog, eventlog and alert log
13 5 * * * /opt/observium/housekeeping.php -ysel
# Run housekeeping script daily for rrds, ports, orphaned entries in the database and performance data
47 4 * * * /opt/observium/housekeeping.php -yrptb

View File

@ -0,0 +1,8 @@
/usr/bin/pidproxy /run/mariadb/mariadb.pid /usr/bin/mysqld_safe --pid-file=/run/mariadb/mariadb.pid &
mysql -Nse 'create database observium default charset utf8 collate utf8_general_ci;'
mysql -Nse "create user observium@localhost identified by '25d38c2b7ffa43d94621b578';"
mysql -Nse 'grant all on observium.* to observium@localhost;'
mysql -Nse 'flush privileges;'
cd /opt/observium
./discovery.php -u
./adduser.php observium observium 10

View File

@ -0,0 +1,29 @@
[program:httpd]
command=/usr/sbin/apachectl -DFOREGROUND
autostart=true
autorestart=true
killasgroup=true
stopasgroup=true
[program:phpfpm]
command=/usr/sbin/php-fpm -c /etc/php-fpm.conf -F
autostart=true
autorestart=true
#[program:mysql]
#command=/usr/bin/pidproxy /run/mariadb/mariadb.pid /usr/bin/mysqld_safe --pid-file=/run/mariadb/mariadb.pid
#autostart=true
#autorestart=true
[program:crond]
command=/usr/sbin/crond -nsp
autostart=true
autorestart=true
[program:staticroute]
command=/sbin/ip r a 192.168.167.0/24 via 192.168.86.2
autostart=true
autorestart=false
startretries=1
startsecs = 0

5
rocky/observium/start.sh Executable file
View File

@ -0,0 +1,5 @@
docker run -d --name observium --network macvlan --ip=192.168.86.57 \
--cap-add NET_ADMIN --cpus=2 \
-v /my/container-config/centos8/observium/app.data:/opt/observium \
-e TZ=Asia/Hong_Kong \
--restart=always rocky/observium

View File

@ -0,0 +1,3 @@
# attach to container
cd /opt/observium
wget -qq -O- http://www.observium.org/observium-community-latest.tar.gz | tar zxf - --strip-components=1