From cedf566f747072741a029bdb79856f210903cbe8 Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Fri, 8 Jan 2021 14:45:26 +0100 Subject: [PATCH] added webui --- InstallMonitModule.sh | 6 +----- conf.sh | 9 +++++++++ conf/monit/monitrc | 9 ++------- conf/monit/monitwebsocket | 9 +++++++++ conf/{ => monit}/php-fpm.conf | 0 conf/monit/system.conf | 2 +- 6 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 conf/monit/monitwebsocket rename conf/{ => monit}/php-fpm.conf (100%) diff --git a/InstallMonitModule.sh b/InstallMonitModule.sh index c7bd80d..eb35624 100644 --- a/InstallMonitModule.sh +++ b/InstallMonitModule.sh @@ -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 diff --git a/conf.sh b/conf.sh index 7e9461e..48bfc98 100644 --- a/conf.sh +++ b/conf.sh @@ -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 diff --git a/conf/monit/monitrc b/conf/monit/monitrc index c434898..eb32b93 100644 --- a/conf/monit/monitrc +++ b/conf/monit/monitrc @@ -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/conf.d/* +include /etc/monit/websocket #enables/disables monit-websocket \ No newline at end of file diff --git a/conf/monit/monitwebsocket b/conf/monit/monitwebsocket new file mode 100644 index 0000000..e19c49c --- /dev/null +++ b/conf/monit/monitwebsocket @@ -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 \ No newline at end of file diff --git a/conf/php-fpm.conf b/conf/monit/php-fpm.conf similarity index 100% rename from conf/php-fpm.conf rename to conf/monit/php-fpm.conf diff --git a/conf/monit/system.conf b/conf/monit/system.conf index 0e659a1..c34969e 100644 --- a/conf/monit/system.conf +++ b/conf/monit/system.conf @@ -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