システム管理者が知っておくべき20のLinuxシステムモニタリングツール

たまたまWebを見ていたらこんな記事を見つけました。

いくつか初めてみるコマンドがあったので、部屋にある環境でやってみることにしました。

pmap

プロセスがメモリをどう使っているのかを表示出来る模様。

プロセスIDを指定するらしい。

# pmap 1
1:   init [3]
001f2000     88K r-x--  /lib/ld-2.3.4.so
00208000      4K r----  /lib/ld-2.3.4.so
00209000      4K rw---  /lib/ld-2.3.4.so
0020c000   1192K r-x--  /lib/tls/libc-2.3.4.so
00336000      8K r----  /lib/tls/libc-2.3.4.so
00338000      8K rw---  /lib/tls/libc-2.3.4.so
0033a000      8K rw---    [ anon ]
0033e000     52K r-x--  /lib/libsepol.so.1
0034b000      4K rw---  /lib/libsepol.so.1
0034c000     32K rw---    [ anon ]
0037b000     52K r-x--  /lib/libselinux.so.1
00388000      4K rw---  /lib/libselinux.so.1
08048000     28K r-x--  /sbin/init
0804f000      4K rw---  /sbin/init
09afc000    132K rw---    [ anon ]
b7f8d000      8K rw---    [ anon ]
bff65000    620K rw---    [ stack ]
ffffe000      4K r-x--    [ anon ]
 total     2252K

d オプションでオフセットとデバイスNo.付きで表示。
x オプションはより詳細な表示。

# pmap -d 1
1:   init [3]
Address   Kbytes Mode  Offset           Device    Mapping
001f2000      88 r-x-- 0000000000000000 008:00003 ld-2.3.4.so
00208000       4 r---- 0000000000015000 008:00003 ld-2.3.4.so
00209000       4 rw--- 0000000000016000 008:00003 ld-2.3.4.so
0020c000    1192 r-x-- 0000000000000000 008:00003 libc-2.3.4.so
00336000       8 r---- 0000000000129000 008:00003 libc-2.3.4.so
00338000       8 rw--- 000000000012b000 008:00003 libc-2.3.4.so
0033a000       8 rw--- 000000000033a000 000:00000   [ anon ]
0033e000      52 r-x-- 0000000000000000 008:00003 libsepol.so.1
0034b000       4 rw--- 000000000000c000 008:00003 libsepol.so.1
0034c000      32 rw--- 000000000034c000 000:00000   [ anon ]
0037b000      52 r-x-- 0000000000000000 008:00003 libselinux.so.1
00388000       4 rw--- 000000000000d000 008:00003 libselinux.so.1
08048000      28 r-x-- 0000000000000000 008:00003 init
0804f000       4 rw--- 0000000000007000 008:00003 init
09afc000     132 rw--- 0000000009afc000 000:00000   [ anon ]
b7f8d000       8 rw--- 00000000b7f8d000 000:00000   [ anon ]
bff65000     620 rw--- 00000000bff65000 000:00000   [ stack ]
ffffe000       4 r-x-- 0000000000000000 000:00000   [ anon ]
mapped: 2252K    writeable/private: 824K    shared: 0K

# pmap -x 1
1:   init [3]
Address   Kbytes     RSS    Anon  Locked Mode   Mapping
001f2000      88       -       -       - r-x--  ld-2.3.4.so
00208000       4       -       -       - r----  ld-2.3.4.so
00209000       4       -       -       - rw---  ld-2.3.4.so
0020c000    1192       -       -       - r-x--  libc-2.3.4.so
00336000       8       -       -       - r----  libc-2.3.4.so
00338000       8       -       -       - rw---  libc-2.3.4.so
0033a000       8       -       -       - rw---    [ anon ]
0033e000      52       -       -       - r-x--  libsepol.so.1
0034b000       4       -       -       - rw---  libsepol.so.1
0034c000      32       -       -       - rw---    [ anon ]
0037b000      52       -       -       - r-x--  libselinux.so.1
00388000       4       -       -       - rw---  libselinux.so.1
08048000      28       -       -       - r-x--  init
0804f000       4       -       -       - rw---  init
09afc000     132       -       -       - rw---    [ anon ]
b7f8d000       8       -       -       - rw---    [ anon ]
bff65000     620       -       -       - rw---    [ stack ]
ffffe000       4       -       -       - r-x--    [ anon ]
-------- ------- ------- ------- -------
total kB    2252       -       -       -

トラブルシュートやプロファイリング用にいいかも。

使いたいときは「procps」パッケージが入っていればいいみたいです。

# rpm -qf /usr/bin/pmap
procps-3.2.3-8.17
ss

ソケットの状態を表示してくれるコマンドらしいです。
manが無かったので一瞬えっ?と思いましたが、
同じサイトのここに結構詳しい使い方が。

「ss -s」で現在の接続状態を表示。

# ss -s
Total: 51 (kernel 52)
TCP:   6 (estab 1, closed 1, orphaned 0, synrecv 0, timewait 0/0), ports 4

Transport Total     IP        IPv6
*         52        -         -
RAW       0         0         0
UDP       3         3         0
TCP       5         2         3
INET      8         5         3
FRAG      0         0         0

「ss -l」で一覧表示。試したときはなぜかIPv6アドレスで表示されました。
IPv4で通信しているのに。。。
pオプションをつけると、さらにプロセス情報も追記されます。

# ss -l
Recv-Q Send-Q    Local Address:Port                      Peer Address:Port
0      0                                       *:sunrpc                                *:*
0      0         ::xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:http    ::xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:* 
0      0         ::xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:ssh     ::xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:*     
0      0                                       *:668                                   *:*

# ss -pl
Recv-Q Send-Q    Local Address:Port                      Peer Address:Port
0      0                                       *:sunrpc                                *:*   users:(("portmap",3021,4))
0      0         ::xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:http    ::xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:*   users:(("httpd",4066,3),("httpd",4068,3),("httpd",4070,3))
0      0         ::xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:ssh     ::xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:*   users:(("sshd",3174,3))
0      0                                       *:668                                   *:*   users:(("rpc.statd",3030,8))

なお、tオプション、uオプションでそれぞれ、TCP, UDPのものだけ出力できるようです。

こっちは「iproute」パッケージです。

# rpm -qf /usr/sbin/ss
iproute-2.6.9-4.el4
iptraf

説明を見る限り、リアルタイムでネットワークの状態(パケットの送受信状況?)を見られるみたいです。
あいにく、触った環境には入ってなかったので、今度どこかで試してみようと思います。

感想

まだまだ知らないコマンドっていっぱいあるなぁと思いました。
コマン道は奥が深い。

今日はこんなところで。