Groovy web console

subscribe to the feed Subscribe
to this
site

map_data1

Published 6 months ago by tst with tags tst
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def output = """define contactgroup{
contactgroup_name     webio-admins
alias                 UIM:NAGIOS-TEST-WEBIO;
members               emusic
}
define contactgroup{
contactgroup_name     voice_ops
alias                 UIM:NAGIOS-TEST-WEBIO1;
members               emusic,mkopitsch,gmohan
}
define contactgroup{
contactgroup_name     voice_ops11
alias                 NAGIOS-TEST-WEBIO2;
members               emusic,mkopitsch,gmohan
}
define contactgroup{
contactgroup_name     voice_ops22
alias                 UIM:NAGIOS-TEST-WEBIO3;
members               emusic,mkopitsch,gmohan
}
"""
def result = [:]

def matches = output.findAll(/(?<=contactgroup_name).*/)
 def matches1 = output.findAll(/(?<=UIM:).*/)
for (i=0; i<matches.size; i++)
{
    if(matches[i])
    { println("inside if1..")
        matches[i] = matches[i].trim();
    }
    if(matches1[i])
    { println("inside if2..")
        matches1[i] = matches1[i].replaceAll(/[; ]+/,"").trim()
    }
    //matches1[i] = matches1[i] ?: matches1[i].replaceAll(/[; ]+/,"").trim()
   result.put(matches[i], matches1[i])
}
println(result)