使用python脚本监控weblogic
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的更多相关文章
- Redis之使用python脚本监控队列长度
编辑python脚本redis_conn.py #!/usr/bin/env python #ending:utf-8 import redis def redis_conn(): pool = re ...
- zabbix 调用python脚本监控 磁盘剩余空间(创建模版,创建监控项,创建触发器)
主要 记录一下 使用zabbix 自己创建模版.监控项.触发器,并调用python脚本. 需求: 监控备份机磁盘剩余空间(windows系统) 一.安装zabbix_agent 比较简单 修改配置文 ...
- python脚本监控股票价格钉钉推送
关注股市,发家致富 问题:一天天盯着股市多累,尤其上班,还不能暴露,股票软件,红红绿绿,这么明显的列表页面,一看就知道在摸鱼.被领导发现饭碗就没了 解决:搞个脚本监听一下自己关注的股票,一到价格就发个 ...
- Python 脚本 监控数据库状态
打算用这个脚本通过zabbix 监控Mariadb的,无奈要等Mariadb完全上线才行,所以先写一个粗略大致功能的版本. #coding:utf-8 #author:shiyiwen #versio ...
- 在nagios中使用python脚本监控linux主机
在被监控端192.168.5.1101.先把getload.py放到/usr/local/nagios/libexec内[root@nhserver1 ~]# vim /usr/local/nagio ...
- 写一个python脚本监控在linux中的进程
在虚拟机中安装Linux中的CentOS7系统 https://baijiahao.baidu.com/s?id=1597320700700593557&wfr=spider&for= ...
- python脚本监控获取当前Linux操作系统[内存]/[cpu]/[硬盘]/[登录用户]
此脚本应用在linux, 前提是需要有python和python的psutil模块 脚本 #!/usr/bin/env python # coding=utf-8 import sys import ...
- linux:使用python脚本监控某个进程是否存在(不使用crontab)
背景: 需要每天定时去检测crontab进程是否启动,所以不能用crontab来启动检测脚本了,直接使用while 循环和sleep方式实现定时检测 # coding:utf-8 import os ...
- WebLogic口令猜解工具【Python脚本】
WebLogic 默认端口7001 可以通过如下链接访问控制台 http://10.9.1.1:7001/console/login/LoginForm.jsp 写了一个简单的猜解脚本,半成品,做个记 ...
随机推荐
- C++学了这么多年,你也许不知道为什么类定义要放在.h文件,类实现放在cpp文件。它们如何关联?
原文 http://blog.csdn.net/ithzhang/article/details/8119286 主题 C++ C++学了这么多年你知道为什么定义类时,类的定义放在.h文件中,而类 ...
- Tomcat启动时自动加载一个类
有时候在开发Web应用的时候,需要tomcat启动后自动加载一个用户的类,执行一些初始化方法,如从数据库中加载业务字典到内存中,因此需要在tomcat启动时就自动加载一个类,或运行一个类的方法. 可以 ...
- Java集合 List,Set,Map
一.List:.有顺序以线性方式存储,可以存放重复对象 线程安全方法:List list = Collections.synchronizedList(new LinkedList(...)); ...
- oracle修改sys用户密码
- Oracle Flashback Technologies - 闪回数据库
Oracle Flashback Technologies - 闪回数据库 根据指定的SCN,使用rman闪回数据库 #查看可以闪回到多久前 SQL> select * from v$flash ...
- networkcommon v3开源消息框架资料
http://www.cnblogs.com/csdev/category/870400.html
- SQL in查询
--sal为员工工资 select * from emp;
- manacher 最长回文子串
确定当前已知能匹配到的最长处,看是否要更新最长 #include <bits/stdc++.h> using namespace std; const int N = 210005; in ...
- jetbrains公司全系列软件最简单破解教程
由于最新jetbrains发布了IntelliJ IDEA 15. PyCharm 5.PhpStorm10.WebStorm 11.RubyMine等各个版本,但是改变了注册方法.原先的注册码包括注 ...
- hdu5322 Hope
设dp[n]为n个数字排列时候的答案,那么可以得到dp方程 dp[n]=Σdp[n-i]*c(n-1,i-1)*(i-1)!*i^2(1<=i<=n) 然后上式可以化成卷积形式,分治FFT ...