Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/isilon quota #496

Merged
merged 11 commits into from
Dec 1, 2021
15 changes: 15 additions & 0 deletions roles/shared_storage/files/crontab.smbtime
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Quota management for our Isilon file systems
#
# This contab.smbtime file must be installed on one of the Isilon nodes in
# /etc/mcp/override/crontab.smbtime
# Important notes:
# * This file should survive an Isilon OneFS update,
# but check after each Isilon update to make sure and redeploy if necessary!
# * We use the isi_ropc command to make sure the script will Run Once Per Cluster.
# * We currently do not have access from our Ansible control hosts to the Isilon backend,
# so this crontab.smbtime cannot be deployed with Ansible: deploy manually instead!
#
#min hour mday month wday who command
30 * * * * root isi_ropc -s zsh /ifs/scripts/set_isilon_quota.zsh -a
45 5 * * 0 root isi_ropc -s zsh /ifs/scripts/send_isilon_quota_report_wrapper.zsh
65 changes: 65 additions & 0 deletions roles/shared_storage/files/send_email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python

#
# Helper script to send mail using the Isilon libraries.
# Original from: https://groups.google.com/g/isilon-user-group/c/4XM0_hmHTr0/m/sRos52H2HAAJ
#

import sys
from optparse import OptionParser
import socket
from isi.app.lib.emailer import Emailer, EmailAttachmentFromFile

# Emailer.send_email(to_addresses(list), message(string), from_address=None(string), subject=None(string),
# attachments=None(list), headers=None(list), charset="us-ascii"(string))

def main():
usage = '%prog: [-f sender] -t recipient [ -t recipient ... ] [-s subject] [-b body] [-a attachment]'
argparser = OptionParser(usage = usage, description = 'Send email from a cluser node')
argparser.add_option('-f', '--from', '--sender', dest='sender',
help="email sender (From:)")
argparser.add_option('-t', '--to', '--recipients', dest='recipients',
action = 'append', help="email recipient (To:)")
argparser.add_option('-s', '--subject', dest='subject',
help="email subject (Subject:)")
argparser.add_option('-b', '--body', dest='body',
help="email body (default stdin)")
argparser.add_option('-a', '--attachment', '--file', dest='attfiles',
action = 'append', help="attachment filename")
(options, args) = argparser.parse_args()
if options.sender is None:
fqdn = socket.getfqdn()
sender = "root@%s" % fqdn
else:
sender = options.sender
if options.recipients is None:
argparser.error("Unable to send mail without at least one recipient");
sys.exit(1);
else:
recipients = options.recipients
if options.subject is None:
subject = 'No subject specified'
else:
subject = options.subject
if options.body is None:
lines = sys.stdin.readlines()
body = ''.join(lines)
else:
body = options.body
if options.attfiles is None:
atts = None
else:
atts = []
for attfile in options.attfiles:
att = EmailAttachmentFromFile(attfile)
atts.append(att)
try:
Emailer.send_email(recipients, body, sender, subject, attachments = atts)
except:
print('Error sending email.')
sys.exit(1)

sys.exit(0)

if __name__ == "__main__":
main()
23 changes: 23 additions & 0 deletions roles/shared_storage/files/send_isilon_quota_report_wrapper.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/zsh
#
# Wrapper script to:
# * Generate a quota report with "isi quota quotas list" command and
# * Send the generated report by email using a custom sendmail.py,
# which is required as Isilon systems are Debian based,
# but lack a regular Linux command line mail client.
#

declare -a physical_file_systems
physical_file_systems=(
'umcgst10' # On UMCG Research Isilon
)

for pfs in "${physical_file_systems}"; do
isi quota quotas list \
--recurse-path-children \
--path "/ifs/rekencluster/${pfs}/groups/" \
| python /ifs/scripts/send_email.py \
-f "cron@$(hostname)" \
-t hpc.helpdesk@umcg.nl \
-s "HPC report: Quota vs. disk usage for file system ${pfs}."
done
2 changes: 1 addition & 1 deletion roles/shared_storage/templates/set_isilon_quota.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ declare pfs_base_path='/ifs/rekencluster'
declare pfs_name_prefix='umcgst'
declare TMPDIR="${TMPDIR:-/tmp}" # Default to /tmp if ${TMPDIR} was not defined.
declare SCRIPT_NAME
SCRIPT_NAME="$(basename "${0}" '.bash')"
SCRIPT_NAME="$(basename "${0}" '.zsh')"
export TMPDIR
export SCRIPT_NAME
declare mixed_stdouterr='' # global variable to capture output from commands for reporting in custom log messages.
Expand Down