I. Common commands
View the process tree by pstree. We can clearly see the relationship between processes;
Top: view resources occupied by various processes;
Du-h -- Max-depth = 1 shows the size of all subdirectories in the current directory;
W. View server load
Bigip uses the command "bigip sh $ {IP/machine name} {username}" on the pre-release machine to check whether the machine is in the disable or enable status on F5.
GM. Sh "curl http: // localhost/monitor/OK .html" Check the Health Check page of each server on the pre-release machine.
GM. Sh "ps amx | grep httpd | WC-L" check the number of HTTP connections of each server on the pre-release Machine
2. pseudo files under Proc. For example, meminfo checks memory information and cpuinfo kernel information.
CAT/proc/cpuinfo checks CPU information. Some of our programs have been optimized based on the number of CPU cores (such as memcached, fake multi-core may cause some bugs .)
If the baike-web1 is 4-core, the baike-web2 is dual-core hyper-threading.
All logical processors with the same physical ID share the same physical outlet. Each physical ID represents a unique physical encapsulation. Siblings indicates the number of logical processors in this physical encapsulation. If no logical processor exists, it indicates 1. Each core ID represents a unique processor kernel. All logical processors with the core ID are located on the same processor kernel. If more than one logical processor has the same core ID and physical ID, The system supports hyper-threading (HT) technology. If two or more logical processors have the same physical ID but the core ID is different, it indicates that this is a multi-core processor.
Iii. Network Connection
Netstat:-T: TCP link information;-u: UDP link information;-N: IP address directly, no name conversion;-P: display the corresponding process PID and name (root permission required)
If you want to view more detailed usage information about sockets, you can use lsof.
A) netstat-anp | grep Java | grep 3306 | WC-l checks the number of connections to the database in the Java Process
B) netstat-Na | grep established | awk '{print $4}' | grep ": 80 $" | WC-l check the number of established ports 80
C) netstat-Na | grep ": 2088" check the number of connections to the search engine
Iv. Dump JAVA process stack
A) Kill-3 $ {JAVA process ID}. You can view the output in the Java Process log (JBoss is recorded in jboss_stdout.log)
B) jstack $ PID. Directly dump the stack information of the current process.
The thread dump information mainly focuses on the thread status and its execution stack. Especially when the load is very high, we can see what the thread is doing through thread dump and find out the problem. The thread status is generally three types: runable: currently available threads, waiting on monitor: threads active wait, waiting for monitor entry: threads and other locks. when the CPU is busy, pay attention to the runnable thread. When the CPU is idle, pay attention to the waiting for monitor entry thread.
V. Java memory overflow
1. You can use jstat-gcutil $ {pid} {interval} to check the dynamic information of Java memory collection. Interval-indicates the interval printing time, in milliseconds
The parameter meanings in the figure are as follows:
Percentage of used space in Region vor space 0 on S0-heap
Percentage of used space in Region 1 of region vor space on S1-heap
Percentage of space used in Eden space on e-heap
Percentage of space used in the old space area on o-heap
Percentage of space used in the p-Perm space area
Ygc-number of young GC times from application startup to sampling
Ygct-time taken by young GC from application startup to sampling (unit: seconds)
FGC-number of times full GC occurs from application startup to sampling
Fgct-time taken from application startup to full GC during sampling (unit: seconds)
2. Use jmap to dump all objects in Java memory and analyze the deadlock location.
Jmap-histo $ PID: Quickly view the size and quantity of each Java object in the current Memory
Jmap-dump: Live, format = B, file = heap. DMP $ PID can copy all information in the JVM stack to the file head. pay attention to this heap in DMP. the DMP file will be relatively large. The memory allocated by JBoss online is generally 2 GB. When the memory overflows, dump the head. the DMP file is also 2 GB, so the dump time is also relatively long, usually half an hour.
After the log file is generated, run the command "jhat-J-mx768m-port 7001 heap. dmp" to analyze the stack log (Be sure not to analyze it online on the server ). Access http: // localhost: 7001 to view the analysis report.
Alternatively, you can use the mat plug-in Analysis of Eclipse, which analyzes the distribution of Java objects in the memory in a graphical form: (plug-in address http://download.eclipse.org/mat/1.0/update-site/). After importing, you can generate a graphical report
6. generate an alarm on port 7001.
Generally, JBoss crashes. Because the Java Process has exited. 1 first, check jboss_stdout.log. It will tell you some information about JBoss crash. It will also tell you a detailed error report on JBoss crash, location:/Web-deploy/bin/hs_err_pid.log
VII. Cookie Log Analysis
Cat cookie_log | awk '{print $1}' | grep-V "172.16" | grep-V "127.0.0.1" | sort | uniq-c | sort-N | tail-N 10 extract the top 10 IP addresses.
Cat cookie_log | grep '09/DEC/2010:18:01 '| WC-l checks the total access volume for this minute.
Cat cookie_log | grep 'HTTP/.../"[4 | 5] '| more view the Error Response Request.
Cat cookie_log | grep-e 'googlebot | baiduspider '| WC-l counts the visits of Google and javaske crawlers.
Common server maintenance commands