added webui
This commit is contained in:
@@ -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")
|
dist=$(grep --color=never -Po "^ID=\K.*" "/etc/os-release")
|
||||||
|
|
||||||
if [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"18.04"* ]]; then
|
if [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"18.04"* ]]; then
|
||||||
echo "Ubuntu 18.04 Detected"
|
|
||||||
PKGM="$APTMODE"
|
PKGM="$APTMODE"
|
||||||
PKGUC="$PKGM update"
|
PKGUC="$PKGM update"
|
||||||
PKGUP="$PKGM upgrade -y"
|
PKGUP="$PKGM upgrade -y"
|
||||||
@@ -73,7 +72,6 @@ if [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"18.04"* ]]; then
|
|||||||
PKGLIST="apt"
|
PKGLIST="apt"
|
||||||
shortdist=ubu1804
|
shortdist=ubu1804
|
||||||
elif [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"20.04"* ]]; then
|
elif [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"20.04"* ]]; then
|
||||||
echo "Ubuntu 20.04 Detected"
|
|
||||||
PKGM="$APTMODE"
|
PKGM="$APTMODE"
|
||||||
PKGUC="$PKGM update"
|
PKGUC="$PKGM update"
|
||||||
PKGUP="$PKGM upgrade -y"
|
PKGUP="$PKGM upgrade -y"
|
||||||
@@ -81,7 +79,6 @@ PKGUC="$PKGM update"
|
|||||||
PKGLIST="apt"
|
PKGLIST="apt"
|
||||||
shortdist=ubu2004
|
shortdist=ubu2004
|
||||||
elif [[ "${dist}" == *"debian"* ]] && [[ "${dist_ver}" == *"10"* ]]; then
|
elif [[ "${dist}" == *"debian"* ]] && [[ "${dist_ver}" == *"10"* ]]; then
|
||||||
echo "Debian 10 Detected"
|
|
||||||
PKGM="$APTMODE"
|
PKGM="$APTMODE"
|
||||||
PKGUC="$PKGM update"
|
PKGUC="$PKGM update"
|
||||||
PKGUP="$PKGM upgrade -y"
|
PKGUP="$PKGM upgrade -y"
|
||||||
@@ -89,7 +86,6 @@ elif [[ "${dist}" == *"debian"* ]] && [[ "${dist_ver}" == *"10"* ]]; then
|
|||||||
PKGLIST="apt"
|
PKGLIST="apt"
|
||||||
shortdist=deb10
|
shortdist=deb10
|
||||||
elif [[ "${dist}" == *"centos"* ]] && [[ "${dist_ver}" == *"8"* ]]; then
|
elif [[ "${dist}" == *"centos"* ]] && [[ "${dist_ver}" == *"8"* ]]; then
|
||||||
echo "Centos 8 Detected"
|
|
||||||
PKGM="dnf"
|
PKGM="dnf"
|
||||||
PKGUC="$PKGM check-update --refresh"
|
PKGUC="$PKGM check-update --refresh"
|
||||||
PKGUP="$PKGM update -y"
|
PKGUP="$PKGM update -y"
|
||||||
@@ -97,7 +93,7 @@ elif [[ "${dist}" == *"centos"* ]] && [[ "${dist_ver}" == *"8"* ]]; then
|
|||||||
PKGLIST="dnf"
|
PKGLIST="dnf"
|
||||||
shortdist=el8
|
shortdist=el8
|
||||||
else
|
else
|
||||||
echo "This os in not supported"
|
echo "This os in not (yet) supported"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
9
conf.sh
9
conf.sh
@@ -1,6 +1,8 @@
|
|||||||
mrepo=https://git.ictmaatwerk.com/VPS-scripts/Monit
|
mrepo=https://git.ictmaatwerk.com/VPS-scripts/Monit
|
||||||
mbranch=main
|
mbranch=main
|
||||||
|
|
||||||
|
mkdir /var/run/monit
|
||||||
|
|
||||||
if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] ; then
|
if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] ; then
|
||||||
monitconf=/etc/monit/monitrc
|
monitconf=/etc/monit/monitrc
|
||||||
|
|
||||||
@@ -22,11 +24,18 @@ elif [ "$shortdist" = "el8" ]; then
|
|||||||
monitPhpSock=/var/opt/remi/php"${phpver//.}"/run/php-fpm/www.sock
|
monitPhpSock=/var/opt/remi/php"${phpver//.}"/run/php-fpm/www.sock
|
||||||
monitPhpPid=/var/opt/remi/php"${phpver//.}"/run/php-fpm/php-fpm.pid
|
monitPhpPid=/var/opt/remi/php"${phpver//.}"/run/php-fpm/php-fpm.pid
|
||||||
monitPhpPro=php-fpm
|
monitPhpPro=php-fpm
|
||||||
|
|
||||||
|
|
||||||
|
semanage fcontext -at httpd_sys_rw_content_t "/var/run/monit/.*)?"
|
||||||
|
restorecon -R -v "/var/run/monit"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
systemctl stop monit
|
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/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
|
if [ ! -d "/var/lib/monit" ] ; then mkdir -p /var/lib/monit; fi
|
||||||
mkdir -p /etc/monit/conf.d
|
mkdir -p /etc/monit/conf.d
|
||||||
|
|||||||
@@ -9,10 +9,5 @@ set eventqueue
|
|||||||
basedir /var/lib/monit/events # set the base directory where events will be stored
|
basedir /var/lib/monit/events # set the base directory where events will be stored
|
||||||
slots 100 # optionally limit the queue size
|
slots 100 # optionally limit the queue size
|
||||||
|
|
||||||
#WEBUIset httpd port 2812 and
|
include /etc/monit/conf.d/*
|
||||||
#WEBUIallow admin:monit # require user 'admin' with password 'monit'
|
include /etc/monit/websocket #enables/disables monit-websocket
|
||||||
#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/*
|
|
||||||
9
conf/monit/monitwebsocket
Normal file
9
conf/monit/monitwebsocket
Normal 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
|
||||||
@@ -18,7 +18,7 @@ check system $HOST
|
|||||||
else if recovered then exec "/opt/MonitNotify.sh 'SYS-OK: CPU(sys) threshold'"
|
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'"
|
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'"
|
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'"
|
else if recovered then exec "/opt/MonitNotify.sh 'SYS-OK: CPU threshold'"
|
||||||
|
|
||||||
#Disk
|
#Disk
|
||||||
|
|||||||
Reference in New Issue
Block a user