フレックスエージェントの手動インストールと設定
多言語インストールのウィザードを使用してフレックスエージェントをインストールする代わりに、以下の手順を使用して手動でインストールできます。この手順は、自動化を使用してアプリケーションを大規模にデプロイする場合に役立ちます。
フレックスエージェントの仕組み
フレックスエージェントは、マシン上で新しプロセスが起動するのを確認し、そのプロセスがエージェントによる監視(インストゥルメント)の対象候補であるかどうかを判断します。
フレックスエージェントをインストールすると、「インジェクタ」と呼ばれるものが提供されます。このインジェクタは、起動したプロセスの言語を特定します。そのプロセスに対応するエージェントが利用可能な場合は、エージェントをプロセスに接続(attach)するよう試みます。接続が成功すると、エージェントはプロセスを監視しします。
標準のエージェント設定を使用して、エージェントはデータをContrast Webインターフェイスに報告します。
開始する前に
ルートアクセスが必要
対応OS:Linuxのほとんどのバージョン
対応言語: .NET, Java, Node.js, Python, PHP
以下のいずれかが必要:
手動:
tarおよびcURL、sha256sum(任意)Debian:
apt-get、cURL、およびgnupg2RPM:
teeおよびyum
フレックスエージェントをインストールして全てのプロセスに接続
フレックスエージェントで実行中の全てのWebプロセスにエージェントを接続(attach)するには、以下のクイックインストールコマンドを使用します。
cURL:
cURLを使用してインストールするには、以下のコマンドを使用します。$AGENT_TOKENは、ご利用のContrast APIトークンに置き換えて下さい。curl -s https://download.flex.contrastsecurity.com/installer/install.sh | CONTRAST__API__TOKEN=<token> sudo bash
ダウンロードした
contrast-flex-agent.tar.gzの署名を確認するには、untarコマンドを実行する前に以下のコマンドを実行して下さい。OK以外の出力があった場合は、アーティファクトを削除して再度ダウンロードして下さい。Sha256の代わりにSha1とMD5のチェックサムを使用することもできます。curl -s -o /tmp/install.sh https://download.flex.contrastsecurity.com/installer/install.sh && \ curl -s -o /tmp/checksum.sha256 https://download.flex.contrastsecurity.com/installer/checksum.sha256 && \ if [[ "$(shasum -a 256 /tmp/install.sh | awk '{print $1}')" == "$(cat /tmp/checksum.sha256 | awk '{print $1}')" ]]; then \ CONTRAST__API__TOKEN=<token> bash /tmp/install.sh; \ fiDebian:Debianを使用してインストールするには、以下のコマンドを使用します。
curl https://pkg.contrastsecurity.com/api/gpg/key/public | gpg -o /usr/share/keyrings/contrast-keyring.pgp --dearmor echo "deb [signed-by=/usr/share/keyrings/contrast-keyring.pgp] https://pkg.contrastsecurity.com/debian-public/ $(sed -rne 's/^VERSION_CODENAME=(.*)$/\1/p' /etc/*ease) contrast" | tee /etc/apt/sources.list.d/contrast.list echo "deb [signed-by=/usr/share/keyrings/contrast-keyring.pgp] https://pkg.contrastsecurity.com/debian-public/ all contrast" | tee -a /etc/apt/sources.list.d/contrast.list sudo apt-get update && sudo apt-get install -y contrast-flex-agent
RPM:RPMを使用してインストールするには、以下のコマンドを使用します。
rpm --import https://pkg.contrastsecurity.com/api/gpg/key/public tee /etc/yum.repos.d/contrast.repo <<-"EOF" [contrast] name=Contrast redhat-$releasever repo baseurl=https://pkg.contrastsecurity.com/rpm-public/redhat-$releasever/ gpgcheck=0 enabled=1 gpgkey=https://pkg.contrastsecurity.com/api/gpg/key/public repo_gpgcheck=1 EOF yum install contrast-flex-agent -y
通常の起動コマンドでアプリケーションを起動(または再起動)します。
フレックスエージェントを段階的にインストール
フレックスエージェントで実行中の全てのWebプロセスにエージェントを接続(attach)するが、全ての手順を管理したり、インストール手順を変更したい場合は、以下の手順を使用します。
Download the Flex Agent installation script: Use this command:
curl -s -o /tmp/install.sh https://download.flex.contrastsecurity.com/installer/install.sh
Run the installation: Use one of these commands and replace
$AGENT_TOKENwith your Contrast API token.sudo bash /tmp/install.sh --api-token $AGENT_TOKEN
For manual agent installation, use this command:
sudo /tmp/contrast-flex-agent/install.sh --api-token $AGENT_TOKEN --unattached
Find your application with the app command, which lists out all running processes with open ports:
sudo contrast-flex app
Enable instrumentation with the attach command with the ID from the previous app command:
sudo contrast-flex attach $ID true
Control agent attachment below contains instructions on how to change an installation on Linux to this style after your initial installation. Doing so does not remove instrumentation from running processes until you restart the application.
エージェントの接続を制御
デフォルトでは、フレックスエージェントは全てのプロセスを検査し、エージェントへの接続を自動的に試みます。この動作を変更したり、接続する特定のプロセスを指定する場合は、このセクションの手順を実行して下さい。
全てのプロセスに対する自動接続を制御する
フレックスエージェントが全てのプロセスに接続するのを停止する場合は、以下のコマンドを使用して
auto-attach(自動接続)をグローバルに無効にします。contrast-flex auto-attach set false
以下のコマンドで接続は再度有効になります。
contrast-flex auto-attach set true
auto-attachコマンドを使用しても、現在起動中のプロセスに対してエージェントが接続されたり、接続が解除されることはありません。新しい設定を反映するには、アプリケーションを再起動して下さい。プロセスへの接続を制御する
フレックスエージェントが特定のアプリケーションプロセスに接続するかどうかを制御するには、
attachコマンドを使用して、アプリケーションのIDを指定します。該当するプロセスを特定するには、
appコマンドでプロセスIDを検索します。contrast-flex app
以下のコマンドを使用して、プロセスの接続を有効または無効にします。ここで、
IDは前述の手順で見つけたプロセスIDになります。contrast-flex attach ${ID} ${true|false}Alternatively, set to
defaultto defer to the global auto-attach setting.通常のアプリケーション起動コマンドを使用して、アプリケーションを再起動します。エージェントに自動的にインジェクタが接続されます。