ablog

不器用で落着きのない技術者のメモ

grep の検索結果:

大きなテキストファイルをawkで処理するときにcatで投げ込むと速い理由

….txt 2>&1|grep -C2 fadvise $ /usr/src/gnu/coreutils-8.24/src/cat --version|head -1 cat (GNU coreutils) 8.24 $ strace /usr/src/gnu/coreutils-8.24/src/cat sample.txt 2>&1|grep -C2 fadvise open("sample.txt", O_RDONLY) = 3 fstat(3, {st_mode=S_I…

Perlワンライナー集

…。 awk、sed、grep の正規表現の書き方などをそれぞれ覚えれない。awk、sed、grep でできることはだいたい Perl でできるので、Perl に絞ると覚えることを減らせる*2。 最小限の労力で最大限の仕事ができる。ちょっとしたプログラムを書くような処理でも Perl ワンライナーを使うとたった1行で済むことがあります*3。 Perlワンライナー集 一部、Perl 以外に bash、find、xargs なども含んでいます。 レコードセパレータを変更する per…

funcgraph で Linux カーネル内のボトルネックをミクロに追跡する

… # ps -ef|grep [c]hrome # ./funcgraph -Htp 4511 vfs_write 参考 perf-tools/funcgraph at master · brendangregg/perf-tools · GitHub Ftrace: The hidden light switch [LWN.net] Ftrace と Systrace - steps to phantasien Velocity 2015 linux perf tools …

VirtualBox を 4.3.20 から 4.3.22 にアップグレードした

…$ ps auxw|grep yum|grep -v grep root 4774 11.9 0.9 446356 148708 pts/0 S+ 10:17 2:05 /usr/bin/python /usr/bin/yum update VirtualBox-4.3 $ watch pstree -alp 4774 yum,4774 /usr/bin/yum update VirtualBox-4.3 └─sh,5134 /var/tmp/rpm-tmp.3nXBqe 2…

最近使った Perl ワンライナーのメモ

…{map{$t=$_ and print $t;map{print qq/$t\t$_\t$h->{$t}->{$_}/} keys %{$h->{$_}}} keys %$h}'' strace.loggrep -hA 20 '^top -' top.logperl -lane '/top - ([\d:]+)/ and $t=$1;$F[0]=~/\d+/ and printf (qq/%s %s%s\n/,$t,$_,lc(sprintf(q/%X/,$F[0])))'

Javaのスレッドダンプの読み方

…$ ps auxw|grep [j]ava yazekats 21083 0.0 0.0 5411796 14924 pts/0 Sl+ 15:36 0:00 java Counter $ kill -3 21083 Java 7u4 HotSpot では jcmd で取得できるらしいです。 $ jcmd 30759 sun.tools.jcmd.JCmd 30444 weblogic.Server $ jcmd 30444 Thread.print|head -10 304…

micbench でノートPCのメモリアクセスレイテンシを計測してみた

…/cpuinfo |grep 'model name'|head -1 model name : Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz $ cd /sys/devices/system/cpu/cpu0/cache $ echo `cat index0/level` `cat index0/type` `cat index0/size` 1 Data 32K $ echo `cat index1/level` `cat index1…

gdb でレジスタの値を書き換えてみる

…$ ps auxw|grep [w]rite_loop yazekats 5873 97.6 0.0 3968 284 pts/0 R+ 22:01 1:18 ./write_loop ファイルディスクリプタを確認する。 $ ls -l /proc/5873/fd total 0 lrwx------ 1 yazekats yazekats 64 Dec 19 22:10 0 -> /dev/pts/0 l-wx------ 1 yazekats yazekats 64 De…

Huge Page の解放について

…linux ~]# grep -i hugepage /proc/meminfo AnonHugePages: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB [root@yazekats-linux ~]# sysctl -w vm.nr_hugepages=200 vm.nr_hugepages = 200 [root@y…

micbench をインストールしてみた

…/cpuinfo |grep 'model name'|head -1 model name : Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz [yazekats@yazekats-linux ~]$ cd /sys/devices/system/cpu/cpu0/cache [yazekats@yazekats-linux cache]$ echo `cat index0/level` `cat index0/type` `cat ind…

prociostat.pl と visualize_prociostat.R で Linux のプロセスのボトルネックを分析する

…対象プロセス(今回はgrep)を実行する $ grep -R foo . > /dev/null 2>&1 & [1] 14520 prociostat.pl でプロセスの性能情報をCSVに記録する $ perl prociostat.pl -C -p 14520 pid 14520 uid 501 user 20.16 sys 8.16 r 11112370176 w 0 cmd grep-Rfoo. ^CBye! ←Ctrl+Cで停止 $ ls -1 process.14…

LinuxでCPU使用率を上げるコマンド

…d -multi `grep processor /proc/cpuinfo|wc -l` としてやれば良いです。 最後に書籍紹介。絵で見てわかるシステムパフォーマンスの仕組み作者: 小田圭二,榑松谷仁,平山毅,岡田憲昌出版社/メーカー: 翔泳社発売日: 2014/06/21メディア: 単行本(ソフトカバー)この商品を含むブログ (2件) を見るSystems Performance: Enterprise and the Cloud (English Edition)作者:…

yum update したら"Another app is currently holding the yum lock; waiting for it to exit..."と怒られる

…# ps -elf|grep yum 0 S root 3982 3625 3 80 0 - 131821 poll_s 09:28 ? 00:00:22 /usr/bin/python /usr/share/PackageKit/helpers/yum/yumBackend.py get-updates none 0 S root 4589 4470 0 80 0 - 25825 pipe_w 09:40 pts/1 00:00:00 grep yum # kill 398…

gettimeofday(2) は VDSO によりユーザー空間で実行される

…race -p `pgrep gettimeofday` Process 25792 attached - interrupt to quit ltrace おおっ、ひたすら gettimeofday が出力される $ ltrace -p `pgrep gettimeofday` gettimeofday(0x7fff18b60a60, NULL) = 0 gettimeofday(0x7fff18b60a60, NULL) = 0 gettimeofday(0x7fff18…

Linux で huge page を使っているプロセスを調べる方法

…linux ~]# grep -C 12 'KernelPageSize: 2048 kB' /proc/3834/smaps 2aaaaac00000-2aaabac00000 rw-s 00000000 00:0b 1277985 /SYSV00000002 (deleted) <-- huge page を使っているアドレス(2aaaaac00000-2aaabac00000)やshmid(1277985) Size: 262144 kB <-- huge page を…

libaio の aio コンテキスト数を調べる

…yazekats% grep io_setup strace_fio.log 4790 1396892502.061498 io_setup(2147483647, <unfinished ...> 4790 1396892502.061657 <... io_setup resumed> 0x223e210) = -1 EINVAL (Invalid argument) 4789 1396892502.061683 io_setup(2147483647, <unfinis…

ソースコード検索ツール ack を使ってみた

ソースコード検索ツール ack の存在を知ったのは4年位前だけど、今更使ってみた。*1 インストール # yum install ack 使ってみる 良い感じ。 参考 ack使い方メモ - アルパカDiary Pro *1:grepやackよりも速いコード検索ツールのagをローカルビルドインストールする - Qiita とかいう記事もあり、今時は他のツールが流行っているのかもしれないが

ls -f で返ってくるリストは何の順か?

… tmp 2>&1|grep getdents execve("./getdents_test", ["./getdents_test", "tmp"], [/* 50 vars */]) = 0 getdents(3, /* 42 entries */, 1024) = 1008 getdents(3, /* 42 entries */, 1024) = 1008 getdents(3, /* 18 entries */, 1024) = 432 getdents(3, /…

ls のソースを読んでプログラマになりました

…ux work]$ grep getdents strace_ls.log getdents(3, /* 1050 entries */, 32768) = 32760 <0.001016> getdents(3, /* 1048 entries */, 32768) = 32752 <0.000636> getdents(3, /* 1046 entries */, 32768) = 32768 <0.001006> getdents(3, /* 1049 entries …

hugepage-shm.c をコンパイルして実行してみる

…/meminfo |grep -i huge AnonHugePages: 0 kB HugePages_Total: 200 HugePages_Free: 200 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB # gdb ./hugepage-shm NU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6) Copyright (C) 2010 Free So…

HugePages は free コマンドで見ると used に計上される

… for easy grepping and expansion. 47 */ 48 seq_printf(m, 49 "MemTotal: %8lu kB\n" 50 "MemFree: %8lu kB\n" 51 "Buffers: %8lu kB\n" 52 "Cached: %8lu kB\n" ... 101 K(i.totalram), 102 K(i.freeram), 103 K(i.bufferram), 104 K(cached), 105 K(total…

DoCoMo L-05A を Oracle Linux 6.4 on ThinkPad X230 から利用する

…# lsusb | grep LG Bus 003 Device 002: ID 1004:613a LG Electronics, Inc. [root@yazekats-linux etc]# eject /dev/sr0 [root@yazekats-linux etc]# lsusb | grep LG Bus 003 Device 003: ID 1004:6124 LG Electronics, Inc. vpnagent を停止する*2 [root@yazeka…

ファイルが O_DIRECT フラグを指定してオープンされているか確認する方法

…2767 2>&1|grep fdinfo open("/proc/1147/fdinfo/3", O_RDONLY) = 4 open("/proc/32767/fdinfo/0", O_RDONLY) = 7 open("/proc/32767/fdinfo/1", O_RDONLY) = 7 open("/proc/32767/fdinfo/2", O_RDONLY) = 7 参考 io - How to tell if a given process opened f…

Oracle Database のサーバー・プロセスが通信する際にどのようなソケットオプションを使っているか調べる

…]# ps -ef|grep [t]ns oracle 3249 1 0 19:35 ? 00:00:00 /home/oracle/app/oracle/product/11.2.0/dbhome_2/bin/tnslsnr LISTENER -inherit strace でリスナープロセスと fork されるプロセスのシステムコールをトレースする。 [root@localhost ~]# strace -tf -p 3249 -o strace.log テストケース実行…

Oracle Netトレース・ファイルを出力する

…$ ps auxw|grep [o]racleorcl oracle 3204 0.1 6.6 621024 60600 ? Ss 07:56 0:01 oracleorcl (LOCAL=NO) トレース・ファイルのパスを確認する。 $ ls -l /proc/3204/fd total 0 lr-x------ 1 oracle oracle 64 Apr 20 08:08 0 -> /dev/null l-wx------ 1 oracle oracle 64 Apr …

SQLトレースとstrace

…lhost ~]$ grep 'pread64(257' strace.log|head -5 17:52:37.206294 pread64(257, "\6\242\0\0\263\f\0\1\303\364\356\0\0\0\1\6\306\313\0\0\1\0\0\0'\256\1\0j\350\356\0"..., 40960, 26632192) = 40960 17:52:37.206677 pread64(257, "\6\242\0\0\300\f\0\…

SQLトレースに関するメモ

…t trace]$ grep tim orcl_ora_2924.trc|head -1 PARSING IN CURSOR #18872088 len=32 dep=0 uid=346 oct=42 lid=346 tim=1350518824929181 hv=1569151342 ad='adfeb0' sqlid='4tk6t8tfsfqbf' [oracle@localhost trace]$ sqlplus neo/zion SQL> select to_char…

SystemTap で特定のプロセスが発行したシステムコールを表示する

…$ ps -elf|grep [p]ing 4 S oracle 3198 3169 0 75 0 - 493 416062 00:44 pts/0 00:00:00 ping localhost SystemTap を使ってモニタリングしてみる。 # stap ./targeted.stp -x 3198 Syscall: gettimeofday Syscall: gettimeofday Syscall: sendmsg Syscall: recvmsg Syscall…

ORACLE_HOME の下のディレクトリやファイルのパーミッションについて調べたいとき

find . -name '*.log' -print0|xargs -0 grep chmod

Apache 2.4 で configure 実行時に「configure: error: APR not found」と怒られる

…cking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64…