Last active
November 16, 2015 07:38
-
-
Save diablowu/31c6818cee2d85750254 to your computer and use it in GitHub Desktop.
probe
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
| #!/bin/bash | |
| . ~/.bashrc | |
| echo "jvm statics" | |
| netstat -atnp|grep java|grep LISTEN|awk '{print $4" "$7}'|sed 's#0\.0\.0\.0:##g'|sed 's#/java##g'|while read pport | |
| do | |
| pid=`echo $pport|awk '{print $2}'` | |
| port=`echo $pport|awk '{print $1}'` | |
| echo "PID:$pid PORT:$port" | |
| $JAVA_HOME/bin/jstat -gcutil $pid | |
| echo "" | |
| done |
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 import="java.io.*"%> | |
| <%@page import="java.nio.charset.Charset"%> | |
| <%@ page language="java" contentType="text/html; charset=UTF-8" | |
| pageEncoding="UTF-8"%> | |
| <%! | |
| public String exec_cmd(String...cmd){ | |
| String lang = System.getenv("LANG"); | |
| String charset = "UTF-8"; | |
| if(lang.toLowerCase().contains("gb")){ | |
| charset = "GB18030"; | |
| } | |
| StringBuilder sb = new StringBuilder(); | |
| Runtime rt = Runtime.getRuntime(); | |
| Process p = null; | |
| InputStream is = null; | |
| try{ | |
| p = rt.exec(cmd); | |
| is = p.getInputStream(); | |
| byte[] buf = new byte[256]; | |
| int l = is.read(buf); | |
| while(l>0){ | |
| sb.append(new String(buf, 0, l, Charset.forName(charset))); | |
| l = is.read(buf); | |
| } | |
| }catch(Exception e){ | |
| e.printStackTrace(); | |
| }finally{ | |
| if(is!=null){ | |
| try { | |
| is.close(); | |
| } catch (IOException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| p.destroy(); | |
| } | |
| return sb.toString(); | |
| } | |
| %> | |
| <!DOCTYPE> | |
| <html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
| <title>probe</title> | |
| </head> | |
| <body> | |
| <h1>eth0 info</h1> | |
| <pre> | |
| <%=exec_cmd("/sbin/ifconfig", "eth0") %> | |
| </pre> | |
| <h1>uptime</h1> | |
| <pre> | |
| <%=exec_cmd("uptime") %> | |
| </pre> | |
| <h1>loadavg</h1> | |
| <pre> | |
| <%=exec_cmd("cat","/proc/loadavg") %> | |
| </pre> | |
| <h1>memory</h1> | |
| <pre> | |
| <%=exec_cmd("cat","/proc/meminfo") %> | |
| </pre> | |
| <h1>CPU statics</h1> | |
| <pre> | |
| <%=exec_cmd("iostat","-c") %> | |
| </pre> | |
| <h1>JVM Statics</h1> | |
| <pre> | |
| <%=exec_cmd("/datafile/scripts/jvmstats.sh") %> | |
| </pre> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment