SystemLoggingDB

SystemLoggingDB class is a front-end to the Message Logging Database. The following methods are provided

insertMessage() getMessagesByDate() getMessagesByFixedText() getMessages()

class DIRAC.FrameworkSystem.DB.SystemLoggingDB.SystemLoggingDB

Bases: DB

class SystemLoggingDB

Python interface to SystemLoggingDB.

CREATE  TABLE IF NOT EXISTS `UserDNs` (
  `UserDNID` INT NOT NULL AUTO_INCREMENT ,
  `OwnerDN` VARCHAR(255) NOT NULL DEFAULT 'unknown' ,
  `OwnerGroup` VARCHAR(128) NOT NULL DEFAULT 'nogroup' ,
  PRIMARY KEY (`UserDNID`) ) ENGINE=InnoDB;

CREATE  TABLE IF NOT EXISTS `Sites` (
  `SiteID` INT NOT NULL AUTO_INCREMENT ,
  `SiteName` VARCHAR(64) NOT NULL DEFAULT 'Unknown' ,
  PRIMARY KEY (`SiteID`) ) ENGINE=InnoDB;

CREATE  TABLE IF NOT EXISTS `ClientIPs` (
  `ClientIPNumberID` INT NOT NULL AUTO_INCREMENT ,
  `ClientIPNumberString` VARCHAR(45) NOT NULL DEFAULT '0.0.0.0' ,
  `ClientFQDN` VARCHAR(128) NOT NULL DEFAULT 'unknown' ,
  `SiteID` INT NOT NULL ,
  PRIMARY KEY (`ClientIPNumberID`, `SiteID`) ,
  INDEX `SiteID` (`SiteID` ASC) ,
    FOREIGN KEY (`SiteID` ) REFERENCES Sites(SiteID) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB;

CREATE  TABLE IF NOT EXISTS `SubSystems` (
  `SubSystemID` INT NOT NULL AUTO_INCREMENT ,
  `SubSystemName` VARCHAR(128) NOT NULL DEFAULT 'Unknown' ,
  `SystemID` INT NOT NULL AUTO_INCREMENT ,
  PRIMARY KEY (`SubSystemID`) ) ENGINE=InnoDB;
    FOREIGN KEY (`SystemID`) REFERENCES Systems(SystemID) ON UPDATE CASCADE ON DELETE CASCADE)

CREATE  TABLE IF NOT EXISTS `Systems` (
  `SystemID` INT NOT NULL AUTO_INCREMENT ,
  `SystemName` VARCHAR(128) NOT NULL DEFAULT 'Unknown' ,
  PRIMARY KEY (`SystemID` ) , )
    ENGINE=InnoDB;

CREATE  TABLE IF NOT EXISTS `FixedTextMessages` (
  `FixedTextID` INT NOT NULL AUTO_INCREMENT ,
  `FixedTextString` VARCHAR(255) NOT NULL DEFAULT 'Unknown' ,
  `ReviewedMessage` TINYINT(1) NOT NULL DEFAULT FALSE ,
  `SystemID` INT NOT NULL ,
  PRIMARY KEY (`FixedTextID`, `SystemID`) ,
  INDEX `SystemID` (`SystemID` ASC) ,
    FOREIGN KEY (`SystemID` ) REFERENCES Systems(`SystemID`) ON UPDATE CASCADE ON DELETE CASCADE) ENGINE=InnoDB;

CREATE  TABLE IF NOT EXISTS `MessageRepository` (
  `MessageID` INT NOT NULL AUTO_INCREMENT ,
  `MessageTime` DATETIME NOT NULL ,
  `VariableText` VARCHAR(255) NOT NULL ,
  `UserDNID` INT NOT NULL ,
  `ClientIPNumberID` INT NOT NULL ,
  `LogLevel` VARCHAR(6) NOT NULL ,
  `FixedTextID` INT NOT NULL ,
  PRIMARY KEY (`MessageID`) ,
  INDEX `TimeStampsIDX` (`MessageTime` ASC) ,
  INDEX `FixTextIDX` (`FixedTextID` ASC) ,
  INDEX `UserIDX` (`UserDNID` ASC) ,
  INDEX `IPsIDX` (`ClientIPNumberID` ASC) ,
    FOREIGN KEY (`UserDNID` ) REFERENCES UserDNs(`UserDNID` ) ON UPDATE CASCADE ON DELETE CASCADE,
    FOREIGN KEY (`ClientIPNumberID` ) REFERENCES ClientIPs(`ClientIPNumberID` ) ON UPDATE CASCADE ON DELETE CASCADE,
    FOREIGN KEY (`FixedTextID` ) REFERENCES FixedTextMessages (`FixedTextID` ) ON UPDATE CASCADE ON DELETE CASCADE )
    ENGINE=InnoDB;

CREATE  TABLE IF NOT EXISTS `AgentPersistentData` (
  `AgentID` INT NOT NULL AUTO_INCREMENT ,
  `AgentName` VARCHAR(64) NOT NULL DEFAULT 'unkwown' ,
  `AgentData` VARCHAR(512) NULL DEFAULT NULL ,
  PRIMARY KEY (`AgentID`) ) ENGINE=InnoDB;
__init__()

Standard Constructor

buildCondition(condDict=None, older=None, newer=None, timeStamp=None, orderAttribute=None, limit=False, greater=None, smaller=None, offset=None, useLikeQuery=False)

Build SQL condition statement from provided condDict and other extra check on a specified time stamp. The conditions dictionary specifies for each attribute one or a List of possible values greater and smaller are dictionaries in which the keys are the names of the fields, that are requested to be >= or < than the corresponding value. For compatibility with current usage it uses Exceptions to exit in case of invalid arguments For performing LIKE queries use the parameter useLikeQuery=True

countEntries(table, condDict, older=None, newer=None, timeStamp=None, connection=False, greater=None, smaller=None)

Count the number of entries wit the given conditions

deleteEntries(tableName, condDict=None, limit=False, conn=None, older=None, newer=None, timeStamp=None, orderAttribute=None, greater=None, smaller=None)

Delete rows from “tableName” with N records can match the condition if limit is not False, the given limit is set String type values will be appropriately escaped, they can be single values or lists of values.

executeStoredProcedure(packageName, parameters, outputIds)
executeStoredProcedureWithCursor(packageName, parameters)
getCSOption(optionName, defaultValue=None)
getCounters(table, attrList, condDict, older=None, newer=None, timeStamp=None, connection=False, greater=None, smaller=None)

Count the number of records on each distinct combination of AttrList, selected with condition defined by condDict and time stamps

getDistinctAttributeValues(table, attribute, condDict=None, older=None, newer=None, timeStamp=None, connection=False, greater=None, smaller=None)

Get distinct values of a table attribute under specified conditions

getFields(tableName, outFields=None, condDict=None, limit=False, conn=None, older=None, newer=None, timeStamp=None, orderAttribute=None, greater=None, smaller=None, useLikeQuery=False)

Select “outFields” from “tableName” with condDict N records can match the condition return S_OK(tuple(Field, Value)) if outFields is None all fields in “tableName” are returned if limit is not False, the given limit is set inValues are properly escaped using the _escape_string method, they can be single values or lists of values. if useLikeQuery=True, then conDict can return matched rows if “%” is defined inside conDict.

insertFields(tableName, inFields=None, inValues=None, conn=None, inDict=None)

Insert a new row in “tableName” assigning the values “inValues” to the fields “inFields”. String type values will be appropriately escaped.

insertMessage(message, site, nodeFQDN, userDN, userGroup, remoteAddress)

This function inserts the Log message into the DB

transactionCommit()
transactionRollback()
transactionStart()
updateFields(tableName, updateFields=None, updateValues=None, condDict=None, limit=False, conn=None, updateDict=None, older=None, newer=None, timeStamp=None, orderAttribute=None, greater=None, smaller=None)

Update “updateFields” from “tableName” with “updateValues”. updateDict alternative way to provide the updateFields and updateValues N records can match the condition return S_OK( number of updated rows ) if limit is not False, the given limit is set String type values will be appropriately escaped.