Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hardik Juneja
slapos
Commits
4e259e27
Commit
4e259e27
authored
Feb 23, 2017
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor: promise free_disk_space also check if inodes is not full on slapgrid and /tmp disk
parent
914ff766
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
6 deletions
+28
-6
stack/monitor/buildout.cfg
stack/monitor/buildout.cfg
+2
-2
stack/monitor/instance-monitor.cfg.jinja2.in
stack/monitor/instance-monitor.cfg.jinja2.in
+3
-3
stack/monitor/templates/check_free_disk.in
stack/monitor/templates/check_free_disk.in
+23
-1
No files found.
stack/monitor/buildout.cfg
View file @
4e259e27
...
@@ -89,7 +89,7 @@ md5sum = 683ea85fc054094248baf5752dd089bf
...
@@ -89,7 +89,7 @@ md5sum = 683ea85fc054094248baf5752dd089bf
[monitor-check-free-disk-space]
[monitor-check-free-disk-space]
<= monitor-template-base
<= monitor-template-base
filename = check_free_disk.in
filename = check_free_disk.in
md5sum =
e48f3804dc367e51a70063ab0e589e9e
md5sum =
bab457ac4d139ed31d0b343a7d14d996
# End templates files
# End templates files
# XXX keep compatibility (with software/ipython_notebook/software.cfg )
# XXX keep compatibility (with software/ipython_notebook/software.cfg )
...
@@ -102,7 +102,7 @@ recipe = slapos.recipe.template:jinja2
...
@@ -102,7 +102,7 @@ recipe = slapos.recipe.template:jinja2
filename = template-monitor.cfg
filename = template-monitor.cfg
template = ${:_profile_base_location_}/instance-monitor.cfg.jinja2.in
template = ${:_profile_base_location_}/instance-monitor.cfg.jinja2.in
rendered = ${buildout:directory}/template-monitor.cfg
rendered = ${buildout:directory}/template-monitor.cfg
md5sum =
2c2aacb9fa97e35818bfa4543dffcb5a
md5sum =
bf0adf565d7cde55abc94bd223ec3162
context =
context =
key apache_location apache:location
key apache_location apache:location
key gzip_location gzip:location
key gzip_location gzip:location
...
...
stack/monitor/instance-monitor.cfg.jinja2.in
View file @
4e259e27
...
@@ -170,14 +170,14 @@ recipe = plone.recipe.command
...
@@ -170,14 +170,14 @@ recipe = plone.recipe.command
stop-on-error = true
stop-on-error = true
password-file = ${directory:etc}/.monitor_pwd
password-file = ${directory:etc}/.monitor_pwd
command =
command =
if [ ! -
f
"${:password-file}" ]; then echo "${monitor-instance-parameter:password}" > ${:password-file}; fi
if [ ! -
s
"${:password-file}" ]; then echo "${monitor-instance-parameter:password}" > ${:password-file}; fi
update-command = ${:command}
update-command = ${:command}
[httpd-monitor-htpasswd]
[httpd-monitor-htpasswd]
recipe = plone.recipe.command
recipe = plone.recipe.command
stop-on-error = true
stop-on-error = true
htpasswd-path = ${monitor-directory:etc}/monitor-htpasswd
htpasswd-path = ${monitor-directory:etc}/monitor-htpasswd
command = if [ ! -
f
"${:htpasswd-path}" ]; then {{ apache_location }}/bin/htpasswd -cb ${:htpasswd-path} ${:user} ${:password}; fi
command = if [ ! -
s
"${:htpasswd-path}" ]; then {{ apache_location }}/bin/htpasswd -cb ${:htpasswd-path} ${:user} ${:password}; fi
update-command = ${:command}
update-command = ${:command}
user = ${monitor-instance-parameter:username}
user = ${monitor-instance-parameter:username}
password = ${monitor-instance-parameter:password}
password = ${monitor-instance-parameter:password}
...
@@ -394,4 +394,4 @@ monitor-setup-url = ${monitor-instance-parameter:interface-url}/#page=settings_c
...
@@ -394,4 +394,4 @@ monitor-setup-url = ${monitor-instance-parameter:interface-url}/#page=settings_c
[buildout]
[buildout]
extends =
extends =
{{ template_logrotate_base }}
{{ template_logrotate_base }}
\ No newline at end of file
stack/monitor/templates/check_free_disk.in
View file @
4e259e27
...
@@ -18,6 +18,24 @@ def free_space(path, fn):
...
@@ -18,6 +18,24 @@ def free_space(path, fn):
def user_free_space(path):
def user_free_space(path):
return free_space(path, lambda d: d.f_bsize * d.f_bavail)
return free_space(path, lambda d: d.f_bsize * d.f_bavail)
def check_inode_usage(path):
max_inode_usage = 97.99 # < 98% usage
st = os.statvfs(path)
usage_output = ""
total_inode = st.f_files
free_inode = st.f_ffree
usage = round((float(total_inode - free_inode) / total_inode), 4) * 100
if usage > max_inode_usage:
return "Disk Inodes are widely used: %s%%" % usage
elif os.path.exists('/tmp'):
# check if /tmp is mounted on another disk than path
tmp_st = os.statvfs('/tmp')
if tmp_st.f_blocks != st.f_blocks:
tmp_usage = round((float(tmp_st.f_files - tmp_st.f_ffree) / tmp_st.f_files), 4) * 100
if tmp_usage > max_inode_usage:
return "Disk Inodes are widely used: %s%%" % tmp_usage
return ""
if __name__ == '__main__':
if __name__ == '__main__':
home_path = '{{ home_path }}'
home_path = '{{ home_path }}'
...
@@ -40,7 +58,11 @@ if __name__ == '__main__':
...
@@ -40,7 +58,11 @@ if __name__ == '__main__':
f.write(str(min_free_size/(1024*1024)))
f.write(str(min_free_size/(1024*1024)))
real_free_space = user_free_space(home_path)
real_free_space = user_free_space(home_path)
if real_free_space > min_free_size:
if real_free_space > min_free_size:
print "Free disk space: OK"
inode_usage = check_inode_usage(home_path)
if inode_usage:
print inode_usage
exit(2)
print "Disk usage: OK"
exit(0)
exit(0)
real_space_g = round(real_free_space/(1024.0*1024*1024), 2)
real_space_g = round(real_free_space/(1024.0*1024*1024), 2)
...
...
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