使用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 写了一个简单的猜解脚本,半成品,做个记 ...
随机推荐
- ZooKeeper常见问题(转)
这段时间来,也在和公司里的一些同学交流使用zk的心得,整理了一些常见的zookeeper问题.这个页面的目标是解答一些zk常见的使用问题,同时也让大家明确zk不能干什么.页面会一直更新. 客户端 1. ...
- C语言下WebService的使用方式
用gSoap工具: 1.在dos环境中到gSoap工具对应的目录gsoap_2.8.18\gsoap-2.8\gsoap\bin\win32路径下,执行wsdl2h -c -o *.h ht ...
- IntelliJ IDEA 的 Java 热部署插件 JRebel 安装及使用
JRebel 介绍 JRebel for Intellij JRebel 在 Java Web 开发中, 一般更新了 Java 文件后要手动重启 Tomcat 服务器, 才能生效, 自从有了 JRe ...
- Winforms-GePlugin-Control-library
Winforms-GePlugin-Control-library http://download.csdn.net/download/xm379303813/4247029
- Java- 基本封装
package test.studet_manager; public class Student { static int num = 100; // 编号-->唯一的 private int ...
- maven 无法安装plugin的问题
spring有一个入门例子,在docker里跑spring-boot程序 下载后按照教程执行mvn package docker:build.并不能成功.会报错. [ERROR] No plugin ...
- 在centos安装docker
关闭防火墙 iptables -L systemctl disable firewalld.service systemctl stop firewalld.service 配置代理太麻烦了,建议使用 ...
- js 点击展开、收起
//点击展开.收起 window.onload=function(){ var current=document.getElementsByTagName('li')[0]; document.bod ...
- transient关键字的含义
transient java语言的关键字,变量修饰符,如果用transient声明一个实例变量,当对象存储时,它的值不需要维持. Java的serialization提供了一种持久化对象实例的机制.当 ...
- C# 微信支付教程系列之扫码支付
微信支付教程系列之扫码支付 今天,我们来一起探讨一下这个微信扫码支付.何为扫码支付呢?这里面,扫的码就是二维码了,就是我们经常扫一扫的那种二维码图片,例如,我们自己添加好友的时候 ...