参考-服务描述文件

import framework.utils.usm.StringWrapper

import Helper

 

service {

name "mongod"

icon "mongodb.png"

type "NOSQL_DB"

numInstances 2

elastic true

minAllowedInstances 1

maxAllowedInstances 2

scaleCooldownInSeconds 20

samplingPeriodInSeconds 1

url "http://" + InetAddress.localHost.hostName + ":7777"

 

compute {

template "SMALL_LINUX_32"

}

 

lifecycle {

preServiceStart "mongod_preServiceStart.groovy"

init "mongod_init.groovy"

preInstall "mongod_preInstall.groovy"

install "mongod_install.groovy"

postInstall "mongod_postInstall.groovy"

preStart "mongod_preStart.groovy"

start "mongod_start.groovy"

startDetectionTimeoutSecs 60

startDetection {

ServiceUtils.isPortOccupied(context.attributes.thisInstance["port"])

}

locator "mongod_locator.groovy"

postStart "mongod_postStart.groovy"

preStop "mongod_preStop.groovy"

stop "mongod_stop.groovy"

postStop "mongod_postStop.groovy"

shutdown "mongod_shutdown.groovy"

preServiceStop "mongod_preServiceStop.groovy"

 

details{

builder = new JmxBuilder()

key = "Bind Address"

beanName = "jboss.system:type=ServerConfig"

attribute = "BindAddress"

RMIConnector client = builder.clientConnector( port: 1099)

client.connect()

connection = client.getMBeanServerConnection();

value = connection.getAttribute(beanName, attribute);

client.close()

return [key:value]

}

 

monitors{

try {

port = context.attributes.thisInstance["port"] as int

mongo = new Mongo("127.0.0.1", port)

db = mongo.getDB("mydb")

 

result = db.command("serverStatus")

println "mongod-service.groovy: result is ${result}"

 

return [

"Active Read Clients":result.globalLock.activeClients.readers,

"Active Write Clients":result.globalLock.activeClients.writers,

"Read Clients Waiting":result.globalLock.currentQueue.readers,

"Write Clients Waiting":result.globalLock.currentQueue.writers,

"Current Active Connections":result.connections.current,

"Open Cursors":result.cursors.totalOpen

]

}

finally {

if (null!=mongo) mongo.close()

}

}

}

 

customCommands ([

"updateWar" : "update_war.groovy"

])

 

customProperties ([

"TailerInterval": "1"

])

 

scalingRules ([

scalingRule {

serviceStatistics {

metric "Total Requests Count"

movingTimeRangeInSeconds 20

statistics Statistics.maximumThroughput

}

 

highThreshold {

value 1

instancesIncrease 1

}

 

lowThreshold {

value 0.2

instancesDecrease 1

}

}

])

 

plugins([

plugin {

name "MongoDBMonitorsPlugin"

className "org.cloudifysource.mongodb.MongoDBMonitorsPlugin"

config([

"host":"127.0.0.1",

"dbName":"petclinic",

"dataSpec" : [

"Active Read Clients":"globalLock.activeClients.readers",

"Active Write Clients":"globalLock.activeClients.writers",

"Read Clients Waiting":"globalLock.currentQueue.readers",

"Write Clients Waiting":"globalLock.currentQueue.writers",

"Current Active Connections":"connections.current",

"Open Cursors":"cursors.totalOpen"

]

])

}

])

userInterface {

metricGroups = ([

metricGroup {

name "MongoDB"

metrics([

"Open Cursors",

"Current Active Connections",

"Active Read Clients",

"Active Write Clients",

"Read Clients Waiting",

"Write Clients Waiting"

])

}

])

 

widgetGroups = ([

widgetGroup {

name "Open Cursors"

widgets ([

balanceGauge{metric = "Open Cursors"},

barLineChart{

metric "Open Cursors"

axisYUnit Unit.REGULAR

},

])

},

widgetGroup {

name "Current Active Connections"

widgets ([

balanceGauge{metric = "Current Active Connections"},

barLineChart{

metric "Current Active Connections"

axisYUnit Unit.REGULAR

},

])

},

widgetGroup {

name "Active Read Clients"

widgets ([

balanceGauge{metric = "Active Read Clients"},

barLineChart{

metric "Active Read Clients"

axisYUnit Unit.REGULAR

},

])

},

widgetGroup {

name "Active Write Clients"

widgets ([

balanceGauge{metric = "Active Write Clients"},

barLineChart{

metric "Active Write Clients"

axisYUnit Unit.REGULAR

},

])

},

widgetGroup {

name "Read Clients Waiting"

widgets ([

balanceGauge{metric = "Read Clients Waiting"},

barLineChart{

metric "Read Clients Waiting"

axisYUnit Unit.REGULAR

},

])

},

widgetGroup {

name "Write Clients Waiting"

widgets ([

balanceGauge{metric = "Write Clients Waiting"},

barLineChart{

metric "Write Clients Waiting"

axisYUnit Unit.REGULAR

},

])

}

])

}

}

转载于:https://my.oschina.net/OQKuDOtsbYT2/blog/122097

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值