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

This creates a new database monitor page that can be used to see what… #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions grails-app/controllers/MonitorController.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class MonitorController {

def monitorService

def index = {
def dbStatusText = ""
def otherStatusText = monitorService.otherStatusText

try {
dbStatusText = monitorService.getDatabaseStatusText(false, "")
} catch (e) {
dbStatusText = monitorService.getDatabaseStatusText(true, e.getMessage())
}

render(text: dbStatusText + otherStatusText)

}

}
51 changes: 51 additions & 0 deletions grails-app/services/MonitorService.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import groovy.sql.Sql

class MonitorService {

def grailsApplication
def dataSource
def rserveStatusService
def solrStatusService

def getObservationCount() {
Sql sql = new Sql(dataSource)
String sqlText = "SELECT COUNT(*) FROM i2b2demodata.observation_fact"
def result = sql.firstRow(sqlText)
return result.values()[0]
}

def getLoadedStudies() {
Sql sql = new Sql(dataSource)
String sqlText = "SELECT c_name FROM i2b2metadata.i2b2 WHERE c_visualattributes = 'FAS'"
return sql.rows(sqlText).collect({ it.getAt(0)}).join(", ")
}

def getAppVersion() {
return grailsApplication.metadata['app.version']
}

def getDatabaseStatusText(isDBError, errorMessage) {
if (!isDBError) {
return "Database Connection Status: " + "OK<br/>" +
"Observation Count: " + observationCount + "<br/>" +
"Loaded Studies: " + loadedStudies + "<br/>" +
}
else {
return "Database Connection Status: " + "ERROR<br/>" +
"Last Database Error Message: " + errorMessage + "<br/>"
}
}

def getOtherStatusText() {
return "App Version: " + appVersion + "<br/><br/>" +
"RServe Status <br/>" +
"-------------------- </br>" +
rserveStatusService.status.toHTMLString() + "</br>" +
"Solr Status <br/>" +
"-------------------- </br>" +
solrStatusService.status.toHTMLString()
}



}
12 changes: 10 additions & 2 deletions src/groovy/org/transmartfoundation/status/RserveStatus.groovy
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.transmartfoundation.status

import java.util.Date;

class RserveStatus {

String url
Expand All @@ -15,4 +13,14 @@ class RserveStatus {
return "RserveStatus (" + url + ") - probe at: " + lastProbe
}

String toHTMLString () {
return 'url: ' + url + "</br>" +
'connected: ' + connected + "</br>" +
'simpleExpressionOK: ' + simpleExpressionOK + "</br>" +
'librariesOk: ' + librariesOk + "</br>" +
'lastErrorMessage: ' + lastErrorMessage + "</br>" +
'lastProbe: ' + lastProbe + "</br>"
}


}
13 changes: 13 additions & 0 deletions src/groovy/org/transmartfoundation/status/SolrStatus.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,17 @@ class SolrStatus {
String toString () {
return "SolrStatus (URL: " + url + ") - probe at: " + lastProbe
}

String toHTMLString () {
return 'url: ' + url + "<br/>" +
'connected: ' + connected + "<br/>" +
'rwgAvailable: ' + rwgAvailable + "<br/>" +
'rwgNumberOfRecords: ' + rwgNumberOfRecords + "<br/>" +
'browseAvailable: ' + browseAvailable + "<br/>" +
'browseNumberOfRecords: ' + browseNumberOfRecords + "<br/>" +
'sampleAvailable: ' + sampleAvailable + "<br/>" +
'sampleNumberOfRecords: ' + sampleNumberOfRecords + "<br/>" +
'lastProbe: ' + lastProbe + "<br/>"
}

}