Created
December 28, 2015 01:04
-
-
Save diablowu/c6555090e55c8c4f22c2 to your computer and use it in GitHub Desktop.
tomcat dbcp data monitor jsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%@page trimDirectiveWhitespaces="true" %> | |
| <%@page import="java.io.*"%> | |
| <%@page import="javax.naming.InitialContext" %> | |
| <%@page import="javax.naming.NamingException" %> | |
| <%@page import="javax.sql.DataSource" %> | |
| <%@page import="java.nio.charset.Charset"%> | |
| <%@page import="org.apache.tomcat.dbcp.dbcp.BasicDataSource" %> | |
| <%@ page language="java" contentType="text/html; charset=UTF-8" | |
| pageEncoding="UTF-8"%> | |
| <% | |
| final String FMT = "{" | |
| +"\"init\":%d," | |
| +"\"maxi\":%d," | |
| +"\"mini\":%d," | |
| +"\"numi\":%d," | |
| +"\"numa\":%d," | |
| +"\"maxa\":%d," | |
| +"\"maxw\":%d," | |
| +"\"maxp\":%d" | |
| +"}"; | |
| String token = request.getParameter("t_o_k_e_n"); | |
| if("CyRCvYhP8oj7KgCtMGRb".equals(token)){ | |
| InitialContext context = context = new InitialContext(); | |
| BasicDataSource ds = | |
| (BasicDataSource) context.lookup("java:comp/env/jdbc/ds"); | |
| out.println( | |
| String.format(FMT | |
| ,ds.getInitialSize() | |
| ,ds.getMaxIdle() | |
| ,ds.getMinIdle() | |
| ,ds.getNumIdle() | |
| ,ds.getNumActive() | |
| ,ds.getMaxActive() | |
| ,ds.getMaxWait() | |
| ,ds.getMaxOpenPreparedStatements() | |
| ) | |
| ); | |
| } | |
| %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment