added webui

This commit is contained in:
2021-01-08 14:45:26 +01:00
parent 02ba334032
commit cedf566f74
6 changed files with 22 additions and 13 deletions

View File

@@ -65,7 +65,6 @@ dist_ver=$(grep --color=never -Po "^VERSION_ID=\K.*" "/etc/os-release")
dist=$(grep --color=never -Po "^ID=\K.*" "/etc/os-release")
if [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"18.04"* ]]; then
echo "Ubuntu 18.04 Detected"
PKGM="$APTMODE"
PKGUC="$PKGM update"
PKGUP="$PKGM upgrade -y"
@@ -73,7 +72,6 @@ if [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"18.04"* ]]; then
PKGLIST="apt"
shortdist=ubu1804
elif [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"20.04"* ]]; then
echo "Ubuntu 20.04 Detected"
PKGM="$APTMODE"
PKGUC="$PKGM update"
PKGUP="$PKGM upgrade -y"
@@ -81,7 +79,6 @@ PKGUC="$PKGM update"
PKGLIST="apt"
shortdist=ubu2004
elif [[ "${dist}" == *"debian"* ]] && [[ "${dist_ver}" == *"10"* ]]; then
echo "Debian 10 Detected"
PKGM="$APTMODE"
PKGUC="$PKGM update"
PKGUP="$PKGM upgrade -y"
@@ -89,7 +86,6 @@ elif [[ "${dist}" == *"debian"* ]] && [[ "${dist_ver}" == *"10"* ]]; then
PKGLIST="apt"
shortdist=deb10
elif [[ "${dist}" == *"centos"* ]] && [[ "${dist_ver}" == *"8"* ]]; then
echo "Centos 8 Detected"
PKGM="dnf"
PKGUC="$PKGM check-update --refresh"
PKGUP="$PKGM update -y"
@@ -97,7 +93,7 @@ elif [[ "${dist}" == *"centos"* ]] && [[ "${dist_ver}" == *"8"* ]]; then
PKGLIST="dnf"
shortdist=el8
else
echo "This os in not supported"
echo "This os in not (yet) supported"
exit
fi

View File

@@ -1,6 +1,8 @@
mrepo=https://git.ictmaatwerk.com/VPS-scripts/Monit
mbranch=main
mkdir /var/run/monit
if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] ; then
monitconf=/etc/monit/monitrc
@@ -22,11 +24,18 @@ elif [ "$shortdist" = "el8" ]; then
monitPhpSock=/var/opt/remi/php"${phpver//.}"/run/php-fpm/www.sock
monitPhpPid=/var/opt/remi/php"${phpver//.}"/run/php-fpm/php-fpm.pid
monitPhpPro=php-fpm
semanage fcontext -at httpd_sys_rw_content_t "/var/run/monit/.*)?"
restorecon -R -v "/var/run/monit"
fi
systemctl stop monit
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/conf/monit/monitrc -o $monitconf
curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/conf/monit/monitwebsocket -o /conf/monit/websocket
touch /opt/MonitNotify.sh
chmod +x /opt/MonitNotify.sh
if [ ! -d "/var/lib/monit" ] ; then mkdir -p /var/lib/monit; fi
mkdir -p /etc/monit/conf.d

View File

@@ -9,10 +9,5 @@ set eventqueue
basedir /var/lib/monit/events # set the base directory where events will be stored
slots 100 # optionally limit the queue size
#WEBUIset httpd port 2812 and
#WEBUIallow admin:monit # require user 'admin' with password 'monit'
#WEBUI#use address localhost # only accept connection from localhost (drop if you use M/Monit)
#WEBUI#allow localhost # allow localhost to connect to the server and
include /etc/monit/conf.d/*
include /etc/monit/websocket #enables/disables monit-websocket

View File

@@ -0,0 +1,9 @@
#Set-up monit webui as unixsocket
set httpd unixsocker /var/run/monit/monit.sock
uid www-data
signature disable
allow admin:monit
#Set-up monit webui on port 2812
##set httpd port 2812 and
##allow admin:monit

View File

@@ -18,7 +18,7 @@ check system $HOST
else if recovered then exec "/opt/MonitNotify.sh 'SYS-OK: CPU(sys) threshold'"
if cpu usage (wait) > 80% for 4 cycles then exec"/opt/MonitNotify.sh 'SYS-WARN: CPU(wait) threshold'"
else if recovered then exec "/opt/MonitNotify.sh 'SYS-OK: CPU(wait) threshold'"
if cpu usage > 200% for 4 cycles then exec "/opt/MonitNotify.sh "/opt/MonitNotify.sh 'SYS-WARN: CPU threshold'"
if cpu usage > 200% for 4 cycles then exec "/opt/MonitNotify.sh /opt/MonitNotify.sh 'SYS-WARN: CPU threshold'"
else if recovered then exec "/opt/MonitNotify.sh 'SYS-OK: CPU threshold'"
#Disk