Skip to content

Commit 03561cc

Browse files
committed
priv
1 parent 37942c7 commit 03561cc

File tree

140 files changed

+11616
-1794
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+11616
-1794
lines changed

.docker/Dockerfile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
FROM npeca75/php:84
2+
3+
# ==> Download packages
4+
ARG DEBIAN_FRONTEND=noninteractive
5+
RUN apt-get -y update \
6+
&& apt-get install --no-install-recommends -y acl curl fping graphviz imagemagick mariadb-client mtr-tiny nginx-full nmap sudo snmp snmpd snmptrapd rsyslog tini \
7+
rrdtool rrdcached memcached whois unzip dialog mc iputils-ping net-tools cron locales mailutils git ipmitool \
8+
python3-pip python3-memcache python3.11-venv \
9+
&& curl -sSL https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
10+
&& apt-get clean && apt-get autoclean && apt-get autoremove --purge && update-locale
11+
12+
# COPY . /tmp/
13+
14+
# ===> SYSTEM
15+
RUN mkdir -p /tmp/librenms \
16+
&& mkdir -p /config \
17+
&& mkdir -p /etc/bash_completion.d \
18+
&& mkdir -p /root/.ssh \
19+
&& cd /tmp/librenms \
20+
&& git clone --branch priv https://github.com/Npeca75/librenms.git . \
21+
&& rm -rf .git .github html/plugins/Test html/plugins/Weathermap doc/* tests/* /tmp/*.patch \
22+
&& mv -f /tmp/librenms /opt/ \
23+
&& mkdir -p /opt/librenms/.config/pip \
24+
&& printf "[global]\nbreak-system-packages = true" > /opt/librenms/.config/pip/pip.conf \
25+
&& printf "export PATH=\"$HOME/.local/bin:$PATH\"" > /opt/librenms/.bashrc \
26+
&& printf "export PATH=\"$HOME/.local/bin:$PATH\"" > /opt/librenms/.bash_profile \
27+
&& useradd librenms -d /opt/librenms -M -s /bin/bash \
28+
&& usermod -a -G librenms www-data \
29+
&& chown -R librenms:librenms /opt/librenms \
30+
&& chmod 771 /opt/librenms \
31+
&& sudo -u librenms ./scripts/composer_wrapper.php install --no-dev \
32+
&& sudo -u librenms pip3 install --user -r requirements.txt --break-system-packages \
33+
&& setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/ \
34+
&& setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
35+
36+
# ===> ENV Block
37+
ENV APP_URL=/ \
38+
DB_HOST=0.0.2.18 \
39+
DB_PORT=3306 \
40+
DB_DATABASE=dockernms \
41+
DB_USERNAME=dockernms \
42+
DB_PASSWORD=dockernms \
43+
LIBRENMS_USER=librenms \
44+
APP_KEY=base64:6CaJpkZHwn6asygA4XYFUPVx2WceJilUErR+EnWCnnw= \
45+
NODE_ID=61ec37deb7b95 \
46+
DEF_IP=169.254.255.254 \
47+
HTPASSWD=Monitoring:{SHA}y9YdYTU/SdxKN53tgn311TxPJ28= \
48+
NMS_ROLE=poller
49+
50+
VOLUME /config
51+
MAINTAINER Peca Nesovanovic <[email protected]>
52+
EXPOSE 162/tcp 162/udp 514/tcp 514/udp 18000/tcp
53+
ENTRYPOINT ["tini", "--"]
54+
CMD ["/opt/librenms/.docker/startup.sh"]

.docker/config/Dockerfile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
FROM npeca75/php:84
2+
3+
# ==> Download packages
4+
ARG DEBIAN_FRONTEND=noninteractive
5+
RUN apt-get -y update \
6+
&& apt-get install --no-install-recommends -y acl curl fping graphviz imagemagick mariadb-client mtr-tiny nginx-full nmap sudo snmp snmpd snmptrapd rsyslog tini \
7+
rrdtool rrdcached memcached whois unzip dialog mc iputils-ping net-tools cron locales mailutils git ipmitool \
8+
python3-pip python3-memcache python3.11-venv \
9+
&& curl -sSL https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
10+
&& apt-get clean && apt-get autoclean && apt-get autoremove --purge && update-locale
11+
12+
COPY . /tmp/
13+
14+
# ===> SYSTEM
15+
RUN mkdir -p /tmp/librenms \
16+
&& mkdir -p /config \
17+
&& mkdir -p /etc/bash_completion.d \
18+
&& mkdir -p /root/.ssh \
19+
&& cd /tmp/librenms \
20+
&& git clone --depth=1 https://github.com/librenms/librenms.git . \
21+
&& echo "----- patch 0 -----" \
22+
&& git apply /tmp/0.patch \
23+
&& echo "----- patch 1 -----" \
24+
&& git apply /tmp/1.patch \
25+
&& echo "----- patch end -----" \
26+
&& mv -f /tmp/.docker /tmp/librenms/.docker \
27+
&& rm -rf .git .github html/plugins/Test html/plugins/Weathermap doc/* tests/* /tmp/*.patch \
28+
&& mv -f /tmp/librenms /opt/ \
29+
&& mkdir -p /opt/librenms/.config/pip \
30+
&& printf "[global]\nbreak-system-packages = true" > /opt/librenms/.config/pip/pip.conf \
31+
&& printf "export PATH=\"$HOME/.local/bin:$PATH\"" > /opt/librenms/.bashrc \
32+
&& printf "export PATH=\"$HOME/.local/bin:$PATH\"" > /opt/librenms/.bash_profile \
33+
&& useradd librenms -d /opt/librenms -M -s /bin/bash \
34+
&& usermod -a -G librenms www-data \
35+
&& chown -R librenms:librenms /opt/librenms \
36+
&& chmod 771 /opt/librenms \
37+
&& sudo -u librenms ./scripts/composer_wrapper.php install --no-dev \
38+
&& sudo -u librenms pip3 install --user -r requirements.txt --break-system-packages \
39+
&& setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/ \
40+
&& setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
41+
42+
# ===> ENV Block
43+
ENV APP_URL=/ \
44+
DB_HOST=0.0.2.18 \
45+
DB_PORT=3306 \
46+
DB_DATABASE=dockernms \
47+
DB_USERNAME=dockernms \
48+
DB_PASSWORD=dockernms \
49+
LIBRENMS_USER=librenms \
50+
APP_KEY=base64:6CaJpkZHwn6asygA4XYFUPVx2WceJilUErR+EnWCnnw= \
51+
NODE_ID=61ec37deb7b95 \
52+
DEF_IP=169.254.255.254 \
53+
HTPASSWD=Monitoring:{SHA}y9YdYTU/SdxKN53tgn311TxPJ28= \
54+
NMS_ROLE=poller
55+
56+
VOLUME /config
57+
MAINTAINER Peca Nesovanovic <[email protected]>
58+
EXPOSE 162/tcp 162/udp 514/tcp 514/udp 18000/tcp
59+
ENTRYPOINT ["tini", "--"]
60+
CMD ["/opt/librenms/.docker/startup.sh"]

.docker/config/librenms.cron

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Using this cron file requires an additional user on your system, please see install docs.
2+
3+
33 */6 * * * librenms /opt/librenms/cronic /opt/librenms/discovery-wrapper.py 1
4+
*/5 * * * * librenms /opt/librenms/discovery.php -h new >> /dev/null 2>&1
5+
*/5 * * * * librenms /opt/librenms/cronic /opt/librenms/poller-wrapper.py 10
6+
* * * * * librenms /opt/librenms/alerts.php >> /dev/null 2>&1
7+
*/5 * * * * librenms /opt/librenms/poll-billing.php >> /dev/null 2>&1
8+
01 * * * * librenms /opt/librenms/billing-calculate.php >> /dev/null 2>&1
9+
*/5 * * * * librenms /opt/librenms/check-services.php >> /dev/null 2>&1
10+
19 0 * * * librenms /opt/librenms/daily.sh >> /dev/null 2>&1
11+
* * * * * librenms php /opt/librenms/artisan schedule:run --no-ansi --no-interaction > /dev/null 2>&1

.docker/config/librenms.vhost

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
server {
3+
listen 18000;
4+
listen [::]:18000;
5+
server_name #;
6+
root /opt/librenms/html;
7+
index index.php;
8+
auth_basic "restricted";
9+
auth_basic_user_file /etc/nginx/htpasswd;
10+
11+
charset utf-8;
12+
gzip on;
13+
gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
14+
location / {
15+
try_files $uri $uri/ /index.php?$query_string;
16+
}
17+
location ~ [^/]\.php(/|$) {
18+
fastcgi_pass unix:/run/php-fpm-librenms.sock;
19+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
20+
include fastcgi.conf;
21+
}
22+
location ~ /\.(?!well-known).* {
23+
deny all;
24+
}
25+
}

.docker/config/rsyslog.conf

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# /etc/rsyslog.conf configuration file for rsyslog
2+
#
3+
# For more information install rsyslog-doc and see
4+
# /usr/share/doc/rsyslog-doc/html/configuration/index.html
5+
#
6+
# Default logging rules can be found in /etc/rsyslog.d/50-default.conf
7+
8+
9+
#################
10+
#### MODULES ####
11+
#################
12+
13+
module(load="imuxsock") # provides support for local system logging
14+
#module(load="immark") # provides --MARK-- message capability
15+
16+
# provides UDP syslog reception
17+
module(load="imudp")
18+
input(type="imudp" port="514")
19+
20+
# provides TCP syslog reception
21+
module(load="imtcp")
22+
input(type="imtcp" port="514")
23+
24+
# provides kernel logging support and enable non-kernel klog messages
25+
module(load="imklog" permitnonkernelfacility="on")
26+
27+
#$template remote-incoming-logs, "/var/log/rsyslog/%HOSTNAME%/%PROGRAMNAME%.log"
28+
#*.* ?remote-incoming-logs
29+
30+
###########################
31+
#### GLOBAL DIRECTIVES ####
32+
###########################
33+
34+
#
35+
# Use traditional timestamp format.
36+
# To enable high precision timestamps, comment out the following line.
37+
#
38+
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
39+
40+
# Filter duplicated messages
41+
$RepeatedMsgReduction on
42+
43+
#
44+
# Set the default permissions for all log files.
45+
#
46+
$FileOwner root
47+
$FileGroup root
48+
$FileCreateMode 0640
49+
$DirCreateMode 0755
50+
$Umask 0022
51+
$PrivDropToUser root
52+
$PrivDropToGroup root
53+
54+
#
55+
# Where to place spool and state files
56+
#
57+
$WorkDirectory /var/spool/rsyslog
58+
59+
################
60+
### LibreNMS ###
61+
################
62+
63+
module(load="omprog")
64+
65+
template(name="jetstream"
66+
type="string"
67+
string= "%fromhost%||%syslogfacility%||%syslogpriority%||%syslogseverity%||%msg:F,32:3%||%$year%-%$month%-%$day% %timegenerated:8:25%||%msg:R,ERE,4,FIELD:(\\s)([0-9][0-9][0-9][0-9][0-9])(\\s)(.+)--end%||tp-link\n")
68+
69+
template(name="librenms"
70+
type="string"
71+
string= "%HOSTNAME%||%syslogfacility%||%syslogpriority%||%syslogseverity%||%syslogtag%||%$year%-%$month%-%$day% %timegenerated:8:25%||%msg%||%programname%\n")
72+
73+
if re_match($hostname, '^[0-9]+\\-[0-9]+\\-[0-9]+') then {
74+
action(type="omprog"
75+
binary="/opt/librenms/syslog.php"
76+
template="jetstream")
77+
& stop
78+
} else {
79+
action(type="omprog"
80+
binary="/opt/librenms/syslog.php"
81+
template="librenms")
82+
& stop
83+
}
84+
#
85+
# Include all config files in /etc/rsyslog.d/
86+
#
87+
#$IncludeConfig /etc/rsyslog.d/*.conf

.docker/config/snmpd.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
rocommunity public 127.0.0.1
2+
3+
extend distro /opt/librenms/Docker/agents/distro
4+
extend hardware "/bin/cat /sys/devices/virtual/dmi/id/product_name"
5+
extend manufacturer "/bin/cat /sys/devices/virtual/dmi/id/sys_vendor"

.docker/config/snmptrapd.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
snmpTrapdAddr udp:162,udp6:162
2+
disableAuthorization yes
3+
authCommunity log,execute,net public
4+
traphandle default /opt/librenms/.docker/prgs/trap.sh

.docker/prgs/agents/distro

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/usr/bin/env bash
2+
# Detects which OS and if it is Linux then it will detect which Linux Distribution.
3+
4+
OS=$(uname -s)
5+
REV=$(uname -r)
6+
MACH=$(uname -m)
7+
8+
if [ "${OS}" = "SunOS" ] ; then
9+
OS=Solaris
10+
ARCH=$(uname -p)
11+
OSSTR="${OS} ${REV}(${ARCH} $(uname -v))"
12+
13+
elif [ "${OS}" = "AIX" ] ; then
14+
OSSTR="${OS} `oslevel` ($(oslevel -r))"
15+
16+
elif [ "${OS}" = "Linux" ] ; then
17+
KERNEL=$(uname -r)
18+
19+
if [ -f /etc/fedora-release ]; then
20+
DIST=$(cat /etc/fedora-release | awk '{print $1}')
21+
REV=`cat /etc/fedora-release | sed s/.*release\ // | sed s/\ .*//`
22+
23+
elif [ -f /etc/redhat-release ] ; then
24+
DIST=$(cat /etc/redhat-release | awk '{print $1}')
25+
if [ "${DIST}" = "CentOS" ]; then
26+
DIST="CentOS"
27+
IGNORE_OS_RELEASE=1 # https://bugs.centos.org/view.php?id=8359
28+
elif [ "${DIST}" = "CloudLinux" ]; then
29+
DIST="CloudLinux"
30+
elif [ "${DIST}" = "Mandriva" ]; then
31+
DIST="Mandriva"
32+
PSEUDONAME=`cat /etc/mandriva-release | sed s/.*\(// | sed s/\)//`
33+
REV=`cat /etc/mandriva-release | sed s/.*release\ // | sed s/\ .*//`
34+
elif [ -f /etc/oracle-release ]; then
35+
DIST="Oracle"
36+
elif [ -f /etc/rockstor-release ]; then
37+
DIST="Rockstor"
38+
else
39+
DIST="RedHat"
40+
fi
41+
42+
PSEUDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
43+
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
44+
45+
elif [ -f /etc/mandrake-release ] ; then
46+
DIST='Mandrake'
47+
PSEUDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
48+
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
49+
50+
elif [ -f /etc/devuan_version ] ; then
51+
DIST="Devuan `cat /etc/devuan_version`"
52+
REV=""
53+
54+
elif [ -f /etc/debian_version ] ; then
55+
DIST="Debian `cat /etc/debian_version`"
56+
REV=""
57+
if [ -f /usr/bin/lsb_release ] ; then
58+
ID=`lsb_release -i | awk -F ':' '{print $2}' | sed 's/ //g'`
59+
fi
60+
if [ "${ID}" = "Raspbian" ] ; then
61+
DIST="Raspbian `cat /etc/debian_version`"
62+
fi
63+
if [ -f /usr/bin/pveversion ]; then
64+
DIST="${DIST}/PVE `/usr/bin/pveversion | cut -d '/' -f 2`"
65+
fi
66+
67+
elif [ -f /etc/gentoo-release ] ; then
68+
DIST="Gentoo"
69+
REV=$(tr -d '[[:alpha:]]' </etc/gentoo-release | tr -d " ")
70+
71+
elif [ -f /etc/arch-release ] ; then
72+
DIST="Arch Linux"
73+
REV="" # Omit version since Arch Linux uses rolling releases
74+
IGNORE_LSB=1 # /etc/lsb-release would overwrite $REV with "rolling"
75+
76+
elif [ -f /etc/photon-release ] ; then
77+
DIST=$(head -1 < /etc/photon-release)
78+
REV=$(sed -n -e 's/^.*PHOTON_BUILD_NUMBER=//p' /etc/photon-release)
79+
IGNORE_LSB=1 # photon os does not have /etc/lsb-release nor lsb_release
80+
81+
elif [ -f /etc/openwrt_version ] ; then
82+
DIST="OpenWrt"
83+
REV=$(cat /etc/openwrt_version)
84+
85+
elif [ -f /etc/pld-release ] ; then
86+
DIST=$(cat /etc/pld-release)
87+
REV=""
88+
89+
elif [ -f /etc/SuSE-release ] ; then
90+
DIST=$(echo SLES $(grep VERSION /etc/SuSE-release | cut -d = -f 2 | tr -d " "))
91+
REV=$(echo SP$(grep PATCHLEVEL /etc/SuSE-release | cut -d = -f 2 | tr -d " "))
92+
fi
93+
94+
if [ -x "$(command -v awk)" ]; then # some distros do not ship with awk
95+
if [ "`uname -a | awk '{print $(NF)}'`" = "DD-WRT" ] ; then
96+
DIST="dd-wrt"
97+
fi
98+
if [ "`uname -a | awk '{print $(NF)}'`" = "ASUSWRT-Merlin" ] ; then
99+
DIST="ASUSWRT-Merlin"
100+
REV=`nvram show | grep buildno= | egrep -o '[0-9].[0-9].[0-9]'` > /dev/null 2>&1
101+
fi
102+
fi
103+
104+
# try standardized os version methods
105+
if [ -f /etc/os-release -a "${IGNORE_OS_RELEASE}" != 1 ] ; then
106+
source /etc/os-release
107+
STD_DIST="$NAME"
108+
STD_REV="$VERSION_ID"
109+
elif [ -f /etc/lsb-release -a "${IGNORE_LSB}" != 1 ] ; then
110+
STD_DIST=$(lsb_release -si)
111+
STD_REV=$(lsb_release -sr)
112+
fi
113+
if [ -n "${STD_DIST}" ]; then
114+
DIST="${STD_DIST}"
115+
fi
116+
if [ -n "${STD_REV}" ]; then
117+
REV="${STD_REV}"
118+
fi
119+
120+
if [ -n "${REV}" ]; then
121+
OSSTR="${DIST} ${REV}"
122+
else
123+
OSSTR="${DIST}"
124+
fi
125+
126+
elif [ "${OS}" = "Darwin" ] ; then
127+
if [ -f /usr/bin/sw_vers ] ; then
128+
OSSTR=`/usr/bin/sw_vers|grep -v Build|sed 's/^.*:.//'| tr "\n" ' '`
129+
fi
130+
131+
elif [ "${OS}" = "FreeBSD" ] ; then
132+
DIST=$(cat /etc/version | cut -d'-' -f 1)
133+
if [ "${DIST}" = "FreeNAS" ]; then
134+
OSSTR=`cat /etc/version | cut -d' ' -f 1`
135+
else
136+
OSSTR=`/usr/bin/uname -mior`
137+
fi
138+
fi
139+
140+
echo ${OSSTR}

0 commit comments

Comments
 (0)