Skip to content

Instantly share code, notes, and snippets.

@nblair
Created October 12, 2017 20:47
Show Gist options
  • Save nblair/0a3a8ac9ebe2f1f201a4914f5a295839 to your computer and use it in GitHub Desktop.
Save nblair/0a3a8ac9ebe2f1f201a4914f5a295839 to your computer and use it in GitHub Desktop.
A groovy script to check the 'freeze' state of Nexus Repository Manager databases
/**
* Tested with Nexus Repository Manager 3.6.
* Warning: uses internal APIs which are subject to change.
*
* When run, prints a task log entry for each OrientDB database indicating whether or not the database is frozen.
* See https://orientdb.com/docs/2.2/Console-Command-Freeze-Db.html
*
* Usage:
* 1. Create a task with the "Execute Script" type - see https://help.sonatype.com/display/NXRM3/Configuration#Configuration-ConfiguringandExecutingTasks
* 2. Set task frequency to manual
* 3. Choose groovy for language, and paste the following groovy code into the source block.
*/
import org.sonatype.nexus.orient.DatabaseManager
import static org.sonatype.nexus.orient.DatabaseInstanceNames.DATABASE_NAMES
def manager = container.lookup(DatabaseManager.class.name)
DATABASE_NAMES.each {
log.info("${it} isFrozen=${manager.instance(it).isFrozen()}")
}
@peterlynch
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment