SlideShare a Scribd company logo
プロセスアカウンティングで
  バイナリに出会った
acct   パッケージを使ってみる

ターミナル1
$ sudo aptitude install acct
$ tail ---disable-inotify -f /var/log/account/pacct

ターミナル2
$ ls
Lastcomm コマンド

●    Lastcomm
ls              yutaka-m pts/3    0.00 secs Sun Jan 13 15:47
less             yutaka-m pts/3      0.00 secs Sun Jan 13 15:47
lastcomm            yutaka-m pts/3     0.00 secs Sun Jan 13 15:47
問題


tail -f がちゃんと動いてない事件
 Coreutils 6.XX -> 8.13 に変更
問題

   coreutils 8.13 の tail
tail -f /var/log/account/pacct


出力なし。泣きたい。
解決?

           inotify が悪さしてる?
tail ---disable-inotify -c 0 -f /var/log/account/pacct
     出力が出ていることを確認。
出力確認
●
    tail -f を通したデータが正しいとは限らない




         もう何も信じられない!
    構造体とバイナリを突き合わせて安心したい
lsで出力されるバイナリ
tail ---disable-inotify -c 0 -f /var/log/account/pacct >/tmp/acct.log


hexdump -C /tmp/acct.log
00000000 00 03 02 88 00 00 00 00 e8 03 00 00 e8 03 00 00 |................|
00000010 87 1a 00 00 05 1a 00 00 7f 4d f2 50 00 00 00 00 |.........M.P....|
00000020 00 00 00 00 f0 15 00 00 00 00 6c 01 00 00 00 00 |..........l.....|
00000030 6c 73 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |ls..............|
00000040
acct_v3 構造体
struct acct_v3 {
     char     ac_flag;      /* Flags */
     char     ac_version; /* Always set to ACCT_VERSION (3) */
     u_int16_t ac_tty;       /* Controlling terminal */
     u_int32_t ac_exitcode; /* Process termination status */
     u_int32_t ac_uid;        /* Real user ID */
     u_int32_t ac_gid;        /* Real group ID */
     u_int32_t ac_pid;        /* Process ID */
     u_int32_t ac_ppid;       /* Parent process ID */
     u_int32_t ac_btime;       /* Process creation time */
     float   ac_etime;      /* Elapsed time */
     comp_t    ac_utime;       /* User CPU time */
     comp_t    ac_stime;       /* System time */
     comp_t    ac_mem;          /* Average memory usage (kB) */
     comp_t    ac_io;        /* Characters transferred (unused) */
     comp_t    ac_rw;        /* Blocks read or written
                         (unused) */
     comp_t    ac_minflt;     /* Minor page faults */
     comp_t    ac_majflt;     /* Major page faults */
     comp_t    ac_swaps;        /* Number of swaps (unused) */
     char     ac_comm[ACCT_COMM]; /* Command name */
};
バイナリを検証
           フラグ バージョン              TTY exitcode        userid        groupid


00000000 00 03 02 88 00 00 00 00 e8 03 00 00 e8 03 00 00 |................|
00000010 87 1a 00 00 05 1a 00 00 7f 4d f2 50 00 00 00 00 |.........M.P....|
00000020 00 00 00 00 f0 15 00 00 00 00 6c 01 00 00 00 00 |..........l.....|
00000030 6c 73 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |ls..............|
00000040
                           pid    ppid   実行時間        Elapsed time
  User CPU time   System time    memory usage (kB)

                                              Minor page faults     Major page faults
                                    Command name
検証結果



データは正しい

More Related Content

KEY
Emacs 使いが Vim を使ってみた(ちょっとだけGit)
PDF
CUDAメモ
PDF
MacPort japanese_ver.1.0
PDF
2INPUT OR GATEの等価回路モデル
PDF
2INPUT COMPARATORの等価回路モデル
PDF
Delayの等価回路モデル
PDF
A_road_to_AMBER_simulations_ver_1.0
PDF
アセンブラ短歌(第2回APASEC+第2期サイボウズ・ラボユース合同勉強会)
Emacs 使いが Vim を使ってみた(ちょっとだけGit)
CUDAメモ
MacPort japanese_ver.1.0
2INPUT OR GATEの等価回路モデル
2INPUT COMPARATORの等価回路モデル
Delayの等価回路モデル
A_road_to_AMBER_simulations_ver_1.0
アセンブラ短歌(第2回APASEC+第2期サイボウズ・ラボユース合同勉強会)

What's hot (19)

PDF
HYSTERESIS COMPARATORの等価回路モデル
PDF
オレオレPHPのつくり方
PDF
REFERENCEの等価回路モデル
ODP
Xen4.0 and vt-d Network Performance Benchmark
PDF
あなたの知らないnopたち@ラボユース合宿
PDF
おれが考えた見やすい通知
PDF
microLIFA for LabVIEW & Arduino User
PDF
Assembly Tanka on Web - Aiko Kenji
PDF
OpenCM IDE、OpenCM 485 EXPを用いてのDynamixel Xシリーズの制御
PDF
ひよこch 配信中
PDF
Memory sanitizer
PPTX
20150603卒研進捗LT (share)
PDF
画像処理ボード入門およびビデオ信号入門
PPTX
FPGAでゲーム機を作ろう! 第6回
ODP
カーネルモジュールプログラミング超入門 #1(仮)
PPTX
Kiso sekkei 01rev03
PDF
MMIO on VT-x
PDF
How_to_install_OpenCV_ver1.0
PDF
初めてのCPUを作ってみた
HYSTERESIS COMPARATORの等価回路モデル
オレオレPHPのつくり方
REFERENCEの等価回路モデル
Xen4.0 and vt-d Network Performance Benchmark
あなたの知らないnopたち@ラボユース合宿
おれが考えた見やすい通知
microLIFA for LabVIEW & Arduino User
Assembly Tanka on Web - Aiko Kenji
OpenCM IDE、OpenCM 485 EXPを用いてのDynamixel Xシリーズの制御
ひよこch 配信中
Memory sanitizer
20150603卒研進捗LT (share)
画像処理ボード入門およびビデオ信号入門
FPGAでゲーム機を作ろう! 第6回
カーネルモジュールプログラミング超入門 #1(仮)
Kiso sekkei 01rev03
MMIO on VT-x
How_to_install_OpenCV_ver1.0
初めてのCPUを作ってみた
Ad

Similar to Acct v3 binary (20)

ODP
Android デバッグ小ネタ
PDF
[data analytics showcase] B12: サーバー1,000台を監視するということ by 株式会社インサイトテクノロジー 小幡 一郎
PPTX
Linux Performance Analysis in 15 minutes
PPTX
そうだ 検証、しよう。
PDF
MINCS – containers in the shell script
PDF
MySQLerの7つ道具
PDF
Gingerbread
ODP
「前回の COMSTAR ネタに刺激されてしまったので、オレも COMSTAR を使ってみた。」(仮)
PPT
PDF
Linuxのプロセススケジューラ(Reading the Linux process scheduler)
PDF
Ubuntuで始めるコンテナ技術入門
PDF
[TL06] 日本の第一人者が C# の現状と今後を徹底解説! 「この素晴らしい C# に祝福を!」
PPTX
Pub/Sub model, msm, and asio
ODP
DRBD/Heartbeat/Pacemakerで作るKVM仮想化クラスタ
PDF
Task Spooler を試した
PDF
15. running deploying camel
PDF
高速ネットワーク最新動向と具体例 (ENOG58 Meeting)
PDF
JDKツール使ってますか
PPTX
M5Stack互換機を作った話
PDF
debugging server with strace
Android デバッグ小ネタ
[data analytics showcase] B12: サーバー1,000台を監視するということ by 株式会社インサイトテクノロジー 小幡 一郎
Linux Performance Analysis in 15 minutes
そうだ 検証、しよう。
MINCS – containers in the shell script
MySQLerの7つ道具
Gingerbread
「前回の COMSTAR ネタに刺激されてしまったので、オレも COMSTAR を使ってみた。」(仮)
Linuxのプロセススケジューラ(Reading the Linux process scheduler)
Ubuntuで始めるコンテナ技術入門
[TL06] 日本の第一人者が C# の現状と今後を徹底解説! 「この素晴らしい C# に祝福を!」
Pub/Sub model, msm, and asio
DRBD/Heartbeat/Pacemakerで作るKVM仮想化クラスタ
Task Spooler を試した
15. running deploying camel
高速ネットワーク最新動向と具体例 (ENOG58 Meeting)
JDKツール使ってますか
M5Stack互換機を作った話
debugging server with strace
Ad

Acct v3 binary

  • 2. acct パッケージを使ってみる ターミナル1 $ sudo aptitude install acct $ tail ---disable-inotify -f /var/log/account/pacct ターミナル2 $ ls
  • 3. Lastcomm コマンド ● Lastcomm ls yutaka-m pts/3 0.00 secs Sun Jan 13 15:47 less yutaka-m pts/3 0.00 secs Sun Jan 13 15:47 lastcomm yutaka-m pts/3 0.00 secs Sun Jan 13 15:47
  • 4. 問題 tail -f がちゃんと動いてない事件 Coreutils 6.XX -> 8.13 に変更
  • 5. 問題 coreutils 8.13 の tail tail -f /var/log/account/pacct 出力なし。泣きたい。
  • 6. 解決? inotify が悪さしてる? tail ---disable-inotify -c 0 -f /var/log/account/pacct 出力が出ていることを確認。
  • 7. 出力確認 ● tail -f を通したデータが正しいとは限らない もう何も信じられない! 構造体とバイナリを突き合わせて安心したい
  • 8. lsで出力されるバイナリ tail ---disable-inotify -c 0 -f /var/log/account/pacct >/tmp/acct.log hexdump -C /tmp/acct.log 00000000 00 03 02 88 00 00 00 00 e8 03 00 00 e8 03 00 00 |................| 00000010 87 1a 00 00 05 1a 00 00 7f 4d f2 50 00 00 00 00 |.........M.P....| 00000020 00 00 00 00 f0 15 00 00 00 00 6c 01 00 00 00 00 |..........l.....| 00000030 6c 73 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |ls..............| 00000040
  • 9. acct_v3 構造体 struct acct_v3 { char ac_flag; /* Flags */ char ac_version; /* Always set to ACCT_VERSION (3) */ u_int16_t ac_tty; /* Controlling terminal */ u_int32_t ac_exitcode; /* Process termination status */ u_int32_t ac_uid; /* Real user ID */ u_int32_t ac_gid; /* Real group ID */ u_int32_t ac_pid; /* Process ID */ u_int32_t ac_ppid; /* Parent process ID */ u_int32_t ac_btime; /* Process creation time */ float ac_etime; /* Elapsed time */ comp_t ac_utime; /* User CPU time */ comp_t ac_stime; /* System time */ comp_t ac_mem; /* Average memory usage (kB) */ comp_t ac_io; /* Characters transferred (unused) */ comp_t ac_rw; /* Blocks read or written (unused) */ comp_t ac_minflt; /* Minor page faults */ comp_t ac_majflt; /* Major page faults */ comp_t ac_swaps; /* Number of swaps (unused) */ char ac_comm[ACCT_COMM]; /* Command name */ };
  • 10. バイナリを検証 フラグ バージョン TTY exitcode userid groupid 00000000 00 03 02 88 00 00 00 00 e8 03 00 00 e8 03 00 00 |................| 00000010 87 1a 00 00 05 1a 00 00 7f 4d f2 50 00 00 00 00 |.........M.P....| 00000020 00 00 00 00 f0 15 00 00 00 00 6c 01 00 00 00 00 |..........l.....| 00000030 6c 73 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |ls..............| 00000040 pid ppid 実行時間 Elapsed time User CPU time System time memory usage (kB) Minor page faults Major page faults Command name