Check_mk数据收集器

名称:Check_mk数据采集器

版本:0.1.0

发布:2016-05-20

描述:解析数据并将其从check_mk导入到iTop中

itop-version:2.0, 2.1, 2.2

关键词:inventory, data synchronization, check_mk, nagios, itomig

依赖项:itop-config-mgmt

作者:ITOMIG GmbH

下载:https://odoo.itomig.de/shop/product/check-mk-collector-126

这个独立的PHP应用收集由check_mk的库存特性管理的数据。它使用同步数据源将硬件信息与iTop实例同步。

特征

  • 收集服务器和PC库存以及型号,品牌,操作系统家族和版本。
  • 通过Web界面连接到iTop。

局限性

需要直接(读取)访问check_mk的库存文件。这意味着它必须在安装了check_mk的计算机上运行(具有足够的权限)。或者,必须将check_mk使用的库存数据文件复制到库存可以访问它们的位置。

必须通过手动指定主机名模式来实现PC与服务器之间的区分。请参阅下面的配置。

要求

  • PHP版本5.3.0
  • 读取check_mk的库存文件的访问权限
  • 访问iTop REST服务

安装

  • 提取归档的内容。
  • 使用您的iTop凭据编辑conf/params.local.xml。
  • 从 collectors/params.distrib.xml创建 collectors/params.template.xml,然后编辑配置选项。

归档的根目录中的README和README_checkmk包含更多文档。

配置

强制参数

在conf/params.local.xml中编辑以下参数:

<itop_url>https://localhost/</itop_url>
<itop_login>admin</itop_login>
<itop_password>admin</itop_password>
参数含义样品价值
itop_urliTop应用的URLhttps://localhost/itop
itop_login权利的用户名称。必须具有管理员连接到iTop才能执行数据同步。管理员
itop_passwordiTop账号的密码。 

还必须在collectors/params.distrib.xml中设置以下参数:

<default_org_id>Demo</default_org_id>
<check_mk_dir>/var/lib/check_mk/inventory</check_mk_dir>
<type_mapping type="array">
  <pattern>/.*pc.*/PC</pattern>
  <pattern>/.*srv.*/Server</pattern>
</type_mapping>
参数含义样品价值
default_org_idiTop组织的名称,应该在其下存储库存项。演示版
check_mk_dir采集器应该在其中检查库存数据文件的目录。/var/lib/check_mk/inventory/
type_mapping映射表指定应如何根据check_mk中的主机名对主机进行分类。采用pattern/replacement格式的模式,其中pattern是与主机名匹配的正则表达式,并且替换必须是服务器或PC。与模式不匹配的主机名将被忽略。<pattern >>。**Server<< pattern>-捕获所有模式,将所有主机分类为服务器

可选参数

可以在collectors/params.distrib.xml中设置以下布尔参数:

<use_network_hostname>false</use_network_hostname>
<skip_gz>true</skip_gz>
<skip_dot>true</skip_dot>
参数含义样品价值
use_network_hostname使用给定库存机器在网络上使用的主机名,而不使用存储在check_mk下的主机名。默认为false。
skip_gz查找库存文件时,如果找到.gz副本,则跳过它们。默认为true。真正
skip_dot跳过库存文件目录中遇到的任何点文件。默认为true。真正

文件collectorssparams.template.xml包含所有配置项目的默认值以及有关其效果的更多文档。

默认字段

给出一个常量价值,将其分配给采集器不会填充的特定字段可能会很有用。这是在collectors/params.distrib.xml中完成的:

<default_fields type="hash">
  <field_name>field value</field_name>
  <field_name2>another field value</field_name2>
</default_fields>

如果正在使用诸如statusbusiness_criticity之类的字段,这将特别有用。仅应指定服务器和PC都具有的字段。

数据映射

check_mk中的数据是从各种来源收集的,因此可能并不总是适合现有的iTop数据。映射表用于定义在将以上项添加到iTop时应如何转换数据以使其适合数据。

在此采集器中,这适用于品牌,OS家族和OS版本对象。

映射表在collectors/params.distrib.xml中进行编辑。归档中提供的文件collectors/params.template.xml包含示例和更多文档。

例:

<osfamily_mapping type="array">
  <pattern>/.*linux.*/Linux</pattern>
  <pattern>/.*windows.*/Windows</pattern>
  <pattern>/.*mac os.*/Mac OS</pattern>
  <pattern>/.*solaris.*/Solaris</pattern>
  <pattern>/.*bsd.*/BSD</pattern>
  <pattern>/.*/$1$s</pattern>
</osfamily_mapping>

这将映射Linux,Windows,Mac OS,Solaris和BSD OS家族版本。 <pattern >>。** $ 1 $ s << pattern>将允许采集器向iTop添加任何不适合任何其他模式的值,而无需对其进行操作。

如果要忽略在映射表中未定义的OS系列(或OS版本或品牌),请省略<pattern >>。** $ 1 $ s << pattern>。这是默认的行为。

用法

首次运行采集器时,建议使用以下命令:

php exec.php --configure_only

如果它们不存在,这将创建同步数据源。

要在不与iTop同步的情况下收集数据,请运行

php exec.php --collect_only

这会将收集到的数据存储在采集器的dataa子目录中的CSV文件中-这对于在将数据传递给iTop之前进行检查很有用。可以检查映射的值并更新映射表-但是,请注意,在进行此类更改后,应再次运行收集。

最后,要与收集的数据执行iTop同步:

php exec.php --synchro_only

如果需要,可以在一个步骤中执行数据收集和同步(如果需要,还可以进行数据源更新):

php exec.php

尽管这更简单,但与同步流程相比,它提供的控制更少。

有关运行采集器的更多信息,请参见基于itop-数据-采集器 页。

数据系列引用

服务器和PC

服务器和PC收集了相同的数据。

iTop中的字段check_mk库存条目
name*check_mk主机名,即check_mk库存数据文件的名称,或网络主机名(请参阅上面的配置)
org_id*取自配置中的default_org_id
cpu硬件→CPU→模型
ram硬件→内存→total_ram_usable(在MiB中)
osfamily_id使用osfamily_mapping模式列表在软件→操作系统→类型或软件→操作系统→名称中使用数据进行映射
osversion_id使用osversion_mapping模式列表从软件→os→名称映射
serial硬件→系统→串行
brand_id使用brand_mapping模式列表从硬件→系统→供应商映射
model_id从硬件映射到系统→家族

*表示必填字段-如果check_mk中不存在相关的数据,则其余字段将被忽略,而不会阻止对象同步.

原贴链接:https://www.itophub.io/wiki/page?id=extensions%3Aitomig%3Acheck_mk-collector


Check_mk Data Collector

name:
Check_mk Data Collector
version:
0.1.0
release:
2016-05-20
description:
Parses and imports data from check_mk into iTop
itop-version:
2.0, 2.1, 2.2
keyword:
inventorydata synchronizationcheck_mknagiositomig
dependencies:
itop-config-mgmt
author:
ITOMIG GmbH
download:
https://odoo.itomig.de/shop/product/check-mk-collector-126
Download

This standalone PHP application collects data managed by check_mk's inventory feature. It synchronizes hardware information with an iTop instance using Synchronization Data Sources.

Features

  • Collects Server and PC inventory along with Models, Brands, OS Families and Versions.

  • Connects to iTop via the web interface.

Limitations

Requires direct (read) access to check_mk's inventory files. This means that it must be run on the machine check_mk is installed on (with adequate permissions). Alternatively, the inventory data files used by check_mk must be copied somewhere the application may access them.

Distinguishing between PCs and Servers must be achieved by manually specifying host name patterns. See Configuration below.

Requirements

  • PHP Version 5.3.0

  • Read access on check_mk's inventory files

  • Access to the iTop REST service

Installation

  • Extract the contents of the archive.

  • Edit conf/params.local.xml with your iTop credentials.

  • Create collectors/params.distrib.xml from collectors/params.template.xml and edit the configuration options.

README and README_checkmk in the archive's root directory contain further documentation.

Configuration

Mandatory parameters

Edit the following parameters in conf/params.local.xml:

<itop_url>https://localhost/</itop_url>
<itop_login>admin</itop_login>
<itop_password>admin</itop_password>
ParameterMeaningSample value
itop_urlURL to the iTop Applicationhttps://localhost/itop
itop_loginUser name for connecting to iTop. Must have admin rights for executing the data synchro.admin
itop_passwordPassword for the iTop account. 

These parameters must also be set in collectors/params.distrib.xml:

<default_org_id>Demo</default_org_id>
<check_mk_dir>/var/lib/check_mk/inventory</check_mk_dir>
<type_mapping type="array">
  <pattern>/.*pc.*/PC</pattern>
  <pattern>/.*srv.*/Server</pattern>
</type_mapping>
ParameterMeaningSample value
default_org_idThe name of the iTop organization under which inventory items should be stored.Demo
check_mk_dirThe directory where the collector should check for inventory data files./var/lib/check_mk/inventory/
type_mappingThe mapping table which specifies how hosts should be categorized based on their host name in check_mk. Takes patterns in the format /pattern/replacement, where pattern is a regex matched against the host name andreplacement must either be Server or PC. Host names which match no pattern will be ignored.<pattern>/.*/Server</pattern> - catch-all pattern which categorizes all hosts as Servers

Optional parameters

The following boolean parameters may be set in collectors/params.distrib.xml:

<use_network_hostname>false</use_network_hostname>
<skip_gz>true</skip_gz>
<skip_dot>true</skip_dot>
ParameterMeaningSample value
use_network_hostnameUse the host name used on the network by a given inventory machine instead of using the host name stored it is stored under in check_mk. Default is false.false
skip_gzWhen looking for inventory files, skip .gz counterparts if they are found. Default is true.true
skip_dotSkip any dotfiles encountered in the inventory file directory. Default is true.true

The file collectors/params.template.xml contains default values for all configuration items and further documentation on their effects.

Defaulted fields

It may be useful to give a constant value that should be assigned to a specific field that isn't otherwise filled by the collector. This is done incollectors/params.distrib.xml:

<default_fields type="hash">
  <field_name>field value</field_name>
  <field_name2>another field value</field_name2>
</default_fields>

This is particularly useful for fields such as status and business_criticity if they are in use. Only fields which both Servers and PCs have should be specified this way.

Data mapping

The data in check_mk is gathered from a variety of sources and thus may not always fit the existing iTop data. A mapping table is used to define how data should be converted to fit in with your needs when the above items are being added to iTop.

In this collector, this applies to Brand, OS Family and OS Version objects.

Mapping tables are edited in collectors/params.distrib.xml. The file collectors/params.template.xml, supplied in the archive, contains examples and further documentation.

Example:

<osfamily_mapping type="array">
  <pattern>/.*linux.*/Linux</pattern>
  <pattern>/.*windows.*/Windows</pattern>
  <pattern>/.*mac os.*/Mac OS</pattern>
  <pattern>/.*solaris.*/Solaris</pattern>
  <pattern>/.*bsd.*/BSD</pattern>
  <pattern>/.*/$1$s</pattern>
</osfamily_mapping>

This will map Linux, Windows, Mac OS, Solaris and BSD OS family variations. <pattern>/.*/$1$s</pattern> will allow the collector to add any values which don't fit any other patterns to iTop without manipulating them.

Omit <pattern>/.*/$1$s</pattern> if you want OS Families (or OS Versions or Brands) which are not otherwise defined in the mapping table to be ignored. This is the default behaviour.

Usage

The first time the collector is run, the following command is recommended:

php exec.php --configure_only

This will create the Synchronization Data Sources if they don't already exist.

To collect the data without synchronizing with iTop, run

php exec.php --collect_only

This will store the collected data in CSV files in the data/ subdirectory of the collector - this is useful for checking the data before it is passed over to iTop. Mapped values can be checked and mapping tables updated - however, note that collection should be run again after such changes.

Finally, to perform iTop synchronization with the data collected:

php exec.php --synchro_only

Data collection and synchronization (and data source update/creation if necessary) can be performed in a single step if desired:

php exec.php

While this is simpler, it affords less control over the synchronization process.

More information on running the collector may be found on the itop-data-collector-base page.

Data Collection Reference

Servers and PCs

Servers and PCs have the same data collected about them.

Field in iTopcheck_mk inventory entry
name*The check_mk host name, which is the name of the check_mk inventory data file, or networking host name (see Configuration above)
org_id*Taken from default_org_id in configuration
cpuhardware → cpu → model
ramhardware → memory → total_ram_usable (in MiB)
osfamily_idMapped using data in either software→os→type or software→os→name using osfamily_mapping pattern list
osversion_idMapped from software→os→name using osversion_mapping pattern list
serialhardware → system → serial
brand_idMapped from hardware→system→vendor using brand_mapping pattern list
model_idMapped from hardware→system→family

* denotes mandatory fields - the rest can and will be ignored if the relevant data is not present in check_mk without preventing the object from being synchronized.

 

标签:
由 superadmin 在 2020/08/25, 16:42 创建
    

需要帮助?

如果您需要有关XWiki的帮助,可以联系:

深圳市艾拓先锋企业管理咨询有限公司