Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RedHat_Insights_Inside

OMO
September 24, 2019

 RedHat_Insights_Inside

18:00ー19:00:ディープなTechセッション
Insightsの中身をもう少しだけ詳しく見てみる
https://connpass.com/event/143809/

OMO

September 24, 2019
Tweet

More Decks by OMO

Other Decks in Technology

Transcript

  1. Insights Client (Egg) /usr/bin/insights-client /usr/bin/insights-client-run /etc/insights-client/ 実際の”Core”はこの人たち https://github.com/RedHatInsights/insights-core/insights/client /etc/insights-client/rpm.egg ./EGG-INFO/dependency_links.txt

    ./EGG-INFO/entry_points.txt ./EGG-INFO/PKG-INFO ./EGG-INFO/requires.txt ./EGG-INFO/SOURCES.txt ./EGG-INFO/top_level.txt ./insights/client/archive.py ./insights/client/auto_config.py ./insights/client/cert_auth.py ./insights/client/client.py ./insights/client/collection_rules.py ./insights/client/compressed_file.py ./insights/client/config.py ./insights/client/connection.py ./insights/client/constants.py ・・・・・など
  2. Insights Client (動作のPhase) /usr/bin/insights-client /usr/bin/insights-client-run /etc/insights-client/ 各Phaseに分けて動作 ・pre_update ----> 接続前の設定確認・疎通確認、

    etc. ・update -----> Insightsサーバと接続 ・post_update ---> 事後処理(登録情報・offline確認等) ・collect_and_output ---> 実際の情報収集行為 /etc/insights-client/rpm.egg
  3. Insights Client (pre_update) /usr/bin/insights-client /usr/bin/insights-client-run /etc/insights-client/ 各Phaseに分けて動作 ・pre_update ----> 接続前の設定確認・疎通確認、

    etc. /etc/insights-client/rpm.egg --- if config.validate: if validate_remove_file(config.remove_file): --- if config.test_connection: logger.info("Running Connection Tests...") rc = client.test_connection() /etc/insights-client/insights-client.conf ---略--- # Timeout for HTTP calls, in seconds #http_timeout=10 疎通確認(”http_timeout値”タイムアウト)
  4. Insights Client (動作のPhase) /usr/bin/insights-client /usr/bin/insights-client-run /etc/insights-client/ 各Phaseに分けて動作 ・pre_update ----> 接続前の設定確認・疎通確認、

    etc. ・update -----> Insightsサーバと接続 ・post_update ---> 事後処理(登録情報・offline確認等) ・collect_and_output ---> 実際の情報収集行為 /etc/insights-client/rpm.egg
  5. Insights Client (update) /usr/bin/insights-client /usr/bin/insights-client-run /etc/insights-client/rpm.egg Uploader.jsonに更新があればダウンロード { "commands": [

    { "command": "python -m insights.tools.cat --no-header aws_instance_type", "pattern": [], "symbolic_name": "aws_instance_type" }, { "command": "python -m insights.tools.cat --no-header azure_instance_type", "pattern": [], "symbolic_name": "azure_instance_type" }, ・・・etc. Uploader.jsonの更新を確認
  6. Insights Client (参考) /usr/bin/insights-client /usr/bin/insights-client-run /etc/insights-client/ remove.conf /etc/insights-client/rpm.egg Uploader.jsonをダウンロードして実行 (中身を見れば、どの情報が取られるかわかる)

    { "commands": [ { "command": "python -m insights.tools.cat --no-header aws_instance_type", "pattern": [], "symbolic_name": "aws_instance_type" }, { "command": "python -m insights.tools.cat --no-header azure_instance_type", "pattern": [], "symbolic_name": "azure_instance_type" }, ・・・etc. 収集されたくない情報を指定 (処理自体はpre-update時)
  7. Insights Client (動作のPhase) /usr/bin/insights-client /usr/bin/insights-client-run /etc/insights-client/ 各Phaseに分けて動作 ・pre_update ----> 接続前の設定確認・疎通確認、

    etc. ・update -----> Insightsサーバと接続 ・post_update ---> 事後処理(登録情報・offline確認等) ・collect_and_output ---> 実際の情報収集行為 /etc/insights-client/rpm.egg
  8. Insights Client (動作のPhase) /usr/bin/insights-client /usr/bin/insights-client-run /etc/insights-client/ 各Phaseに分けて動作 ・pre_update ----> 接続前の設定確認・疎通確認、

    etc. ・update -----> Insightsサーバと接続 ・post_update ---> 事後処理(登録情報・offline確認等) ・collect_and_output ---> 実際の情報収集行為 /etc/insights-client/rpm.egg
  9. Insights Client (collect_and_output) /usr/bin/insights-client /usr/bin/insights-client-run /etc/insights-client/ /etc/insights-client/rpm.egg HTTPS アップロード (PUT)

    insights-core/insights/client/connection.py ------------------------ """ Module handling HTTP Requests and Connection Diagnostics """ from __future__ import print_function from __future__ import absolute_import import requests import os -------------- Do an HTTPS upload of the archive ''' file_name = os.path.basename(data_collected) try: from insights.contrib import magic m = magic.open(magic.MAGIC_MIME) m.load() mime_type = m.file(data_collected) except ImportError: magic = None logger.debug('python-magic not installed, using backup function...') from .utilities import magic_plan_b mime_type = magic_plan_b(data_collected) files = { 'file': (file_name, open(data_collected, 'rb'), mime_type)} if self.config.analyze_container: logger.debug('Uploading container, image, mountpoint or tarfile.') upload_url = self.upload_url else: logger.debug('Uploading a host.') upload_url = self.upload_url + '/' + generate_machine_id() logger.debug("Uploading %s to %s", data_collected, upload_url) headers = {'x-rh-collection-time': str(duration)} net_logger.info("POST %s", upload_url)
  10. Insights Client (何を送っているか) [root@fc30 ~]# insights-client --offline Starting to collect

    Insights data for fc30.localdomain Archive saved at /var/tmp/qybk6le2/insights-fc30.localdomain-20190812050718.tar.gz [root@fc30 insights-fc30.localdomain-20190812050718]# ls -F boot/ display_name insights_commands/ run/ usr/ branch_info etc/ proc/ sys/ version_info オフラインモードでinsights-clientを動作させる(--offline)
  11. Insights Plugins (Parser) Rawデータ Parser ファイル ファイル ファイル ファイル コマンド出力

    コマンド出力 コマンド出力 コマンド出力 一定の形(Object) 一定の形(Object) 一定の形(Object) 一定の形(Object) 一定の形(Object) 一定の形(Object) 一定の形(Object) 一定の形(Object) 種々のParserを使って、様々なファイル/出力形式を変換します。
  12. Q&A