1.python的脚本如下:

 ###############################################################################
#created on 2013-07-09
#author : zhaolijun
#used to get weblogic server runtime infomation
#wls_ver:weblogic 10.3.5.0
############################################################################### ###############################################################################
# parameters define
###############################################################################
username='weblogic'
password='isp902isp'
url='t3://10.200.36.210:17101'
LOOPS=3
IntervalTime=30000
FILEPATH="e:/logs/"
newline = "\n"
###############################################################################
# define functions
###############################################################################
def WriteToFile(ServerName, SubModule, LogString, LSTARTTIME, FILENAME): if SubModule == "ServerCoreInfo":
HeadLineInfo = "DateTime,ServerName,ExecuteThreadIdleCount,StandbyThreadCount,ExecuteThreadTotalCount,busythread,HoggingThreadCount"
elif SubModule == "DataSourceInfo":
HeadLineInfo = "DateTime,ServerName,DataSourceName,ActiveConnectionsCurrentCount,CurrCapacity,WaitingForConnectionCurrentCount,WaitingForConnectionTotal" if not os.path.exists(FILENAME):
print "path not exist, create log file by self."
f = open(FILENAME, "a+")
f.write(HeadLineInfo + newline)
f.write(LSTARTTIME + "," + ServerName + "," + LogString + newline)
f.close()
f = None
else:
f = open(FILENAME, "a+")
f.write(LSTARTTIME + "," + ServerName + "," + LogString + newline)
f.close()
f = None def getCurrentTime():
s=SimpleDateFormat("yyyyMMdd HHmmss")
currentTime=s.format(Date())
return currentTime
def GetJdbcRuntimeInfo():
domainRuntime()
servers = domainRuntimeService.getServerRuntimes();
print ' ******************DATASOURCE CONNECTION POOL RUNTIME INFORMATION*******'
for server in servers:
print 'SERVER: ' + server.getName();
ServerName=server.getName()
jdbcRuntime = server.getJDBCServiceRuntime();
datasources = jdbcRuntime.getJDBCDataSourceRuntimeMBeans();
for datasource in datasources:
ds_name=datasource.getName()
print('-Data Source: ' + datasource.getName() + ', Active Connections: ' + repr(datasource.getActiveConnectionsCurrentCount()) + ', CurrCapacity: ' + repr(datasource.getCurrCapacity())+' , WaitingForConnectionCurrentCount: '+repr(datasource.getWaitingForConnectionCurrentCount())+' , WaitingForConnectionTotal: '+str(datasource.getWaitingForConnectionTotal()));
FILENAME=FILEPATH + ServerName +"_"+ ds_name + "_"+ "DataSourceInfo" +".csv"
LSTARTTIME=getCurrentTime()
dsLogString=ds_name +','+ str(datasource.getActiveConnectionsCurrentCount())+','+repr(datasource.getCurrCapacity())+','+str(datasource.getWaitingForConnectionCurrentCount())+','+str(datasource.getWaitingForConnectionTotal())
WriteToFile(ServerName, "DataSourceInfo", dsLogString, LSTARTTIME, FILENAME) def GetThreadRuntimeInfo():
domainRuntime()
servers=domainRuntimeService.getServerRuntimes();
print ' ******************SERVER QUEUE THREAD RUNTIME INFOMATION***************'
for server in servers:
print 'SERVER: ' + server.getName()
ServerName=server.getName()
threadRuntime=server.getThreadPoolRuntime()
hoggingThreadCount = str(threadRuntime.getHoggingThreadCount())
idleThreadCount = str(threadRuntime.getExecuteThreadIdleCount())
standbycount = str(threadRuntime.getStandbyThreadCount())
threadTotalCount = str(threadRuntime.getExecuteThreadTotalCount())
busythread=str(threadRuntime.getExecuteThreadTotalCount()-threadRuntime.getStandbyThreadCount()-threadRuntime.getExecuteThreadIdleCount()-1)
print ('-Thread :' + 'idleThreadCount:' + idleThreadCount+' ,standbycount:'+standbycount+' , threadTotalCount: '+threadTotalCount+' , hoggingThreadCount:'+hoggingThreadCount+' ,busythread:'+busythread)
FILENAME=FILEPATH + ServerName +"_"+ "ServerCoreInfo" +".csv"
LSTARTTIME=getCurrentTime()
serLogString=idleThreadCount+','+standbycount+','+threadTotalCount+','+busythread+','+hoggingThreadCount
WriteToFile(ServerName, "ServerCoreInfo", serLogString, LSTARTTIME, FILENAME)
###############################################################################
############ main
###############################################################################
if __name__ == '__main__':
from wlstModule import *#@UnusedWildImport
#import sys, re, os
#import java
from java.util import Date
from java.text import SimpleDateFormat
print 'starting the script ....'
connect(username,password, url);
try:
for i in range(LOOPS) : GetThreadRuntimeInfo()
GetJdbcRuntimeInfo()
java.lang.Thread.sleep(IntervalTime) except Exception, e:
print e
dumpStack()
raise
disconnect()

ColletRuntime.py

2.将脚本放到weblogic的安装目录D:\weblogic\bea\wlserver_10.3\common\bin下
3.修改collectionRuntime.py中的weblogic的用户名,密码,IP,端口,日志路径修改成正确的数据。

4.打开CMD窗口,切换到D:\weblogic\bea\wlserver_10.3\common\bin下,然后执行命令wlst.cmd CollectRuntime.py

5.在日志路径下会看到自动生成的CSV文件。能看到HoggingThread和busyThread的数据。

监控gc执行情况的方法如下:

1. 首先需要安装jdk,在jdk/bin目录下,例如:C:\Program Files (x86)\Java\jdk1.6.0_10\bin

2. 打开CMD窗口,切换到jdk/bin目录下,使用命令jstat -gcutil 4556 5s 100 >d:/jstat/text.log ,其中的4556为服务器的进程号。通过jconsole查询得出。

使用 > d:/jstat/text.log的方式可以将jstat的输出结果保存到文件中。

3. 在输出的结果中,可以看到full gc的输出结果。

4. 在监控full gc和hogging thread的过程中,adminserver是不用监控的。

计算方法:

1. full gc间隔,使用FGC列计算,最后一项减去第一项,除以场景时间(分)。

2. gc执行时间,使用FGCT列计算,最后一项减去第一项,除以场景的执行时间(秒)。

3. hogging  thread 和 busy thread都是找出最大值即可

至此,监控过程全部完成。

使用python脚本监控weblogic的更多相关文章

  1. Redis之使用python脚本监控队列长度

    编辑python脚本redis_conn.py #!/usr/bin/env python #ending:utf-8 import redis def redis_conn(): pool = re ...

  2. zabbix 调用python脚本监控 磁盘剩余空间(创建模版,创建监控项,创建触发器)

    主要 记录一下  使用zabbix 自己创建模版.监控项.触发器,并调用python脚本. 需求: 监控备份机磁盘剩余空间(windows系统) 一.安装zabbix_agent 比较简单 修改配置文 ...

  3. python脚本监控股票价格钉钉推送

    关注股市,发家致富 问题:一天天盯着股市多累,尤其上班,还不能暴露,股票软件,红红绿绿,这么明显的列表页面,一看就知道在摸鱼.被领导发现饭碗就没了 解决:搞个脚本监听一下自己关注的股票,一到价格就发个 ...

  4. Python 脚本 监控数据库状态

    打算用这个脚本通过zabbix 监控Mariadb的,无奈要等Mariadb完全上线才行,所以先写一个粗略大致功能的版本. #coding:utf-8 #author:shiyiwen #versio ...

  5. 在nagios中使用python脚本监控linux主机

    在被监控端192.168.5.1101.先把getload.py放到/usr/local/nagios/libexec内[root@nhserver1 ~]# vim /usr/local/nagio ...

  6. 写一个python脚本监控在linux中的进程

    在虚拟机中安装Linux中的CentOS7系统 https://baijiahao.baidu.com/s?id=1597320700700593557&wfr=spider&for= ...

  7. python脚本监控获取当前Linux操作系统[内存]/[cpu]/[硬盘]/[登录用户]

    此脚本应用在linux, 前提是需要有python和python的psutil模块 脚本 #!/usr/bin/env python # coding=utf-8 import sys import ...

  8. linux:使用python脚本监控某个进程是否存在(不使用crontab)

    背景: 需要每天定时去检测crontab进程是否启动,所以不能用crontab来启动检测脚本了,直接使用while 循环和sleep方式实现定时检测 # coding:utf-8 import os ...

  9. WebLogic口令猜解工具【Python脚本】

    WebLogic 默认端口7001 可以通过如下链接访问控制台 http://10.9.1.1:7001/console/login/LoginForm.jsp 写了一个简单的猜解脚本,半成品,做个记 ...

随机推荐

  1. 优化Linux内核参数/etc/sysctl.conf sysctl 《高性能Linux服务器构建实战:运维监控、性能调优与集群应用》

    优化Linux内核参数/etc/sysctl.conf  sysctl  <高性能Linux服务器构建实战:运维监控.性能调优与集群应用> http://book.51cto.com/ar ...

  2. jboss\server\default\.\tmp 拒绝访问 axis2

    下载axis2.war包. 下载jboss-4.2.3.GA.zip和jboss-5.0.1.GA.zip两个包并解压. 配置JDK后要配置JBOSS_HOME的环境变量,在Path中配置%JBOSS ...

  3. [BS-14] 打印NSArray和NSDictionary的3种方法

    打印NSArray和NSDictionary的3种方法 NSArray *arr = @[@"奔驰",@"宝马",@"路虎",@" ...

  4. canvas保存为data:image扩展功能的实现

    [已知]canvas提供了toDataURL的接口,可以方便的将canvas画布转化成base64编码的image.目前支持的最好的是png格式,jpeg格式的现代浏览器基本也支持,但是支持的不是很好 ...

  5. ios数字转emoj表情

    +(NSString *)convertSimpleUnicodeStr:(NSString *)inputStr{ ,); UTF32Char inputChar = ; // unicodeInt ...

  6. C# 微信海报

    最近悟出来一个道理,在这儿分享给大家:学历代表你的过去,能力代表你的现在,学习代表你的将来.我们都知道计算机技术发展日新月异,速度惊人的快,你我稍不留神,就会被慢慢淘汰!因此:每日不间断的学习是避免被 ...

  7. EBS R12.2安装,使用的操作系统用户

    在安装时,错误使用了oracle rdbms的对应的操作系统用户,导致安装前,验证时"web server install prerequisites"选项验证失败: (本图其它两 ...

  8. Java NIO学习(一)

    Java NIO 由以下几个核心部分组成: Channels Buffers Selectors 虽然Java NIO 中除此之外还有很多类和组件,但在我看来,Channel,Buffer 和 Sel ...

  9. 一个想了好几天的问题——关于8086cpu自己编写9号中断不能单步的问题

           在<汇编语言>第十五章中我们可能遇到这样的问题:程序运行正确,但是debug单步调试,却无法运行,修改int 9h中断例程入口地址的指令,虚拟模式下,debug提示指令无效, ...

  10. Leetcode: Trapping Rain Water II

    Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevati ...