Package: resource-availability-monitoring
Resource Availability Monitoring (ram) toolThis lightweight tool can be used to monitor the availability of resources and services via HTCondor. User-defined jobs are submitted in regular intervals, and their results are collected and written to an influxdb database. The service is designed to run as a systemd service, and can be configured extensively.InstallationThe tool is installed via pip:pipinstallresource-availability-monitoringAfterwards, the service can be started viaram-cliConfigurationPer default, ram comes without a configuration, however, a default configuration can be generated viaram-cli--initialize--configdir/path/to/your/configdirJob ConfigurationThe configuration has to be adjusted to the user's needs. The main configuration contains a list of defined testjobs. Each testjob configuration contains the following fields:jobs:-name:"default"# Name of the testjobparameters:enabled:true# The testjob will only be executed if enabled is set to truedescription:"DefaultTest"# Description of the testjobsite:"Default"# The name of the site to be monitoredinterval:1200# after each interval, a new job is submitted (in seconds)timeout:1200# maximum time the testjob has to finish (in seconds)job:executable:"default.sh"# The executable to be run, has to be located in <configdir>/<name of job>/AccountingGroup:"group"# The accounting group to be used by HTCondorarguments:""# Arguments to be passed to the executableoutput_file:"job_result.yaml"# The file to which the result of the job is writtenoutput:"default.out"# The file to which the stdout of the job is writtenerror:"default.err"# The file to which the stderr of the job is writtenlog:"default.log"# The file to which the HTCondor of the job is writtenuniverse:"vanilla"# The universe to be used by HTCondordocker_image:""# The docker image to be used by HTCondor (only if universe is set to docker)requirements:''# Requirements to be passed to HTCondorcpu:1# The number of CPUs to be used by the jobmemory:1000# The amount of memory to be used by the job (in MB)disk:100000# The amount of disk space to be used by the job (in KB)gpu:0# The number of GPUs to be used by the jobrequirements:''# Additional requirements to be passed to HTCondor, e.g. "OpSysMajorVer == 7"In addition, the job executable has to be located in<configdir>/<name of job>/. The executable has to be a shell script, and has to return a yaml file with the following structure:tests:-test:"default_test"passed:Truemessage:"default_testpassed"A testjob can contain multiple tests, and each test has to contain the fieldstest,passed, andmessage. A testjob is considered to have passed if all tests have passed and the job has finished successfully. Within the shell script, the tests can be implemented as needed, and the results have to be written to the yaml file.InfluxDB ConfigurationThe Influxdb parameters are stored in a separate configuration file, and contain the following fields:url:""token:""bucket:""org:""Set all parameters to the correct values to enable the writing of the results to the Influxdb database. If you do not want to use an Influxdb database, run the service with the--no-influxdbflag. This will disable the writing of the results to the Influxdb database.UsageAll command line options can be displayed viaram-cli-h
usage:__main__.py[-h]--workdirWORKDIR--configdirCONFIGDIR[--config-fileCONFIG_FILE][--influxdb-config-fileINFLUXDB_CONFIG_FILE][--job-db-fileJOB_DB_FILE][--log-fileLOG_FILE][--initialize][--check][--no-influxdb]optionalarguments:-h,--helpshowthishelpmessageandexit--workdirWORKDIRDirectorytostorejobresults,joblogsandjobdatabase--configdirCONFIGDIRDirectorytostoreconfigurationfilesandjobscripts--config-fileCONFIG_FILEPathtotheconfigurationfileforthejobs,defaultis<configdir>/config.yml--influxdb-config-fileINFLUXDB_CONFIG_FILEPathtotheInfluxDBconfigurationfile,defaultis<configdir>/influx_parameters.yml--job-db-fileJOB_DB_FILEPathtothejobdatabasefile,defaultis<workdir>/jobs.sqlite3--log-fileLOG_FILEPathtothelogfile,defaultis<workdir>/remote-testsuite.log--initializeInitializethetoolwithdefaultconfiguration--checkCheckifthegivenconfigurationisvalidandexit--no-influxdbDonotwritetoInfluxDB,onlyrunthejobsAfter the configuration has been adjusted, the configuration and Influxdb parameters can be tested viaram-cli--configdir/path/to/your/configdir--workdir/path/to/your/workdir--checkRecommended arguments are:ram-cli--configdir/path/to/your/configdir--workdir/path/to/your/workdirSystemd ServiceTo run the service as a systemd service, some best practices should be followed. The service should be run as a dedicated user, and the configuration and workdir should be owned by this user. After the user is created, setup a python venv, where the package is installed:python3-mvenv/path/to/your/venvsource/path/to/your/venv/bin/activate
pip3installresource-availability-monitoringThe service file should be located in/etc/systemd/system/, and should contain the following content and be namedresource-availability-monitoring.service:[Unit]Description=ResourceAvailabilityMonitoringServiceAfter=network.targetWants=network-online.targetAfter=network-online.target[Install]WantedBy=multi-user.target[Service]Type=simpleUser=ramGroup=ramLimitNOFILE=65536WorkingDirectory=/path/to/your/workdirExecStart=/path/to/your/venv/bin/python3-mresource_availability_monitoring--configdir/path/to/your/configdir--workdir/path/to/your/workdirRestart=on-failureRestartSec=300sAfter the service file has been created, the service can be started viasystemctlstartresource-availability-monitoring