java 虚拟机–新生代与老年代GC
Java 堆内存 – 老生代 新生代
http://www.blogjava.net/fancydeepin/archive/2013/09/29/jvm_heep.html
关于新生代,老生代,young gc,full gc 解释的简单易懂
10 个最好的 PHP 库用于轻松发送HTTP请求 – OPEN资讯
独家许可与独占许可
独家许可: 被许可方和许可方都可以使用,不能再有其它方使用
独占许可: 只有被许可方可以使用,许可方自己不能使用
文件操作监控
缘起
话说strace是运维的利器,可以跟踪进程的所有的系统调用;有一天,运维小明发现tmp目录下意外产生了大量图片文件,并且在不断增多,但是不知道是哪个进程写的,所以更不知道是哪个应用写的,这时候strace无能为力了(其实可以strace所有可以的进程的,有些麻烦)
曾记否,inotify是可以监控文件(目录)的访问(不仅仅是变化)的,其输出类似:
嗯,没有进程信息,咋办?
还有一个神奇: systemtap
参考文档: https://sourceware.org/systemtap/SystemTap_Beginners_Guide.pdf
这里的iotime.stp 可以用来监控文件的变化,而且包含进程信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
#! /usr/bin/env stap /* * Copyright (C) 2006-2007 Red Hat Inc. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Print out the amount of time spent in the read and write systemcall * when each file opened by the process is closed. Note that the systemtap * script needs to be running before the open operations occur for * the script to record data. * * This script could be used to to find out which files are slow to load * on a machine. e.g. * * stap iotime.stp -c 'firefox' * * Output format is: * timestamp pid (executabable) info_type path ... * * 200283135 2573 (cupsd) access /etc/printcap read: 0 write: 7063 * 200283143 2573 (cupsd) iotime /etc/printcap time: 69 * */ global start global time_io function timestamp:long() { return gettimeofday_us() - start } function proc:string() { return sprintf("%d (%s)", pid(), execname()) } probe begin { start = gettimeofday_us() } global filehandles, fileread, filewrite probe syscall.open.return { filename = user_string($filename) if ($return != -1) { filehandles[pid(), $return] = filename } else { printf("%d %s access %s fail\n", timestamp(), proc(), filename) } } probe syscall.read.return { p = pid() fd = $fd bytes = $return time = gettimeofday_us() - @entry(gettimeofday_us()) if (bytes > 0) fileread[p, fd] += bytes time_io[p, fd] <<< time } probe syscall.write.return { p = pid() fd = $fd bytes = $return time = gettimeofday_us() - @entry(gettimeofday_us()) if (bytes > 0) filewrite[p, fd] += bytes time_io[p, fd] <<< time } probe syscall.close { if ([pid(), $fd] in filehandles) { printf("%d %s access %s read: %d write: %d\n", timestamp(), proc(), filehandles[pid(), $fd], fileread[pid(), $fd], filewrite[pid(), $fd]) if (@count(time_io[pid(), $fd])) printf("%d %s iotime %s time: %d\n", timestamp(), proc(), filehandles[pid(), $fd], @sum(time_io[pid(), $fd])) } delete fileread[pid(), $fd] delete filewrite[pid(), $fd] delete filehandles[pid(), $fd] delete time_io[pid(),$fd] } |
这个脚本用来干这事儿,逻辑有些多,杀鸡用了牛刀,不过至少可以解决问题
[转载] Linux的capability深入分析 – 舒方小院 – 博客园
Linux 进程状态之 D
题记:
研究啥问题,至少要能重现啥问题
如何制造一个状态为D的进程呢?
如下:
1 2 3 4 5 |
#include <sys/types.h> #include <unistd.h> void main() { if (!vfork()) sleep(100); } |
主机内存查看方式
我们的一个96G内存的机器:
阿里云的一个4G内存的机器:
难道阿里云给的不够?
提工单给阿里云,人家说内存查看方式不对,应该是:
1 |
dmidecode | grep -A 5 "Memory Device" | grep Size | grep -v Range |
工单截屏:
甭说,还真是,如下:
那么,free看不到的那部分内存谁用了去了?
Docker一些知识
- docker容器其实(可以)在同一个父的cgroup下的,可以对这个父的cgroup进行限制,避免总量超限
- 一个机器上可以有多个docker daemon的,截止该文章诞生的时候,该功能还处于试验阶段,至少理论上是可以的: 参考: https://docs.docker.com/engine/reference/commandline/dockerd/#/running-multiple-daemons
- docker daemon可以使用不同的运行时,默认为containnerd,自动启动,并且通过socket通信;· 参考: https://docs.docker.com/engine/reference/commandline/dockerd/#/docker-runtime-execution-options