Skip to content

Instantly share code, notes, and snippets.

@istairbn
Last active December 1, 2015 09:21
Show Gist options
  • Save istairbn/2a85101b101b47f09fdb to your computer and use it in GitHub Desktop.
Save istairbn/2a85101b101b47f09fdb to your computer and use it in GitHub Desktop.
Groovy script for testing monitors - outputs specified logs lines on a schedule you can set.
//OutputTester.groovy - Used to output data at specific times. Useful for testing monitors
def counter = 0
outputLine = args.length > 0 ? args[0] : "App:LogscapeSmokeTest Counter:$counter The Service has successfully deployed"
while(1){
def timestamp = new Date().format ("yyyy-MM-dd HH:mm:ss,SSS")
def nowMins = new Date().format("mm").toInteger()
def nowSecs = new Date().format("ss").toInteger()
def nowMillis = new Date().format("SS").toInteger()
//If you want to specify which minutes it runs on, uncomment out the below line. Otherwise it's every two minutes
//if(nowMins == 0)
if (nowMins % 2 == 0 ){
//Only runs in the 0 second - change to suit your needs
if (nowSecs == 0){
//Only runs in the first 499 milliseconds - change to suit your needs
if( nowMillis < 050){
println("$timestamp $outputLine")
//If you want to track the number of messages etc, uncomment the below two lines
//println("$timestamp Counter = $counter nowMillis=$nowMillis")
counter++
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment