OCS库存数据收集器

名称:OCS库存数据采集器

描述:OCS库存数据采集器NG

版本:1.0.5

发布:2019-10-29

下载:https://store.itophub.io/en_US/products/ocsng-data-collector

代码:ocsng-data-collector

状态:稳定

备用名称:OCS库存数据采集器NG

扩散:iTop Hub,Combodo网站

这个独立的应用可以从一个OCS库存NG 服务器以便使用收集的服务器,PC和虚拟机填充iTop CMDB。采集器使用iTop数据同步引擎来动态在OCS库存和iTop之间的信息。

https://www.itophub.io/wiki/media?w=450&tok=c885ea&media=extensions%3Aitopocsngcollector.png

附加(和可选)扩展OCS库存详情 可用于在每个同步的对象(服务器,PC或虚拟机)的iTop内部直接显示OCS库存页面的内容:

https://www.itophub.io/wiki/media?w=650&tok=59d59a&media=extensions%3Aocsngitopframe.png

特征

  • 来自OCS库存服务器的品牌,模型,OS家族,OS版本,物理服务器,PC和虚拟机的自动化库存
  • 自动化的网络接口库存
  • 采集器可以驻留在任何系统上,并可以通过Web访问iTop和mysql访问OCS库存服务器
  • 在iTop中自动创建和更新同步数据源。
  • 可选的小型扩展程序可用于在同步的PC,服务器和VirtualMachines上显示额外的选项卡“ OCS库存”。此选项卡显示设备的OCS页面(使用IFRAME)。

该采集器利用iTop的内置数据同步机制。有关数据同步如何工作的更多信息,请参考数据同步概述 并依靠基础数据采集器 机制

修订记录

日期版本描述
2019-10-291.0.5处理TeemIp:
-自动检测是否存在TeemIp(作为iTop模块或独立的应用)。
-IPv4地址的可选同步
-IP接口的可选同步
2018-09-041.0.4第一个公众版本。不再需要更改数据模型。
2018-06-261.0.3新的调试跟踪
2015-05-201.0.1修复了一些错误:支持Windows文件名(即c:\ Program Files \…)。 SPEED从“ 100 Mbbs”转换为“ 100”。强制对“笔记本电脑”等进行不区分大小写的比较。
2015-02-161.0.0第一个版本

局限性

  • 采集器不检索已安装的软件信息
  • 采集器未规范模型,OS家族和OS版本
  • 采集器仅同步OCS中具有有效序列号的PC和服务器
  • 如果启用了IP收集,则仅收集IPv4地址,而不收集IPv6
  • 如果使用HTTPS访问iTop,则OCS库存也必须如此,否则由于浏览器的安全限制,iTop中的OCS库存的内联框架将不会显示。
  • iTop和OCS之间没有单一登录,因此在显示“ OCS”选项卡时,您必须登录名到OCS。

要求

  • PHP版本5.3.0
  • 对OCS库存NG mysql数据库的访问
  • 可以访问iTop Web服务(REST +同步_导入。php和同步_exec.php)。注意:从iTop 2.5.0开始,用户必须在iTop中具有同步REST服务简档。
  • + 基础数据采集器 要求。

安装

安装OCS库存集成扩展

通过iTop Hub自动安装

  • 转到扩展商店 在iTop Hub上
  • 单击购物车图标以获取扩展,并按照屏幕上的说明将其部署在iTop实例上

手册安装

  • 将文件“ itop-ocsng.zip”解压缩到iTop扩展文件夹中
  • 确保Web服务器流程具有足够的权利来读取复制的文件
  • 启动iTop设置
  • 出现提示时,选择OCS库存集成扩展

https://www.itophub.io/wiki/media?w=450&tok=fbdec2&media=extensions%3Aocsngextensionsetup.png

  • 编辑iTop配置文件以指定访问OCS Web服务器的URL:
    'itop-ocsng' => array (
                'ocsng_url' => 'http://localhost/ocsreports/',
        ),

安装OCS库存数据采集器

  • 在将运行采集器应用的计算机上的文件夹中,展开zip归档“ ocsng-数据-采集器”的内容。该计算机必须具有对OCS NG数据库的SQL访问权限,以及对iTop采集器的Web访问权限。
  • 创建文件conf/params.local.xml以适合您的安装,并提供适当的凭据以连接到OCS NG和iTop。

默认情况下,此文件应包含用于连接到iTop服务器和OCS NG服务器的值:

<parameters>
  <itop_url>http://localhost/</itop_url>
  <itop_login>admin</itop_login>
  <itop_password>admin</itop_password>
  <contact_to_notify>john.doe@demo.com</contact_to_notify>
  <synchro_user>admin</synchro_user>
  <sql_host>localhost</sql_host>
  <sql_database>ocsweb;charset=UTF8</sql_database>
  <sql_login>root</sql_login>
  <sql_password>root</sql_password>
</parameters>
参数含义样品价值
itop_urliTop应用的URLhttps://localhost/
itop_login连接到iTop的登录名(用户账号)。必须具有管理员权利才能执行数据同步。管理员
itop_passwordiTop账号的密码。 
contact_to_notifyiTop中现有联系人的发送邮件地址,将被通知同步结果john.doe@demo.com
synchro_useriTop用户用于同步Web服务管理员
sql_host连接到OCS的地址服务器数据库默认值:localhost
sql_database数据库连接。您可以使用; charset强制字符集默认ocsweb
sql_ogin登录名连接到OCS数据库 
sql_password连接到OCS数据库的密码 

配置

默认情况下,数据集合配置在文件collectors/params.distrib.xml中定义。不要修改该文件!如果需要修改配置,请在conf目录中创建一个名为params.local.xml的文件,然后将所需的定义复制粘贴到其中(两个XMl文件的结构相同)。此配置定义必须在OCS NG配置上执行哪些SQL查询才能使用iTop检索数据和数据。

 <default_org_id>Demo</default_org_id>
  <default_status>production</default_status>
  <PCCollection>yes</PCCollection>
  <ServerCollection>yes</ServerCollection>
  <VMCollection>yes</VMCollection>
  <OCSBrandCollector_query>SELECT DISTINCT SMANUFACTURER as primary_key, SMANUFACTURER as name FROM bios</OCSBrandCollector_query>
  <OCSOSFamilyCollector_query>SELECT DISTINCT OSNAME as primary_key,OSNAME as name FROM hardware</OCSOSFamilyCollector_query>
  <OCSOSVersionCollector_query>SELECT DISTINCT CONCAT(OSNAME,OSVERSION) as primary_key,OSNAME as osfamily_id,OSVERSION as name FROM hardware</OCSOSVersionCollector_query>
  <OCSServerModelCollector_query>SELECT DISTINCT CONCAT(SMANUFACTURER,SMODEL) AS primary_key,SMANUFACTURER as brand_id,SMODEL as name, 'Server' As type FROM bios WHERE TYPE COLLATE utf8_general_ci NOT IN ('Notebook','Laptop') AND SMANUFACTURER COLLATE utf8_general_ci NOT LIKE 'VMware%'</OCSServerModelCollector_query>
  <OCSServerCollector_query>SELECT b.SSN as primary_key,h.ID as ocsid, h.NAME as name, h.OSNAME as osfamily_id,h.OSVERSION as osversion_id, h.PROCESSORT as cpu, h.MEMORY as ram, h.IPADDR as managementip, b.SMANUFACTURER as brand_id,b.SMODEL as model_id,b.SSN as serialnumber, '$default_status$' as status, '$default_org_id$' as org_id FROM hardware AS h JOIN bios AS b ON h.id=b.hardware_id WHERE b.TYPE COLLATE utf8_general_ci NOT IN ('Notebook','Laptop') AND SMANUFACTURER COLLATE utf8_general_ci NOT LIKE 'VMware%'</OCSServerCollector_query>
  <OCSServerPhysicalInterfaceCollector_query>SELECT  n.ID as primary_key,n.DESCRIPTION as name, IF(SPEED REGEXP '^[0-9]+ ', LEFT(SPEED, LOCATE(' ', SPEED)), SPEED) as speed, MACADDR as macaddress, IPADDRESS as ipaddress, IPMASK as ipmask,IPGATEWAY as ipgateway,h.NAME as connectableci_id FROM networks AS n JOIN hardware AS h ON n.hardware_id=h.id JOIN bios AS b ON h.id=b.hardware_id WHERE SMANUFACTURER COLLATE utf8_general_ci NOT LIKE 'VMware%' AND b.TYPE COLLATE utf8_general_ci NOT IN ('Notebook','Laptop')</OCSServerPhysicalInterfaceCollector_query>
  <OCSPCModelCollector_query>SELECT DISTINCT CONCAT(SMANUFACTURER,SMODEL) AS primary_key,SMANUFACTURER as brand_id,SMODEL as name, 'PC' As type FROM bios WHERE TYPE COLLATE utf8_general_ci IN ('Notebook','Laptop') AND SMANUFACTURER NOT LIKE 'VMware%'</OCSPCModelCollector_query>
  <OCSPCCollector_query>SELECT b.SSN as primary_key,h.ID as ocsid, h.NAME as name, h.OSNAME as osfamily_id,h.OSVERSION as osversion_id, h.PROCESSORT as cpu, h.MEMORY as ram, b.SMANUFACTURER as brand_id,b.SMODEL as model_id,b.SSN as serialnumber, '$default_status$' as status, '$default_org_id$' as org_id FROM hardware AS h JOIN bios AS b ON h.id=b.hardware_id WHERE b.TYPE COLLATE utf8_general_ci IN ('Notebook','Laptop') AND SMANUFACTURER COLLATE utf8_general_ci NOT LIKE 'VMware%'</OCSPCCollector_query> 
  <OCSPCPhysicalInterfaceCollector_query>SELECT  n.ID as primary_key,n.DESCRIPTION as name, IF(SPEED REGEXP '^[0-9]+ ', LEFT(SPEED, LOCATE(' ', SPEED)), SPEED) as speed, MACADDR as macaddress, IPADDRESS as ipaddress, IPMASK as ipmask,IPGATEWAY as ipgateway,h.NAME as connectableci_id FROM networks AS n JOIN hardware AS h ON n.hardware_id=h.id JOIN bios AS b ON h.id=b.hardware_id WHERE SMANUFACTURER COLLATE utf8_general_ci NOT LIKE 'VMware%' AND b.TYPE COLLATE utf8_general_ci IN ('Notebook','Laptop')</OCSPCPhysicalInterfaceCollector_query>
  <OCSVirtualMachineCollector_query>SELECT h.ID as primary_key,h.ID as ocsid, h.NAME as name, h.OSNAME as osfamily_id,h.OSVERSION as osversion_id, h.PROCESSORT as cpu, h.MEMORY as ram,h.IPADDR as managementip, '$default_status$' as status, '$default_org_id$' as org_id FROM hardware AS h JOIN bios AS b ON h.id=b.hardware_id WHERE SMANUFACTURER COLLATE utf8_general_ci LIKE 'VMware%'</OCSVirtualMachineCollector_query>
  <OCSLogicalInterfaceCollector_query>SELECT  n.ID as primary_key,n.DESCRIPTION as name, IF(SPEED REGEXP '^[0-9]+ ', LEFT(SPEED, LOCATE(' ', SPEED)), SPEED) as speed, MACADDR as macaddress, IPADDRESS as ipaddress, IPMASK as ipmask,IPGATEWAY as ipgateway,h.NAME as virtualmachine_id FROM networks AS n JOIN hardware AS h ON n.hardware_id=h.id JOIN bios AS b ON h.id=b.hardware_id WHERE SMANUFACTURER COLLATE utf8_general_ci LIKE 'VMware%'</OCSLogicalInterfaceCollector_query>

原则

  • 对于iTop的对象至导入的每个类别(PC,服务器,VM,品牌,模型,OSVersion OSFamily),采集器应用都会创建同步数据源。
  • 每个采集器与一个SQL查询关联(通过参数<name_of_the_采集器> _查询)。
  • 此查询必须返回列,其中别名(即列的“名称”)对应于相应同步数据源的预期字段。
  • 这些查询可以进行调整以适合您的需求(例如,以更好地区分PC和服务器或更改某些列的一些默认值)
  • 由于PC,服务器和虚拟机的同步都依赖于它们自己的SQL查询,因此确保这3个查询的结果不重叠是很重要的。否则,相同的“系统”将在itop中多次导入(例如,作为PC和服务器)。
参数含义
default_org_id为同步的配置项定义默认的组织
default_status为同步的配置项定义默认的状况
PCCollection定义PC收集是否处于活动状态(是)(否)
ServerCollection定义服务器集合是否处于活动状态(是)(否)
VMCollection定义虚拟机集合是否处于活动状态(是)(否)
OCSBrandCollector_querySQL查询从OCS NG服务器中检索已知品牌的列表
OCSOSFamilyCollector_querySQL查询从OCS NG服务器中检索已知操作系统家族的列表
OCSOSVersionCollector_querySQL查询从OCS NG服务器中检索已知OS版本的列表
OCSServerModelCollector_querySQL查询从OCS NG服务器中检索已知物理服务器模型的列表
OCSServerCollector_querySQL查询从OCS NG服务器检索物理服务器列表
OCSServerPhysicalInterfaceCollector_querySQL查询从OCS NG服务器中检索服务器的物理网络接口列表
OCSPCModelCollector_querySQL查询从OCS NG服务器中检索已知PC型号的列表
OCSPCCollector_querySQL查询从OCS NG服务器检索PC列表
OCSPCPhysicalInterfaceCollector_querySQL查询从OCS NG服务器检索PC的物理接口列表
OCSVirtualMachineCollector_query 
OCSLogicalInterfaceCollector_querySQL查询从OCS NG服务器检索虚拟机的逻辑网络接口列表

可以在文件conffparams.local.xml中重新定义这些查询,以将特定的需求纳入账号(例如,创建的服务器,PC,虚拟机以及默认组织的变更的状况)。默认情况下,仅创建VMWare虚拟机。如果要处理其他类型的VM,则必须调整Virtualmachine查询

文件params.distrib.xml包含参数的默认值。这两个文件(params.distrib.xml和params.local.xml)使用完全相同的格式。但是params.distrib.xml被视为引用,并且应保持不变。如果需要变更的变更和价值,请在params.local.xml中复制并修改其定义。 params.local.xml中的值优先于params.distrib.xml中的值

IP和IP接口集合

采集器自动检测远程iTop应用上是否存在TeemIp(作为模块,甚至作为独立应用),以及是否安装了TeemIp Zone管理扩展。如果是这种情况,则以下参数可能会应用IP地址和IP接口集合。

<?xml version="1.0" encoding="UTF-8"?>
  <parameters>
    ...
    <!-- TeemIp options -->
    <collect_ips>yes</collect_ips>
    <default_ip_status>allocated</default_ip_status>
    <manage_ipv6>no</manage_ipv6>
    <default_view_name></default_view_name>
    ...
  </parameters>
参数含义样品价值
collect_ips触发IP地址收集
default_ip_status新创建的IP地址的状态已分配
manage_ipv6触发IPv6收集-尚无法使用没有
default_view_name新创建的IP地址的视图<空字符串>

在此阶段,尚未收集IPv6。这是由于采集器基座的局限性所致,目前尚无法处理此类对象。

用法

要启动数据集合并与iTop同步,请运行以下命令(从安装了数据采集器应用的根目录中):

php exec.php

以下(可选)命令行选项可用:

选项含义默认价值
--console_log_level = <level>控制台的输出级别。从-1(无)到9(调试)。6(信息)
--collect_only仅运行数据集合,但不运行带有iTop的动态数据
--synchro_only将先前收集的数据(存储在数据目录中)与iTop同步。不要运行该集合。
--configure_only在iTop中检查(并根据需要更新)同步数据源并退出。不要运行收集或同步 
--max_chunk_size = <size>一次保存流程的最大项目数,以保留系统的内存。如果流程还有更多项目,则流程将进行迭代。1000

命令行的执行将:

  1. 连接到iTop以创建同步数据源(或检查它们的定义是否已存在,并在需要时进行更新)
  2. 连接到OCS NG以收集有关服务器,PC,虚拟机的信息
  3. 将收集的数据上传到iTop(这是配置参数<name_of_the_采集器> _查询
  4. 动态将收集的数据与现有的iTop配置项一起使用。

排程

交互式运行数据采集器之后,下一步是安排其执行时间,以便定期定期进行收集和导入。

数据采集器不提供任何特定的调度机制,但是可以使用以下任意一种来调度简单的命令行php exec.php:cron (在Linux系统上)或使用任务计划程序 在Windows上。

为了获得最佳结果,请不要忘记调整配置参数full_load_interval以使其与调度频率保持一致。

原文:https://www.itophub.io/wiki/page?id=extensions%3Aocsng-data-collector


Data collector for OCS Inventory

name:
Data collector for OCS Inventory
description:
Data Collector for OCS Inventory NG
version:
1.0.5
release:
2019-10-29
download:
https://store.itophub.io/en_US/products/ocsng-data-collector
code:
ocsng-data-collector
state:
stable
alternate-name:
Data collector for OCS Inventory NG
diffusion:
iTop Hub,Combodo site

This stand-alone application collects information from a single OCS Inventory NG server in order to populate the iTop CMDB with the collected Servers, PCs and Virtual machines. The collector uses the iTop data synchronization engine to synchronize the information between OCS Inventory and iTop.

https://www.itophub.io/wiki/media?w=450&tok=c885ea&media=extensions%3Aitopocsngcollector.png

An additional (and optional) extension Component details from OCS is available to display the content of the OCS Inventory pages directly inside iTop, for each synchronized object (Server, PC or Virtual Machine):

https://www.itophub.io/wiki/media?w=650&tok=59d59a&media=extensions%3Aocsngitopframe.png

Features

  • Automated inventory of Brand, Model, OS Family, OS Version, Physical Server, PC and Virtual Machine from OCS Inventory server

  • Automated inventory of Network Interfaces

  • The collector can reside on any system with web access to iTop and mysql access to the OCS Inventory server

  • Automatic creation and update of the Synchronization Data Sources in iTop.

  • An optional small extension is available to display an extra tab “OCS Inventory” on synchronized PCs, Servers and VirtualMachines. This tab displays the OCS page for the device (using an IFRAME).

This collector makes use of iTop's built-in Data Synchronization mechanism. For more information about how the data synchronization works, refer to Data Synchronization Overviewand relies on Data collector Base mechanism

Revision History

DateVersionDescription
2019-10-291.0.5Handles TeemIp :
- Automatically detects if TeemIp (as an iTop module or as a standalone application) is present.
- Optional synchronization of IPv4 addresses
- Optional synchronisation of IP interfaces
2018-09-041.0.4First public version. No longer requires an alteration of the data model.
2018-06-261.0.3New debug trace
2015-05-201.0.1A few bug fixes: support of Windows file names (i.e. c:\Program Files\…). Conversion of SPEED from '100 Mb/s' to '100'. Forcing a NON case-sensitive comparison for 'Laptop' et al.
2015-02-161.0.0First version

Limitations

  • The collector does not retrieve installed software information

  • The collector is not normalizing Model, OS Family and OS Version

  • The collector synchronizes only PCs and Servers which have a valid serial number in OCS

  • If IP collection is enabled, only IPv4 addresses are collected, not IPv6

  • If your iTop is accessed using HTTPS, then the same must be true for OCS Inventory otherwise the inline frame of OCS Inventory inside iTop will not display because of browsers's security restrictions.

  • There is no single sign-on between iTop and OCS, so you'll have to login to OCS when displaying the OCS tab.

Requirements

  • PHP Version 5.3.0

  • An access to the OCS Inventory NG mysql database

  • An access to the iTop web services (REST + synchro_import.php and synchro_exec.php). Note: starting with iTop 2.5.0, the user must have the profile REST Services User in iTop.

  • Data collector Base requirements.

Installation

Installation of the OCS Inventory integration extension

Automated installation via iTop Hub

  • Go to the extensions store on iTop Hub

  • Click on the cart icon to make the acquisition of the extension and follow the on-screen instructions to deploy it on your iTop instance

Manual installation

  • unzip the file “itop-ocsng.zip” into the iTop extensions folder

  • make sure that the web server process has enough rights to read the copied files

  • Launch iTop setup

  • Select the OCS Inventory Integration extension, when prompted

https://www.itophub.io/wiki/media?w=450&tok=fbdec2&media=extensions%3Aocsngextensionsetup.png

  • Edit the iTop configuration file to specify the URL to access the OCS web server:

      'itop-ocsng' => array (
                'ocsng_url' => 'http://localhost/ocsreports/',
        ),

Install the Data collector for OCS Inventory

  • Expand the content of the zip archive “ocsng-data-collector” in a folder on the machine that will run the collector application. This machine must have an SQL access to the OCS NG database and a web access to the iTop server.

  • create the file conf/params.local.xml to suit your installation, supplying the appropriate credentials to connect to OCS NG and iTop.

By default this file should contains the values used to connect to iTop server and OCS NG server:

<parameters>
  <itop_url>http://localhost/</itop_url>
  <itop_login>admin</itop_login>
  <itop_password>admin</itop_password>
  <contact_to_notify>john.doe@demo.com</contact_to_notify>
  <synchro_user>admin</synchro_user>
  <sql_host>localhost</sql_host>
  <sql_database>ocsweb;charset=UTF8</sql_database>
  <sql_login>root</sql_login>
  <sql_password>root</sql_password>
</parameters>
ParameterMeaningSample value
itop_urlURL to the iTop Applicationhttps://localhost/
itop_loginLogin (user account) for connecting to iTop. Must have admin rights for executing the data synchro.admin
itop_passwordPassword for the iTop account. 
contact_to_notifyThe email address of an existing contact in iTop, to be notified of the results of the synchronizationjohn.doe@demo.com
synchro_useriTop user used for synchronization web serviceadmin
sql_hostThe address to connect to OCS server databasedefault:localhost
sql_databasedatabase to connect to. You can use ;charset to force the character setdefault ocsweb
sql_loginLogin to connect to the OCS database 
sql_passwordPassword to connect to the OCS database 

Configuration

By default the data collection configuration is defined in the file collectors/params.distrib.xml. Do not modify this file! If you need to adapt the configuration, create a file named params.local.xml in the conf directory and copy/paste the needed definitions into it (the structure of both XMl files is the same). This configuration defines which SQL queries have to be executed on the OCS NG server to retrieve the data and synchronize with iTop.

  <default_org_id>Demo</default_org_id>
  <default_status>production</default_status>
  <PCCollection>yes</PCCollection>
  <ServerCollection>yes</ServerCollection>
  <VMCollection>yes</VMCollection>
  <OCSBrandCollector_query>SELECT DISTINCT SMANUFACTURER as primary_key, SMANUFACTURER as name FROM bios</OCSBrandCollector_query>
  <OCSOSFamilyCollector_query>SELECT DISTINCT OSNAME as primary_key,OSNAME as name FROM hardware</OCSOSFamilyCollector_query>
  <OCSOSVersionCollector_query>SELECT DISTINCT CONCAT(OSNAME,OSVERSION) as primary_key,OSNAME as osfamily_id,OSVERSION as name FROM hardware</OCSOSVersionCollector_query>
  <OCSServerModelCollector_query>SELECT DISTINCT CONCAT(SMANUFACTURER,SMODEL) AS primary_key,SMANUFACTURER as brand_id,SMODEL as name, 'Server' As type FROM bios WHERE TYPE COLLATE utf8_general_ci NOT IN ('Notebook','Laptop') AND SMANUFACTURER COLLATE utf8_general_ci NOT LIKE 'VMware%'</OCSServerModelCollector_query>
  <OCSServerCollector_query>SELECT b.SSN as primary_key,h.ID as ocsid, h.NAME as name, h.OSNAME as osfamily_id,h.OSVERSION as osversion_id, h.PROCESSORT as cpu, h.MEMORY as ram, h.IPADDR as managementip, b.SMANUFACTURER as brand_id,b.SMODEL as model_id,b.SSN as serialnumber, '$default_status$' as status, '$default_org_id$' as org_id FROM hardware AS h JOIN bios AS b ON h.id=b.hardware_id WHERE b.TYPE COLLATE utf8_general_ci NOT IN ('Notebook','Laptop') AND SMANUFACTURER COLLATE utf8_general_ci NOT LIKE 'VMware%'</OCSServerCollector_query>
  <OCSServerPhysicalInterfaceCollector_query>SELECT  n.ID as primary_key,n.DESCRIPTION as name, IF(SPEED REGEXP '^[0-9]+ ', LEFT(SPEED, LOCATE(' ', SPEED)), SPEED) as speed, MACADDR as macaddress, IPADDRESS as ipaddress, IPMASK as ipmask,IPGATEWAY as ipgateway,h.NAME as connectableci_id FROM networks AS n JOIN hardware AS h ON n.hardware_id=h.id JOIN bios AS b ON h.id=b.hardware_id WHERE SMANUFACTURER COLLATE utf8_general_ci NOT LIKE 'VMware%' AND b.TYPE COLLATE utf8_general_ci NOT IN ('Notebook','Laptop')</OCSServerPhysicalInterfaceCollector_query>
  <OCSPCModelCollector_query>SELECT DISTINCT CONCAT(SMANUFACTURER,SMODEL) AS primary_key,SMANUFACTURER as brand_id,SMODEL as name, 'PC' As type FROM bios WHERE TYPE COLLATE utf8_general_ci IN ('Notebook','Laptop') AND SMANUFACTURER NOT LIKE 'VMware%'</OCSPCModelCollector_query>
  <OCSPCCollector_query>SELECT b.SSN as primary_key,h.ID as ocsid, h.NAME as name, h.OSNAME as osfamily_id,h.OSVERSION as osversion_id, h.PROCESSORT as cpu, h.MEMORY as ram, b.SMANUFACTURER as brand_id,b.SMODEL as model_id,b.SSN as serialnumber, '$default_status$' as status, '$default_org_id$' as org_id FROM hardware AS h JOIN bios AS b ON h.id=b.hardware_id WHERE b.TYPE COLLATE utf8_general_ci IN ('Notebook','Laptop') AND SMANUFACTURER COLLATE utf8_general_ci NOT LIKE 'VMware%'</OCSPCCollector_query> 
  <OCSPCPhysicalInterfaceCollector_query>SELECT  n.ID as primary_key,n.DESCRIPTION as name, IF(SPEED REGEXP '^[0-9]+ ', LEFT(SPEED, LOCATE(' ', SPEED)), SPEED) as speed, MACADDR as macaddress, IPADDRESS as ipaddress, IPMASK as ipmask,IPGATEWAY as ipgateway,h.NAME as connectableci_id FROM networks AS n JOIN hardware AS h ON n.hardware_id=h.id JOIN bios AS b ON h.id=b.hardware_id WHERE SMANUFACTURER COLLATE utf8_general_ci NOT LIKE 'VMware%' AND b.TYPE COLLATE utf8_general_ci IN ('Notebook','Laptop')</OCSPCPhysicalInterfaceCollector_query>
  <OCSVirtualMachineCollector_query>SELECT h.ID as primary_key,h.ID as ocsid, h.NAME as name, h.OSNAME as osfamily_id,h.OSVERSION as osversion_id, h.PROCESSORT as cpu, h.MEMORY as ram,h.IPADDR as managementip, '$default_status$' as status, '$default_org_id$' as org_id FROM hardware AS h JOIN bios AS b ON h.id=b.hardware_id WHERE SMANUFACTURER COLLATE utf8_general_ci LIKE 'VMware%'</OCSVirtualMachineCollector_query>
  <OCSLogicalInterfaceCollector_query>SELECT  n.ID as primary_key,n.DESCRIPTION as name, IF(SPEED REGEXP '^[0-9]+ ', LEFT(SPEED, LOCATE(' ', SPEED)), SPEED) as speed, MACADDR as macaddress, IPADDRESS as ipaddress, IPMASK as ipmask,IPGATEWAY as ipgateway,h.NAME as virtualmachine_id FROM networks AS n JOIN hardware AS h ON n.hardware_id=h.id JOIN bios AS b ON h.id=b.hardware_id WHERE SMANUFACTURER COLLATE utf8_general_ci LIKE 'VMware%'</OCSLogicalInterfaceCollector_query>

Principles

  • For each class of object to import into iTop (PC, Server, VM, Brand, Model, OSVersion OSFamily), a Synchro Data Source is created by the collector application.

  • Each collector is associated with an SQL query (via the parameter <name_of_the_collector>_query).

  • This query must return column where aliases (i.e. “name” of the columns) correspond to the expected fields for the corresponding Synchro Data Source.

  • These queries can be adapted to suit your needs (for example to better differentiate PCs and Servers or to change/set some default values for some columns)

  • Since the synchronization of PCs, Servers and Virtual Machines all rely on their own SQL query, it is important to make sure that the results of these 3 queries do no overlap. Otherwise the same “system” will be imported several times in itop (for example as both a PC and a Server).

ParameterMeaning
default_org_idDefine the default organization for the synchronized CIs
default_statusDefine the default status for the synchronized CIs
PCCollectionDefine wether PC collection is active (yes) or not (no)
ServerCollectionDefine wether Server collection is active (yes) or not (no)
VMCollectionDefine wether Virtual machine collection is active (yes) or not (no)
OCSBrandCollector_querySQL query to retrieve from OCS NG server the list of known Brands
OCSOSFamilyCollector_querySQL query to retrieve from OCS NG server the list of known OS Families
OCSOSVersionCollector_querySQL query to retrieve from OCS NG server the list of known OS Version
OCSServerModelCollector_querySQL query to retrieve from OCS NG server the list of known Physical server models
OCSServerCollector_querySQL query to retrieve from OCS NG server the list of physical servers
OCSServerPhysicalInterfaceCollector_querySQL query to retrieve from OCS NG server the list of physical network interfaces for servers
OCSPCModelCollector_querySQL query to retrieve from OCS NG server the list of known PC models
OCSPCCollector_querySQL query to retrieve from OCS NG server the list of PCs
OCSPCPhysicalInterfaceCollector_querySQL query to retrieve from OCS NG server the list of physical interfaces for PCs
OCSVirtualMachineCollector_query 
OCSLogicalInterfaceCollector_querySQL query to retrieve from OCS NG server the list of logical network interfaces for virtual machines

These queries can be redefined in the file conf/params.local.xml in order to take into account your specific needs (For instance change de status of created Server, PC, Virtual Machine, as well as de default organisation). By default, only VMWare virtual machines are created. The Virtualmachine query has to be adapted if you want to handle other type of VMs

The file params.distrib.xml contains the default values for the parameters. Both files (params.distrib.xml and params.local.xml) use exactly the same format. But params.distrib.xml is considered as the reference and should remain unmodified. Should you need to change the value of a parameter, copy and modify its definition in params.local.xml. The values inparams.local.xml have precedence over the ones in params.distrib.xml

IPs and IP Interfaces collection

The collector automatically detects if TeemIp is present on the remote iTop application (as a module or even as a stand-alone application) and if TeemIp Zone Management extension is installed. Should that be the case, then the following parameters may trigger IP addresses and IP interfaces collection.

<?xml version="1.0" encoding="UTF-8"?>
  <parameters>
    ...
    <!-- TeemIp options -->
    <collect_ips>yes</collect_ips>
    <default_ip_status>allocated</default_ip_status>
    <manage_ipv6>no</manage_ipv6>
    <default_view_name></default_view_name>
    ...
  </parameters>
ParameterMeaningSample value
collect_ipsTriggers IP addresses collectionyes
default_ip_statusSatus of newly created IP addressesallocated
manage_ipv6Triggers IPv6 collection - not working yetno
default_view_nameView of the newly created IP addresses<empty string>

At this stage, IPv6 are not collected. This is due to a limitation of the collector base which cannot handle such objects yet.

Usage

To launch the data collection and synchronization with iTop, run the following command (from the root directory where the data collector application is installed):

php exec.php

The following (optional) command line options are available:

OptionMeaningdefault value
--console_log_level=<level>Level of output to the console. From -1 (none) to 9 (debug).6 (info)
--collect_onlyRun only the data collection, but do not synchronize the data with iTopfalse
--synchro_onlySynchronizes the data previously collected (stored in the data directory) with iTop. Do not run the collection.false
--configure_onlyCheck (and update if necessary) the synchronization data sources in iTop and exit. Do NOT run the collection or the synchronization 
--max_chunk_size=<size>Maximum number of items to process in one pass, for preserving the memory of the system. If there are more items to process, the application will iterate.1000

The execution of the command line will:

  1. Connect to iTop to create the Synchronization Data Sources (or check their definition if they already exist, updating them if needed)

  2. Connect to OCS NG to collect the information about the Servers, PC, Virtual Machines

  3. Upload the collected data into iTop (this is the configuration parameter <name_of_the_collector>_query

  4. Synchronize the collected data with the existing iTop CIs.

Scheduling

Once you've run the data collector interactively, the next step is to schedule its execution so that the collection and import occurs automatically at regular intervals.

The data collector does not provide any specific scheduling mechanism, but the simple command line php exec.php can be scheduled with either cron (on Linux systems) or using the Task Scheduler on Windows.

For optimal results, don't forget to adjust the configuration parameter full_load_interval to make it consistent with the frequency of the scheduling.

标签:
由 superadmin 在 2020/08/27, 16:06 创建
    

需要帮助?

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

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