6.6 SQL Accounting Interface
Moab Workload Manager®

6.6 SQL Accounting Interface

Moab can be set up to write COMPLETED JOBS statistics to a MySQL database. The following setup shows how to accomplish this:

First, Moab must be compiled with MySQL support. The global Makefile has a section of code that, by default, is commented out. Simply uncomment the following lines for Moab to compile with MySQL support. (The various file locations may change based on a particular site's MySQL installation):

Makefile
#uncomment for SQL
export SQLDEF  =-D__MSQL
#location of MySQL header files
export SQLIP   =-I/usr/include/mysql
#location of MySQL libraries
export SQLLP   =-L/usr/lib/mysql
#MySQL library to load
export SQLLIB  =-lmysqlclient

You can configure Moab to use this interface by entering the following lines in the moab.cfg file. HOST, PORT, DATABASE, and TABLE can be adjusted based on a site's needs:

moab.cfg
RMCFG[sql]	TYPE=NATIVE
RMCFG[sql]	WORKLOADQUERYURL=sql:///Moab,Jobs # <DatabaseName>=Moab -- <TableName>=Jobs
RMCFG[sql]	HOST=localhost
RMCFG[sql]	PORT=0 #'0' indicates use the default MySQL port

ACCOUNTINGINTERFACEURL     sql://sql

This sets up a native resource manager that communicates with the SQL database. Moab connects to the database with the name "Moab" and inserts completed job data into the Jobs table. To keep the communication protocol private, the following should be placed in the moab-private.cfg file:

moab-private.cfg
CLIENTCFG[RM:sql]  AUTHTYPE=PASSWD KEY=<username>.<password>

Moab connects to the MySQL server as <username> using the password <password>. (By default, Moab connect using the primary administrator's username with no password.)

If the WORKLOADQUERYURL parameter is not specified, a MySQL database by the name of "Moab" must be set up with a table named CompletedJobs (default values for database and table). The table must have the following format:

CREATE TABLE CompletedJobs (
  JobName   VARCHAR(40) NOT NULL default '',
  State     VARCHAR(40) default 'COMPLETED',
  StartTime BIGINT NOT NULL default 0,
  EndTime   BIGINT default 0,
  UserName  VARCHAR(40) NOT NULL default '',
  Hostlist  TEXT default '',
  ProcHours DOUBLE default 0.0,
  NetIn     DOUBLE default 0.0,
  NetOut    DOUBLE default 0.0,
  AvgNetIn  DOUBLE default 0.0,
  AvgNetOut DOUBLE default 0.0,
  MaxNetIn  DOUBLE default 0.0,
  MaxNetOut DOUBLE default 0.0,
  MinNetIn  DOUBLE default 0.0,
  MinNetOut DOUBLE default 0.0,
  PRIMARY KEY (JobName,StartTime)
);

The <username> user must have insert privileges to this database/table.

With this setup, Moab writes CompletedJob entries to the database with the following data:

  • JobName
  • State
  • StartTime
  • EndTime
  • UserName
  • Hostlist
  • ProcHours
  • NetIn
  • NetOut
  • AvgNetIn
  • AvgNetOut
  • MaxNetIn
  • MaxNetOut
  • MinNetIn

NOTE: Some versions of libc may not include the z (compression) library by default. This may result in the following error during compilation:

make
undefined reference to `compress'

To remedy this, add the flag -lz to the SQLLIB variable in the file Makefile.