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. Windows 上使用 cygwin 连接到 docker toolbox

    Windows 上使用 cygwin 连接到 docker toolbox Docker 确实给软件开发带来一些好处,在简化部署.统一开发.测试和生产环境上,有它独到的理念.Linux 上可直接安装 ...

  2. angularjs 获取地址传参

    .controller('CityCtrl', function ($scope, $location,$ionicModal) { 注入location服务 $scope.name = $locat ...

  3. [BS-08]注意Xcode自动提示好用但极易出错,务必看清方法的名称

    今日在写一个UIBarButtonItem的分类时,在Xcode自动提示时,因未仔细查看,错将需要用到setBackgroundImage的地方,选择成setImage,结果导致button的boun ...

  4. msvc库没有安装包,编译选项选择 代码生成 MT【多线程】,C#调用

    参考提过的一个问题,封装VC++动态链接库,C#调用,并将C#程序打包为exe安装包. 感谢大神.

  5. javascript实例学习之五——瀑布流布局

    瀑布流布局的特征: 1,各列的高度参差不齐 2,页面向下滚动时,自动请求和加载新数据 目前,瀑布流布局的主流实现方式有两种: 1,基于浮动,每一列是一个ul,这些ul都向左浮动,这种方法的好处是布局容 ...

  6. AWR快照管理

    创建快照: SQL> exec dbms_workload_repository.create_snapshot(); 删除快照: SQL> exec dbms_workload_repo ...

  7. Java Axis2 1.6.3+JDK1.7.0_13+Tomcat7.0.65+eclipse搭建web service

    安装文件下载: jdk1.7.0_13 安装步骤参考文章:http://jingyan.baidu.com/article/6dad5075d1dc40a123e36ea3.html tomcat7. ...

  8. 新版mysql(mysql-5.7.12-winx64)安装

    之前安装了一个php集成运行环境的mysql,不太习惯,还是想弄一个原生的环境来进行学习.于是,卸载了php集成环境中的mysql. 计算机环境:win7 x64. 1.mysql-5.7.12-wi ...

  9. iptables使用

    iptables规则的查看.添加.删除和修改 1.查看 iptables -nvL --line-number (这个命令跟/etc/init.d/iptables status 输出差不多) -L ...

  10. 【Origin】jquery.barddialog.js

    /// <reference path="jquery-2.1.1.min.js" /> /** * @license jquery.bardDialog 1.0.0 ...