LoginSignup
4
5

More than 5 years have passed since last update.

Amazon Linux 2 に snoopy logger をインストールする

Posted at

SSH操作ログを記録したい。Amazon Linux 2で。ちょっとハマったのでメモ。
https://github.com/a2o/snoopy

Amazon Linux 1

1なら簡単に入ります。バージョンはだいぶ古いものの、EPELにRPMがありますので。

sudo yum install -y snoopy-logger --enablerepo=epel

Amazon Linux 2

EPELにパッケージが存在してません。 https://bugzilla.redhat.com/show_bug.cgi?id=1154859 として挙がったものの、進捗は無いようです。

docker run -it library/amazonlinux:2 /bin/bash
yum list | grep snoopy
yum list --enablerepo=epel | grep snoopy

Amazon Linux 2 で成功する手順

git-master 指定でなら成功。snoopy-installがリコメンドしてきた gcc などの他に、Dockerコンテナ版Amazon Linux 2 は which のインストールも必要でした。

docker run -it library/amazonlinux:2 /bin/bash
yum install -y gcc gzip make socat tar wget autoconf git libtool m4
yum install -y which
rm -f snoopy-install.sh
wget -O snoopy-install.sh https://github.com/a2o/snoopy/raw/install/doc/install/bin/snoopy-install.sh
chmod 755 snoopy-install.sh
./snoopy-install.sh git-master

成功してこのようなメッセージが出ます。

bash-4.2# ./snoopy-install.sh git-master
SNOOPY INSTALL: Required programs already present: gcc gzip make socat tar wget autoconf git libtool m4
SNOOPY INSTALL: Starting installation, log file: //snoopy-install.log
SNOOPY INSTALL: Installation mode: git-REFERENCE
SNOOPY INSTALL: Cloning git repository: https://github.com/a2o/snoopy.git
SNOOPY INSTALL: Checking out git ref: master
SNOOPY INSTALL: Git submodules: initilizing...
SNOOPY INSTALL: Git submodules: updating...
SNOOPY INSTALL: Bootstraping build environment... done.
SNOOPY INSTALL: Configuring... done.
SNOOPY INSTALL: Building... done.
SNOOPY INSTALL: Installing... done.
SNOOPY INSTALL: Enabling... done.

SNOOPY LOGGER is now installed and enabled.

TIP #1: If Snoopy is to be enabled for all processes, you need
        to restart your system, or at least all services on it.

TIP #2: If you ever need to disable Snoopy, you should use provided
        'snoopy-disable' script. Use 'snoopy-enable' to reenable it.

TIP #3: Snoopy output can usually be found somewhere in /var/log/*
        Check your syslog configuration for details.

TIP #4: Configuration file location: /etc/snoopy.ini
        See included comments for additional configuration options.

Snoopy wishes you a happy logging experience:)

bash-4.2#

メッセージにあるとおり、SSHログアウトや、EC2インスタンスの再起動などしてください。

Amazon Linux 2 で失敗する手順 (stable

stable と バージョン指定の場合、 http://source.a2o.si というサーバーから持ってこようとしているのですが、 https://github.com/a2o/snoopy/issues/146 によりダメなようです。サーバーが落ちてる理由はちょっとわからないです。まあ、そのうち復活するんじゃないでしょうか。わからんけど。

bash-4.2# ./snoopy-install.sh stable
SNOOPY INSTALL: Required programs already present: gcc gzip make socat tar wget
SNOOPY INSTALL: Starting installation, log file: //snoopy-install.log
SNOOPY INSTALL: Installation mode: package-latest-stable
SNOOPY INSTALL: Getting latest Snoopy version... ^Z

(ここで control + z。一時停止させる

[1]+  Stopped                 ./snoopy-install.sh stable
bash-4.2# bg %1
[1]+ ./snoopy-install.sh stable &

(バックグラウンドで実行を継続させる

bash-4.2# ps -auxfww
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.1  11748  3056 pts/0    Ss   05:49   0:00 /bin/bash
root      5385  0.0  0.1  11616  2660 pts/0    S    05:53   0:00 /bin/bash ./snoopy-install.sh stable
root      5389  0.0  0.0  11616  1776 pts/0    S    05:53   0:00  \_ /bin/bash ./snoopy-install.sh stable
root      5398  0.0  0.2  47116  4692 pts/0    S    05:53   0:00      \_ wget -q -O - http://source.a2o.si/download/snoopy/snoopy-latest-version.txt
root      5404  0.0  0.1  51924  3524 pts/0    R+   05:54   0:00 ps -auxfww
bash-4.2#

(するとwgetで止まってる。URLをウェブブラウザで見に行ってみると、何も反応がないことがわかる。

Amazon Linux 2 で失敗する手順 (バージョン指定

https://github.com/a2o/snoopy/issues/146 のとおりgithubのソースでバージョン指定でやってみるものの、Buildの途中で突然死します。何か出てきても使うのは怖いですね。

bash-4.2# ./snoopy-install.sh git-snoopy-2.4.6
SNOOPY INSTALL: Required programs already present: gcc gzip make socat tar wget autoconf git libtool m4
SNOOPY INSTALL: Starting installation, log file: //snoopy-install.log
SNOOPY INSTALL: Installation mode: git-REFERENCE
SNOOPY INSTALL: Cloning git repository: https://github.com/a2o/snoopy.git
SNOOPY INSTALL: Checking out git ref: snoopy-2.4.6
SNOOPY INSTALL: Git submodules: initilizing...
SNOOPY INSTALL: Git submodules: updating...
SNOOPY INSTALL: Bootstraping build environment... done.
SNOOPY INSTALL: Configuring... done.
SNOOPY INSTALL: Building... bash-4.2#
bash-4.2#
4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5