Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mailinabox
Commits
59f8aa1c
Commit
59f8aa1c
authored
Nov 01, 2015
by
Michael Kroes
Committed by
yodax
Nov 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add checks to the management interface to report memory usage
parent
cfba97e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
status_checks.py
management/status_checks.py
+23
-0
management.sh
setup/management.sh
+1
-1
No files found.
management/status_checks.py
View file @
59f8aa1c
...
@@ -11,6 +11,7 @@ import sys, os, os.path, re, subprocess, datetime, multiprocessing.pool
...
@@ -11,6 +11,7 @@ import sys, os, os.path, re, subprocess, datetime, multiprocessing.pool
import
dns.reversename
,
dns
.
resolver
import
dns.reversename
,
dns
.
resolver
import
dateutil.parser
,
dateutil
.
tz
import
dateutil.parser
,
dateutil
.
tz
import
idna
import
idna
import
psutil
from
dns_update
import
get_dns_zones
,
build_tlsa_record
,
get_custom_dns_config
,
get_secondary_dns
,
get_custom_dns_record
from
dns_update
import
get_dns_zones
,
build_tlsa_record
,
get_custom_dns_config
,
get_secondary_dns
,
get_custom_dns_record
from
web_update
import
get_web_domains
,
get_default_www_redirects
,
get_ssl_certificates
,
get_domain_ssl_files
,
get_domains_with_a_records
from
web_update
import
get_web_domains
,
get_default_www_redirects
,
get_ssl_certificates
,
get_domain_ssl_files
,
get_domains_with_a_records
...
@@ -152,6 +153,7 @@ def run_system_checks(rounded_values, env, output):
...
@@ -152,6 +153,7 @@ def run_system_checks(rounded_values, env, output):
check_miab_version
(
env
,
output
)
check_miab_version
(
env
,
output
)
check_system_aliases
(
env
,
output
)
check_system_aliases
(
env
,
output
)
check_free_disk_space
(
rounded_values
,
env
,
output
)
check_free_disk_space
(
rounded_values
,
env
,
output
)
check_free_memory
(
rounded_values
,
env
,
output
)
def
check_ssh_password
(
env
,
output
):
def
check_ssh_password
(
env
,
output
):
# Check that SSH login with password is disabled. The openssh-server
# Check that SSH login with password is disabled. The openssh-server
...
@@ -202,6 +204,27 @@ def check_free_disk_space(rounded_values, env, output):
...
@@ -202,6 +204,27 @@ def check_free_disk_space(rounded_values, env, output):
else
:
else
:
output
.
print_error
(
disk_msg
)
output
.
print_error
(
disk_msg
)
def
check_free_memory
(
rounded_values
,
env
,
output
):
# Check free memory.
percent_used
=
psutil
.
virtual_memory
()
.
percent
percent_left
=
100
-
percent_used
if
not
rounded_values
:
memory_msg
=
"The system has allocated
%
s
%%
of the memory."
%
str
(
round
(
percent_used
))
if
percent_left
>
20
:
output
.
print_ok
(
memory_msg
)
elif
percent_left
>
15
:
output
.
print_warning
(
memory_msg
)
else
:
output
.
print_error
(
memory_msg
)
else
:
memory_msg
=
"The system has less than
%
s
%%
memory left."
%
str
(
round
(
percent_left
))
if
percent_left
>
20
:
output
.
print_ok
(
"The system has more than 20
%
memory left"
)
elif
percent_left
>
15
:
output
.
print_warning
(
"The system has less than 20
%
memory left but more than 15
%
"
)
else
:
output
.
print_error
(
"The system has less than 15
%
memory left"
)
def
run_network_checks
(
env
,
output
):
def
run_network_checks
(
env
,
output
):
# Also see setup/network-checks.sh.
# Also see setup/network-checks.sh.
...
...
setup/management.sh
View file @
59f8aa1c
...
@@ -7,7 +7,7 @@ echo "Installing Mail-in-a-Box system management daemon..."
...
@@ -7,7 +7,7 @@ echo "Installing Mail-in-a-Box system management daemon..."
# build-essential libssl-dev libffi-dev python3-dev: Required to pip install cryptography.
# build-essential libssl-dev libffi-dev python3-dev: Required to pip install cryptography.
apt_install python3-flask links duplicity libyaml-dev python3-dnspython python3-dateutil
\
apt_install python3-flask links duplicity libyaml-dev python3-dnspython python3-dateutil
\
build-essential libssl-dev libffi-dev python3-dev python-pip
build-essential libssl-dev libffi-dev python3-dev python-pip
hide_output pip3
install
--upgrade
rtyaml
"email_validator>=1.0.0"
"idna>=2.0.0"
"cryptography>=1.0.2"
boto
hide_output pip3
install
--upgrade
rtyaml
"email_validator>=1.0.0"
"idna>=2.0.0"
"cryptography>=1.0.2"
boto
psutil
# duplicity uses python 2 so we need to use the python 2 package of boto
# duplicity uses python 2 so we need to use the python 2 package of boto
hide_output pip
install
--upgrade
boto
hide_output pip
install
--upgrade
boto
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment