前言
最近在研究hadoop集群的负载分析,同学推荐Hadoop自带的监控端口JMX,于是查阅资料做了一下总结。
认识JMX
1.首先看官方接口说明
只提供web页面来访问JMX
例如:启动了hadoop集群(master slave1 slave2)
通过端口50070访问:master:50070查看namenode节点
若查看namenode的监控信息,可直接访问:master:50070/jmx
在web页面即可看到json对象(JMX Beans)的内容
原文说明:
This servlet generally will be placed under the /jmx URL for each HttpServer. It provides read only access to JMX metrics. The optional qry parameter may be used to query only a subset of the JMX Beans. This query functionality is provided through the MBeanServer.queryNames(ObjectName, javax.management.QueryExp) method.
For example http://…/jmx?qry=Hadoop:* will return all hadoop metrics exposed through JMX.
可以通过qry参数来过滤查看内容
{
"beans" : [
{
"name":"bean-name"
...
}
]
}
实例:
url:192.168.84.141:50070/jmx
页面显示:
{
"beans" : [ {
"name" : "Hadoop:service=NameNode,name=JvmMetrics",
"modelerType" : "JvmMetrics",
"tag.Context" : "jvm",
"tag.ProcessName" : "NameNode",
"tag.SessionId" : null,
"tag.Hostname" : "master",
"MemNonHeapUsedM" : 46.013527,
"MemNonHeapCommittedM" : 47.210938,
"MemNonHeapMaxM" : -9.536743E-7,
"MemHeapUsedM" : 34.044724,
"MemHeapCommittedM" : 61.88672,
"MemHeapMaxM" : 966.6875,
"MemMaxM" : 966.6875,
"GcCountCopy" : 51,
"GcTimeMillisCopy" : 357,
"GcCountMarkSweepCompact" : 3,
"GcTimeMillisMarkSweepCompact" : 316,
"GcCount" : 54,
"GcTimeMillis" : 673,
"GcNumWarnThresholdExceeded" : 0,
"GcNumInfoThresholdExceeded" : 0,
"GcTotalExtraSleepTime" : 5121,
"ThreadsNew" : 0,
"ThreadsRunnable" : 8,
"ThreadsBlocked" : 0,
"ThreadsWaiting" : 4,
"ThreadsTimedWaiting" : 24,
"ThreadsTerminated" : 0,
"LogFatal" : 0,
"LogError" : 0,
"LogWarn" : 207,
"LogInfo" : 349
}, {
"name" : "java.lang:type=MemoryPool,name=Survivor Space",
"modelerType" : "sun.management.MemoryPoolImpl",
"Valid" : true,
"Usage" : {
"committed" : 2228224,
"init" : 524288,
"max" : 34930688,
"used" : 28208
},
"PeakUsage" : {
"committed" : 2228224,
"init" : 524288,
"max" : 34930688,
"used" : 1638400
},
.....//省略
}
2.在其他网站上看到的
除了官网给出的参数qry之外,还有两个比较常用的参数:callback get
{
"beans" : [ {
"name" : "java.lang:type=MemoryPool,name=Survivor Space",
"modelerType" : "sun.management.MemoryPoolImpl",
"Valid" : true,
"Usage" : {
"committed" : 1114112,
"init" : 524288,
"max" : 34930688,
"used" : 161480
},
"PeakUsage" : {
"committed" : 1114112,
"init" : 524288,
"max" : 34930688,
"used" : 1108168
},
"MemoryManagerNames" : [ "MarkSweepCompact", "Copy" ],
"UsageThresholdSupported" : false,
"CollectionUsageThreshold" : 0,
"CollectionUsageThresholdExceeded" : false,
"CollectionUsageThresholdCount" : 0,
"CollectionUsage" : {
"committed" : 1114112,
"init" : 524288,
"max" : 34930688,
"used" : 161480
},
"CollectionUsageThresholdSupported" : true,
"Name" : "Survivor Space",
"Type" : "HEAP",
"ObjectName" : "java.lang:type=MemoryPool,name=Survivor Space"
}, {
"name" : "Hadoop:service=ResourceManager,name=RpcActivityForPort8031",
"modelerType" : "RpcActivityForPort8031",
"tag.port" : "8031",
"tag.Context" : "rpc",
"tag.NumOpenConnectionsPerUser" : "{\"hadoop\":3}",
"tag.Hostname" : "master",
"ReceivedBytes" : 2897837,
"SentBytes" : 694106,
"RpcQueueTimeNumOps" : 16941,
"RpcQueueTimeAvgTime" : 0.21456848772763262,
"RpcProcessingTimeNumOps" : 16941,
"RpcProcessingTimeAvgTime" : 0.10979150171549222,
"RpcAuthenticationFailures" : 0,
"RpcAuthenticationSuccesses" : 0,
"RpcAuthorizationFailures" : 0,
"RpcAuthorizationSuccesses" : 7,
"RpcSlowCalls" : 0,
"RpcClientBackoff" : 0,
"NumOpenConnections" : 3,
"CallQueueLength" : 0,
"NumDroppedConnections" : 0
}, {
//省略。。。
}
}
——-后续更新——–
参考网址:https://www.iteblog.com/archives/1694.html