ja:documentation:pandorafms:management_and_operation:04_inventory

インベントリ

Pandora FMS allows you to maintain an inventory of the devices monitored by Pandora FMS. With this inventory it is possible to maintain lists and reports (available in the Enterprise version) of:

Pandora FMS を使用すると、Pandora FMS によって監視されているデバイスのインベントリを保持できます。このインベントリにより、次のような 一覧およびレポート(Enterprise 版のみ) を管理できます。

  • Processor model and speed (MS Windows®, GNU/Linux®).
  • Storage and filesystems.
  • Firmware version (network hardware).
  • Device configuration (network hardware).
  • Serial numbers and licenses (e.g. MS Office®, MS Windows®).
  • Applications installed on the computer (MS Windows®, Android Linux®, GNU/Linux®).
  • Network cards and their MACs associated with IP addresses.
  • RAM memory modules and their capacity (MS Windows®, GNU/Linux®).
  • Installed routes.
  • Running services.
  • Storage devices (MS Windows®, GNU/Linux®).
  • System users.
  • CPU モデルと速度 (MS Windows®, GNU/Linux®)
  • ストレージとファイルシステム
  • ファームウエアバージョン (ネットワークハードウエア)
  • デバイス設定 (ネットワークハードウエア)
  • シリアル番号およびライセンス (例: MS Office®, MS Windows®).
  • コンピュータにインストールされたアプリケーション (MS Windows®, Android Linux®, GNU/Linux®).
  • ネットワークカードおよび IP アドレスに関連付けられた MAC
  • RAM モジュールおよび容量 (MS Windows®, GNU/Linux®)
  • ルーティング
  • 実行中サービス
  • ストレージデバイス (MS Windows®, GNU/Linux®)
  • システムユーザ

The inventory is independent of monitoring and can be obtained:

インベントリは監視とは独立しており、次のように取得できます。

  • Remotely, through Inventory Modules, through scripts integrated into Pandora FMS that execute WMI queries, or scripts executed through SSH with Expect or similar methods.
  • Locally, with the Pandora FMS Software Agent, through plugins in the Agent.
  • インベントリモジュールを介して、Pandora FMS に統合されたスクリプトで、リモートから WMI クエリを実行したり、または Expect または同様の方法で SSH を実行する方法。
  • エージェントプラグインを介してローカルで Pandora FMS エージェントを利用する方法。

Inventory Modules are remote Modules that execute a command against a remote machine. These Modules work similarly to a plugin. The same modules can be defined as local when they obtain data through a Software Agent.

インベントリモジュールは、リモートのマシンにコマンドを実行するリモートモジュールです。これらのモジュールは、プラグインと同じように動作します。エージェントを通してデータを取得するローカルモジュールと同じものを定義することができます。

In the User and Password parameters you can use the following macros: _agentcustomfield_n_ (custom field number n of the agent) .

ユーザおよびパスワードでは、_agentcustomfield_n_ (エージェントのカスタムフィールド番号 n) マクロが利用できます。

With Pandora FMS Enterprise, a good number of inventory modules are installed by default and it also allows you to build new inventory modules, modify, delete and customize those that already exist using the inventory module editor.

Pandora FMS Enterprise では、多数のインベントリ モジュールがデフォルトでインストールされており、インベントリモジュールエディタを使用して新しいインベントリモジュールを作成したり、既存のインベントリモジュールを変更、削除、カスタマイズしたりすることもできます。

リモートモジュールの作成

In the menu ManagementConfigurationInventory Modules you can see this list, and with the Create button add a new one.

管理(Management)設定(Configuration)インベントリモジュール(Inventory Modules) メニューから一覧が表示され、作成(Create) ボタンを押すと新規追加できます。

Some important fields:

重要なフィールドは次の通りです。

  • Interpreter:Leave blank if it is a local Module. Field where the command interpreter used in the module is placed. It can be Shell Script, Perl or another valid interpreter for the inventory server running on a GNU/Linux system.
  • Code:Leave blank if it is a local Module. Module Code; usually it is Perl code or Shell Script. If it were binary code, it would need a different loading procedure that must be introduced through auxiliary scripts.
  • Block mode: Displays and detects changes in the configuration.
  • Format: Type the fields separated by ; that the module will return.
  • インタープリタ(Interpreter): ローカルモジュールの場合は空にします。モジュールで使われるコマンドインタープリタを入力するフィールドです。シェルスクリプト、Perl、その他インベントリサーバで実行できるスクリプト言語を利用できます。
  • コード(Code): ローカルモジュールの場合は空にします。Perl やシェルスクリプトなどのプログラムを設定します。バイナリの実行ファイルの場合、別途それを呼び出すスクリプトが必要です。
  • ブロックモード(Block mode): 設定の 変更を表示・検出します。
  • フォーマット(Format): モジュールが返す値を ; で分割したフィールドを入力します。
  • In Format make sure to place each and every field separated by semicolons. If you omit this field you will not be able to create or save an inventory module and you will lose any changes made.
  • It is very important to choose the corresponding operating system because when adding inventory modules to an agent, only those modules will appear in which the operating system of the module matches the operating system of the agent.
  • フォーマット(Format)では、各フィールドをセミコロンで区切って配置してください。 このフィールドを省略すると、インベントリモジュールを作成または保存できなくなり、行われた変更はすべて失われます
  • インベントリモジュールをエージェントに追加すると、モジュールのオペレーティングシステムがエージェントのオペレーティングシステムと一致するモジュールのみが表示されるため、対応するオペレーティングシステムを選択することが非常に重要です。

リモートモジュールの割当

The assignment of Inventory Modules is carried out in the Agent itself, in the Agent administration tab, click on the Inventory tab.

インベントリモジュールの割り当ては、エージェント自体で実行されます。エージェント管理タブで、インベントリ タブをクリックします。

  • Module: Choose the inventory module that needs to be added. Only modules whose Operating System matches that of the Agent will appear.
  • Target: IP address or name of the server from which you want to retrieve the inventory.
  • Interval: Choose the time interval in which the input module will be executedventory.
  • モジュール(Module): 追加したいインベントリモジュールを選択します。エージェントのオペレーティングシステムに合うモジュールのみが表示されます。
  • 対象(Target): インベントリを取得する対象の IP アドレスもしくはホスト名を設定します。
  • 間隔(Interval): インベントリモジュールの実行間隔を設定します。

It is possible to define fields instead of the username and password that normally exist, for this it is necessary to activate the Use custom fields field. After doing this, a control will appear to add new fields (Add field).

通常存在するユーザ名とパスワードの代わりにフィールドを定義することができます。そのためには、カスタムフィールドの利用(Use custom fields) を有効化する必要があります。 これを行うと、新しいフィールドを追加するためのコントロールが表示されます (フィールド追加(Add field))。

  • In this control you will have to enter the desired name before adding it.
  • If you indicate that the field will contain a password, type It`s a password and the value will be saved in the database in an obfuscated manner.
  • After creating the fields, you can give them a value and finally add the Module.
  • These fields will be applied in order of creation in the execution of the remote inventory script.
  • このコントロールでは、追加する前に希望の名前を入力する必要があります。
  • フィールドにパスワードを含めるようにする場合は、It's a password と入力すると、値が難読化された方法でデータベースに保存されます。
  • フィールドを作成した後、フィールドに値を指定し、最後にモジュールを追加できます。
  • これらのフィールドは、リモートインベントリスクリプトの実行時に作成順に適用されます。

Through Software Agents it is possible to obtain inventory data for a machine. It will be enough to apply the corresponding inventory modules in the Software Agent configuration.

ソフトウエアエージェントを通してインベントリデータを取得することができます。ソフトウエアエージェントの設定に、必要なインベントリモジュールを適用すれば良いだけです。

As with remote modules, it is also necessary to add these modules as an inventory module in ManagementConfigurationInventory modules.

リモートモジュールと同様に、これらのモジュールは、管理(Management)設定(Configuration)インベントリモジュール(Inventory modules) でインベントリモジュールとして追加する必要があります。

ローカルモジュールの作成

To create a local Module go to ManagementConfigurationInventory modules where all the inventory modules that have been created appear. All modules that will be defined in the Agent configuration must be created here; The operating system assigned to the Agent in the console must also match that of the created Module.

ローカルモジュールを作成するには、管理(Management)設定(Configuration)インベントリモジュール(Inventory modules) へ行きます。作成済みの全インベントリモジュールが表示されます。エージェント設定内で定義されるすべてのモジュールを作成します。 コンソール上でエージェントに割り当てられた OS は、作成されたモジュールの OS と一致する必要があります。

The procedure is the same used for the remote case, except for filling in the Interpreter and Code fields. To edit the newly created inventory module (as well as all others) click either the name or the wrench icon.

手順は、インタプリター(Interpreter) および コード(Code) フィールドを設定すること以外、リモートの場合と同じです。新しく作成したインベントリモジュール (その他すべてのモジュール) を編集するには、名前またはスパナアイコンをクリックします。

ソフトウエアエージェントによる Windows のインベントリモジュール

These plugins come by default with the installation of the software agent, although they are commented in the configuration file, to use them uncomment such lines and restart the software agent (in the Enterprise version the software agents can be restarted due to their remote configuration).

これらのプラグインは、ソフトウェアエージェントのインストール時にデフォルトで導入されていますが、設定ファイル内でコメントアウトされています。利用する場合はコメントを外し、ソフトウェア エージェントを再起動します (Enterprise 版では、リモート設定によりソフトウェアエージェントを再起動できます)。

Example for MS Windows®:

MS Windows® の例:

#module_begin
#module_plugin cscript.exe B t:20 "%PROGRAMFILES%\Pandora_Agent\util\cpuinfo.vbs"
#module_crontab * 12-15 * * 1
#module_end

More items can be downloaded from the script collection in the Pandora FMS library. Each one has its instructions for use and the scheduled execution of local inventory scripts must be configured in the pandora_agent.conf file by adding the information to the end of the file.

追加の設定は、スクリプトコレクション Pandora FMS ライブラリ内 からダウンロードできます。 それぞれに使用説明があります。また、ローカルインベントリスクリプトの定期実行は、pandora_agent.conf ファイルの末尾に情報を追加して設定する必要があります。

ソフトウエアエージェントによる UNIX のインベントリモジュール

The Unix Software Agent module uses, locally, a plugin to collect information about different aspects of the machine, both software and hardware.

Unix のソフトウエアエージェントのモジュールは、マシンのソフトウエアおよびハードウエア情報を取得するためにローカルで定義されたプラグインを利用します。

The plugin that collects the inventory is in the directory /etc/pandora/plugins

インベントリーを収集するプラグインはディレクトリ /etc/pandora/plugins にあります。

The Module syntax is as follows:

モジュールの書式は次の通りです。

module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route

The Module is made up of a line with the following parameters:

モジュールは、次のパラメータを一行で設定します。

  • Module Activation:
  • モジュールの有効化
"module_plugin inventory" 1 cpu ram video nic hd cdrom software init_services filesystem users route
  • Field where it is established how many days the Module will be executed. If it is zero (0) the inventory is returned on each Agent execution.
  • モジュールの実行間隔 (日単位) の設定。値が 0 の場合は、エージェントの実行時にインベントリ情報が送信されます。
module_plugin inventory "1" cpu ram video nic hd cdrom software init_services filesystem users route
  • Field where the inventory objects that are collected are defined.
  • 収集するインベントリの対象の設定
module_plugin inventory 1 "cpu ram video nic hd cdrom software init_services filesystem users route"

You can also simply specify that it collect all available information. In this example, you will collect all inventory information daily:

利用可能なすべての情報を収集するように指定することもできます。 この例では、すべてのインベントリ情報を毎日収集します。

  # Plugin for inventory on the agent (Enterprise Only)
  module_plugin inventory 1

To activate the Inventory Module, copy the code described above and add it to the pandora_agent.conf file of the Software Agent and restart the service.

インベントリモジュールを有効化するには、上記の設定をソフトウエアエージェントの pandora_agent.conf に記述しエージェントを再起動します。

ローカルモジュールの割当

It is unnecessary to activate the Modules in the Agents defined in the Console:

エージェントで定義したモジュールはコンソールで有効化する必要はありません。

  • If the modules have been created in ConfigurationInventory modules.
  • If the operating system matches and execution is defined in the Software Agent configuration file.
  • The collected data will appear directly in the ViewInventory section of the Agent in the Console.
  • 設定(Configuration)インベントリモジュール(Inventory modules) をクリックしてモジュールが作成され、
  • ソフトウエアエージェントの設定ファイルに設定された OS が一致すれば、
  • コンソール上のエージェントの 表示(view)インベントリ(inventory) に現れます。

ソフトウエアエージェントでのローカルインベントリモジュールの作成

In addition to the inventory systems that come preconfigured in the Agent, Inventory Modules can be created for Unix® and MS Windows® systems. Basically you have to create a script thatgenerate an XML with the following structure:

エージェントにあらかじめ設定されたインベントリシステムに加えて、Unix® および MS Windows® システム用のインベントリモジュールを作成できます。 基本的には、次の構造の XML を生成するスクリプトを作成する必要があります。

<inventory>
     <inventory_module>
         <name>INVENTORY_MODULE_NAME</name>
         <type>generic_data_string</type>
         <datalist>
             <data>DATA1;DATA2;DATA3....</data>
         </datalist>
     </inventory_module>
</inventory>
  • INVENTORY_MODULE_NAME: The same name of the Module that you registered in the inventory modules in the Pandora FMS Console must be entered.
  • DATA1;DATA2… : These are the data to be extracted and that have been defined in the Inventory Module.
  • In the file pandora_agent.conf the script that generates the XML must be executed.
  • In order for the local script execution to store inventory information, it must have an inventory Module defined in the Console, specifying the operating system, Module name and the data to be stored separated by ; .
  • Therefore, the Inventory Module must be created in Pandora FMS before restarting the Pandora FMS agent.
  • INVENTORY_MODULE_NAME: Pandora FMS コンソールのインベントリモジュールに登録したモジュールと同じ名前を入力する必要があります。
  • DATA1;DATA2… : これらは抽出されるデータであり、インベントリ モジュールで定義されています。
  • ファイル pandora_agent.conf で、XML を生成するスクリプトを実行するようにする必要があります。
  • ローカル スクリプト実行でインベントリ情報を保存するには、コンソールでインベントリ モジュールを定義し、オペレーティングシステム、モジュール名、および保存するデータを ; で区切って指定する必要があります。
  • したがって、Pandora FMS エージェントを再起動する に、Pandora FMS でインベントリモジュールを作成する必要があります。

Inventory data that has been collected from a system, whether locally or remotely, can be viewed from the Agent itself or from the Console Inventory menu.

ローカルまたはリモートでシステムから収集されたインベントリデータは、エージェントもしくはコンソールのインベントリメニューから参照することができます。

From OperationMonitoringInventory it is possible to view the inventory data of all agents, perform searches and export the data to a CSV file.

操作(Operation)モニタリング(Monitoring)インベントリ(Inventory) をクリックすることにより、エージェントのインベントリデータの参照、検索、データの CSV へのエクスポートができます。

By default, all agents are shown, but it is possible to view the modules of all agents that have inventory by choosing All in the search options and clicking Search. In any search case (group, module, etc.) you can group by agent if you check the Order by agent option.

デフォルトでは、すべてのエージェントが表示されますが、検索オプションで すべて を選択し、検索 をクリックすると、インベントリを持つすべてのエージェントのモジュールを表示できます。 エージェントごとに並べる(Order by agent) オプションをチェックすると、どの検索ケース (グループ、モジュールなど) でもエージェントごとにグループ化できます。

In the detailed view of the Agent inventory, through a selector, you can choose the date of the specific inventory report to view (by default Last).

エージェントインベントリの詳細表示では、セレクターを使用して、表示する特定のインベントリレポートの日付 (デフォルトでは 最新) を選択できます。

If you notice missing dates it will probably be because there are no changes in the data from the last inventory run. That is, Pandora FMS only stores inventory data when it changes compared to the last run.

日付が無い場合は、前回のインベントリ実行からデータに変更がないことが原因である可能性があります。 つまり、Pandora FMS は、インベントリデータが前回の実行と比較して変化した場合にのみ保存します。

From OperationMonitoringInventory it is possible to export the inventory data, the result of a filter, to a CSV file using the Export this list to CSV button. A file with the inventory data separated by the configured character will be created and downloaded in SetupVisual stylesCSV divider.

操作(Operation)モニタリング(Monitoring)インベントリ(Inventory) をクリックすると、フィルタリングしたあとのインベントリデータを この一覧を CSV へエクスポートする(Export this list to CSV) ボタンを使って CSV ファイルへエクスポートすることができます。CSV 区切り文字 で区切られたインベントリデータを含むファイルが作成およびダウンロードされます。

Pandora FMS can visually show the differences between two configurations, displaying it in two columns to see the differences. The Block mode specifies that the result of an inventory module is a single element, instead of interpreting each line as different elements of the same type, as has been done in the inventory modules seen previously. Configured when defining a local or remote Inventory Module:

Pandora FMS は、2 つの設定間の違いを視覚的に表示し、違いを確認するために 2 つの列に表示します。 ブロックモードでは、前に見たインベントリモジュールで行われていたように、各行を同じタイプの異なる要素として解釈するのではなく、インベントリモジュールの結果全体を一つとして処理します。 ローカルまたはリモートのインベントリ モジュールを定義するときに設定されます。

Version 751 NG or later.

バージョン NG 751 以降

Enterprise Version Inventory alerts They serve to launch specific alerts about the inventory content of a group of agents. Like SNMP alerts or event alerts, they are not applied agent by agent but are global, in this case, they are applied by groups.

Enterprise 版インベントリアラートは、エージェントグループのインベントリコンテンツに関して特定のアラートを発報するのに役立ちます。SNMPアラートやイベントアラートと同様に、エージェントごとに適用されるのではなく、グローバルに適用されます。この場合、グループごとに適用されます。

To configure alerts, you must go to the ManagementAlertsInventory alerts section.

これを設定するには、管理(Management)アラート(Alerts)インベントリアラート(Inventory alerts) へ行きます。

Inventory alerts have fields similar to other alerts such as name, description, time threshold and action and with the following differences:

インベントリアラートには、名前、説明、時間しきい値 、アクションなど、他のアラートと似たフィールドがあります。そのため、他のアラートとの違いに焦点を当てます。

  • The group in this case acts as the alert condition, so alerts will be evaluated for any data that comes from an Agent in said group.
  • These alerts also have the option deactivate event which is used so that when the alert is triggered, an alert event is not generated. It is useful since it is possible that with the application of inventory alerts many alerts are triggered in a single execution.
  • グループ はアラート条件として機能するため、アラートは、そのグループのエージェントからのデータについて評価されます。
  • これらのアラートには、アラートが発報されたときにアラートイベントを生成しないようにするための イベントの無効化 オプションもあります。インベントリアラートアプリケーションでは、1回の実行で多くのアラートが発報されることがあるため便利です。

文字列マッチ

In this way, when a specific string arrives in a specific inventory module (for example “software”) the established action will be triggered. Inventory Modules have dynamic fields; For example, in the software inventory module, there are the fields name, version and description that can be used. This way you can set an alert for any of the three d fields.static, such as to monitor a package of a specific version:

特定のインベントリモジュール内の特定のテキスト文字列(“software” など)を受信すると、設定されたアクションが実行されます。インベントリモジュールには 動的フィールド があることに注意する必要があります。 例えば ソフトウェアインベントリモジュールには、名前、バージョン、および説明のフィールドがあります。これにより、特定のパッケージまたは特定のバージョンのパッケージを探すのに最適な、3つの動的フィールドのいずれかにアラートを設定できます。

In these fields you can enter regular expressions to make more complex searches. If a field is empty it counts as .* (it will match any value).

これらのフィールドに正規表現を追加して、より複雑な検索を行うことができます。フィールドが空の場合、.* として扱われます(任意の値にマッチします)。

制限リスト

In this case (Condition, Black list) you must specify only one field of the Inventory Module type, and establish a list of strings (one per line) so that if the Agent contains an element from that list, the alert will go off

この場合、インベントリモジュールタイプのフィールドを 1つだけ指定し、文字列リスト(1行ずつ)を指定して、エージェントにそのリストの要素が含まれている場合にアラートが発生するようにします。リストにあるものがある場合、アラートが発生します。

許可リスト

Similar to the previous case: A list of items (Condition, White list) is specified for one of the inventory fields, except that In this case, the value of the Inventory Module must always be found in one of the elements of the list, if not, the alert will appear.

前述のものと似ています。 インベントリフィールドの 1つに要素のリスト (条件(Condition)ホワイトリスト(White list)) を指定します。ただし、今回は、インベントリモジュールの値がリストの要素の 1つにある必要があります。そうでない場合、アラートが発生します。

Enterprise VersionThis functionality is really useful for detecting vulnerable versions of devices, unauthorized users on machines, or unauthorized use of software on computers.

Enterprise 版この機能は、デバイスの脆弱なバージョン、マシン内の許可されていないユーザ、またはコンピューター内の許可されていないソフトウェアを検出するのに最適です。

Pandora FMS allows you to collect, in addition to inventory data, other important values of each operating system monitored through software agents. All this is centralized in the Operation → Security → Hardening section.

Pandora FMS を使用すると、インベントリデータに加えて、ソフトウェアエージェントを通じて監視される各オペレーティングシステムのその他の重要な値を収集できます。これらすべては、操作(Operation) → セキュリティ(Security) → 強化(Hardening) セクションにあります。

This tool seeks to strengthen the security of each of the monitored devices and the information is presented in three main sections.

このツールは、監視対象の各デバイスのセキュリティを強化することを目的としており、情報は 3 つの主要なセクションで表示されます。

The Historical summary presents the total number of agents that monitor the modules intended for security and the total average score (Total agents and scoring table).

履歴概要には、セキュリティを目的としたモジュールを監視するエージェントの合計数と合計平均スコア (エージェントの合計とスコア 表) が表示されます。

The table AVG Score by group presents the average score for each group defined in PFMS.

グループ別の AVG スコア 表は、Pandora FMS で定義されている各グループの平均スコアを示しています。

There is also a historical graph (Time line table) with the average of failed and approved security checks grouped by days (maximum the last eleven days) regardless of the selected time period. In Filters you can select a custom time period or common values (last week, last month, etc.).

選択した期間に関係なく、失敗したセキュリティチェックと承認されたセキュリティチェックの平均を日ごとにグループ化した履歴グラフ (タイムライン 表) もあります (最大で過去 11 日間)。 フィルタ では、カスタム期間または一般的な値 (先週、先月など) を選択できます。

In the Summary by categories it must be filtered by category and optionally by group to view. By default, the Access Control Management category is selected.

カテゴリ別の概要 では、カテゴリ別、必要に応じてグループ別にフィルタリングして表示する必要があります。 デフォルトでは、アクセス制御管理(Access Control Management) カテゴリが選択されています。

* The Vulnerabilities box will show the total number of failed vulnerabilities and overcome vulnerabilities. * In Checks failed by agent the list of failed checks for the selected category, clicking on each sector of the graph will list the details of the selected check and the affected agents.

* 脆弱性(Vulnerabilities) ボックスには、問題のある脆弱性と対処された脆弱性の合計数が表示されます。 * エージェントごとに問題のある項目 は、選択したカテゴリの問題のある項目の一覧で、グラフの各セクターをクリックすると、選択した項目と影響を受けるエージェントの詳細が一覧されます。

The failure summary is presented (Tittle of check): The list of failed checks filtered by group and the number of incidents. Use the Filters box to define new search and display parameters.

問題の概要が表示されます (確認項目のタイトル): グループおよびインシデントの数によってフィルタリングされた、問題のある項目の一頼です。 フィルタ ボックスを使用して、新しい検索パラメータと表示パラメータを定義します。

Also the list of the agents with the worst security score, with the option to view the security view of each agent by clicking on them.

また、最も低いセキュリティスコアを持つエージェントの一覧と、クリックすることにより各エージェントのセキュリティビューを表示するオプションも表示されます。

Finally, a radar graph is presented with the distribution of failures by category.

最後に、レーダーグラフにカテゴリ別の問題の分布が表示されます。

Pandora FMS ドキュメント一覧に戻る

リモートインベントリモジュール例

UNIX サーバから物理アドレスの一覧を取得する必要がある場合を想定します。これは、通常 “arp -a -n” コマンドで取得でき、サーバで実行すると次のような出力を得られます。

artica@galaga:~$ arp -a -n
? (192.168.70.74) at 08:00:27:39:BF:6F [ether] on eth2
? (192.168.70.162) at B4:74:9F:94:98:84 [ether] on eth2
? (192.168.50.30) at 08:00:27:10:D1:1A [ether] on eth0
? (192.168.70.90) at 98:0C:82:54:2F:DE [ether] on eth2
? (192.168.50.2) at 08:00:27:EA:B2:FF [ether] on eth0
? (192.168.70.135) at C8:60:00:4B:96:67 [ether] on eth2
? (192.168.60.182) at FE:26:C5:91:B1:DA [ether] on tap0

やりたいことは、IP アドレス、MSC アドレス、ネットワークインタフェース名を抽出することです。

これは、フィールドを “ ”(スペース)で分割して、次のようなシェルスクリプトで実現できます。

arp -a -n | sort | grep -v incomplete | awk '{ print $2,$4,$7 }'

Pandora のリモートインベントリサーバへ、この情報を “インポートする” 必要があるとします。そのためには、“CPU” のリモートインベントリモジュールを元に、それを若干修正します。このスクリプトは、SSH を使って対象のサーバへ接続し、コマンドを実行します。コマンドは、“;” 文字で分割して情報を出力します。

ここで、若干スクリプトのプログラミングの知識が必要になります。リモートインベントリスクリプトには、複雑ではありませんが、多少 perl、シェルスクリプト、その他言語の知識が必要です。モジュールから実行され、データ単位ごとに 1行で、かつフィールドを “;” で区切った形式で値を返すのであれば、java や c++ で記述することもできます。

#!/usr/bin/perl
##########################################################################
# pandora_linux_arptable.pl
##########################################################################
# Copyright (c) 2012 Sancho Lerena <slerena@artica.es>
#           (c) 2012 Artica Soluciones Tecnologicas S.L
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
##########################################################################

use strict;
use warnings;

# Check for ssh
my $ssh_client = "ssh";
if (system("$ssh_client -v> /dev/null 2>&1")>> 8 != 255) {
    print "[error] $ssh_client not found.\n";
    exit 1;
}

if ($#ARGV <1) {
    print "Usage: $0 <target ip> <username>\n";
    exit 1;
}

my $target_ip = $ARGV[0];
my $username = $ARGV[1];

# Retrieve ARP table
my ($ip, $mac, $iface);
my $command = '/usr/sbin/arp -a -n | sort | grep -v incomplete | awk \'{ print \$2,\$4,\$7 }\'';

my @info = `$ssh_client $username\@$target_ip "$command" 2> /dev/null`;
foreach my $line (@info) {
    if ($line =~ /^(.+)\s(.+)\s(.+)/) {
        $ip = $1;
        $mac = $2;
        $iface = $3;
        print "$ip;$mac;$iface\n";
    }
}

exit 0;

SSH 接続を自動実行できるようにするためには、対象のサーバに pandora サーバの root ユーザの公開鍵をコピーする必要があります。このコマンドを 192.168.50.10 のサーバで実行することを想定した場合、次のようになります。

1. pandora サーバで root にて鍵を生成します。

ssh-keygen

2. ssh-copy-id コマンドを使って、公開鍵を対象のサーバ(192.168.50.10)の対象ユーザ(例では artica)へコピーします。

ssh-copy-id -i /root/.ssh/id_rsa.pub artica@192.168.50.10

(対象のユーザに公開鍵をインストールするために、一度 “artica” ユーザのパスワードを入力する必要があります。)

3. 接続を試します。パスワードを聞かれずに接続できる必要があります。

ssh artica@192.168.50.10

4. 処理が成功したら、インベントリモジュールが実行するのと同じ処理をコマンドラインから実行してみます。前述のスクリプト(temporal.pl)を IP アドレスとユーザをパラメータに指定して実行します。

perl temporal.pl 192.168.50.10 artica
(192.168.50.1);00:0f:ea:27:ba:f0;eth0
(192.168.50.3);08:00:27:98:f8:48;eth0

スクリプトは、リモートで /usr/sbin/arp を実行していることに注意してください。コマンドが指定のパスにある必要があります。パスが違う場合はスクリプトを修正します。また、スクリプトは “perl” から呼び出します。通常は、/usr/bin/perl です。モジュール定義はつぎのようになります。

これをエージェントに適用する場合は、OS が同じであるか確認することに注意が必要です。異なる OS の場合は、同一のコードは動かないため、それぞれに異なるモジュールを作成する必要があります。

モジュールが実行されると、次のように表示されます。

  • ja/documentation/pandorafms/management_and_operation/04_inventory.txt
  • 最終更新: 2023/11/08 06:20
  • by 127.0.0.1