Self writing weblogic monitoring, automatic thread dump, ftp upload, SMS, voice alarm and problem record

Implementation function content: manually configure weblogic console user name and password, automatically monitor weblogic exclusive or sticky, automatically dump problem threads, automatically upload dump thread logs, automatically send SMS and automatically broadcast Chinese voice.

weblog console config. To be monitored xml

One console manages multiple nodes on multiple servers.

<?xml version="1.0" encoding="gb2312"?>
		<weblogic name="hxhd" ip="" port="9901" username="weblogic"

The whole monitoring program adopts the server and client mode. The server generates the thread information of the problem node, pushes it to the client for alarm, dumps the problem thread and sends short messages.

package com.css.monitor;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;

public class MultiServer {
	static Logger log = Logger.getLogger(MultiServer.class);

	public static void main(String[] args) {
		try {"Create server-side ServerSocket object,Waiting for client connection-------------------------");
			ServerSocket serverSocket = new ServerSocket(6666);
			// 2. Create a thread pool so that multiple clients can be processed
			ThreadPoolExecutor ThreadPoolExecutor = (java.util.concurrent.ThreadPoolExecutor) Executors
			ScheduledThreadPoolExecutor ScheduledThreadPoolExecutor = (ScheduledThreadPoolExecutor) Executors
			ScheduledThreadPoolExecutor.scheduleAtFixedRate(new ServerTestTask(), 1, 3, TimeUnit.SECONDS);

			ThreadPoolExecutor.execute(new ThreadMonitor());

			for (int i = 0; i < 10; i++) {
				// 3. Listening client
				Socket socket = serverSocket.accept();"There are new clients joining-----------------------");
				// 4. Start thread"Server start thread listening begin--------------------");
				System.out.println("getActiveCount:" + ThreadPoolExecutor.getActiveCount());
				System.out.println("getCompletedTaskCount:" + ThreadPoolExecutor.getCompletedTaskCount());
				System.out.println("getCorePoolSize:" + ThreadPoolExecutor.getCorePoolSize());
				System.out.println("getLargestPoolSize:" + ThreadPoolExecutor.getLargestPoolSize());
				System.out.println("getPoolSize:" + ThreadPoolExecutor.getPoolSize());
				System.out.println("getTaskCount:" + ThreadPoolExecutor.getTaskCount());
				ServerListener r = new ServerListener(socket);
				System.out.println("Server start thread listening end--------------------");
			// 5. Close the thread pool
			// 6. Shut down the server
		} catch (IOException e) {

The server side runs the main method of MultiServer class, which is managed in the way of thread pool. Start the server port 6666 through ServerSocket, and the client listens to this port to realize data transmission.

ThreadMonitor mainly implements server-side thread monitoring.

ServerListener is mainly used to monitor client connections on the server side. Up to 10 clients can be monitored simultaneously.

ServerTestTask is mainly used to monitor whether the client is disconnected and maintain the client connection.

ParserForXml mainly implements server-side parsing of config XML, establish a connection with the weblogic console, and save it to the JMXmap static variable.

ThreadDump mainly realizes server-side automatic thread dump and executes server shell script through remote login.

				"sh /weblogic/Oracle/Middleware/user_projects/domains/ hxhd_jlsw_svr001 sdfsdfsd");

The function classes CodeUtil and ShortMsgUtil of the server mainly realize the function of sending SMS, and the foreground needs to be supported by the SMS platform.

DBoption is mainly used to record abnormal threads on the server side. this file needs to be placed in the application server in advance. At the specified location (/ weblogic/Oracle/Middleware/user_projects/domains/, the user automatically dumps the file and automatically uploads the ftp server (provided that the ftp server needs to be built by himself).

The client needs to execute MultiClient class to realize voice alarm.

ClientReadServer mainly realizes that the client receives the problem nodes from the server. Notify the operation and maintenance personnel for handling.

The client uses jacob, which can realize the function of text to voice.

Note that 32-bit and 64 bit windows clients need to register two dll files.

nodeName. The properties file is the Chinese cross reference of weblogic node names.

ClientSendServer mainly realizes the simple interaction between client and server.

The main purpose of ClientTestTask is to prevent the client from dropping the line by constantly sending information to the server.

The singer folder is not used for the time being, so it is not necessary to consider.

The entire directory structure is:

Finally, when running the program, it is recommended to package it into two jar packages, one jar for the server and one jar for the client

In this paper, the fragment code is found on the Internet, and the whole business processing process and its code integration process are written by ourselves.

Wish you time effective operation and maintenance, happy operation and maintenance.

Keywords: Java Weblogic

Added by denoteone on Sun, 16 Jan 2022 04:57:09 +0200