跳转至

IBM i/AS400

·


IBM i/AS400 采集器通过 IBM i Access ODBC Driver 远程访问 Db2 for i SQL Services,采集 IBM i 的系统、ASP、Job、Memory Pool、Subsystem、Job Queue 和 Message Queue 指标。

已测试的版本:

  • IBM i 7.4

配置

前置条件

配置 ODBC 环境

当前采集器仅支持在 Linux AMD64 主机上运行。

IBM i/AS400 采集器通过 unixODBC 加载 IBM i Access ODBC Driver。采集器所在 Linux 主机如果已经安装并配置了 unixODBC,可以直接使用,无需重复安装。

首先检查 unixODBC 及其配置文件位置:

odbcinst -j

如果系统找不到 odbcinst,再根据发行版安装 unixODBC:

# Debian/Ubuntu
sudo apt-get update
sudo apt-get install -y unixodbc

# RHEL/Rocky Linux
sudo dnf install -y unixODBC

# SUSE Linux
sudo zypper install unixODBC

IBM i Access Client Solutions 下载适用于采集器所在平台的 ACS Application Package,并按照软件包说明安装 IBM i Access ODBC Driver。请选择 AMD64 软件包,驱动及其动态库的架构必须与 采集器运行环境一致。

安装后,确认 unixODBC 能识别 IBM i Access ODBC Driver:

odbcinst -q -d

默认使用的驱动名称为 IBM i Access ODBC Driver 64-bit。 可以使用以下命令检查该驱动:

odbcinst -q -d -n "IBM i Access ODBC Driver 64-bit"

如果驱动未自动注册,请根据 odbcinst -j 显示的位置编辑 odbcinst.ini。不同安装包的动态库路径可能不同,以下为常见配置:

[IBM i Access ODBC Driver 64-bit]
Description=IBM i Access for Linux 64-bit ODBC Driver
Driver=/opt/ibm/iaccess/lib64/libcwbodbc.so
Setup=/opt/ibm/iaccess/lib64/libcwbodbcs.so
Threading=0
DontDLClose=1
UsageCount=1

检查驱动动态库及采集器的 ODBC 依赖是否可以正常加载:

ldd /opt/ibm/iaccess/lib64/libcwbodbc.so
ldd /usr/local/datakit/externals/ibm_i

采集器配置

进入 DataKit 安装目录下的 conf.d/samples 目录,复制 ibm_i.conf.sample 并命名为 ibm_i.conf。示例如下:

[[inputs.external]]
  daemon = true
  name   = "ibm_i"
  cmd    = "/usr/local/datakit/externals/ibm_i"

  ## Set true to enable election.
  election = true

  args = [
    "--interval", "60s",
    "--host", "<ibm-i-host>",
    "--username", "DKUSER",

    ## Optional: IBM i Access ODBC driver name registered in odbcinst.ini.
    # "--driver", "IBM i Access ODBC Driver 64-bit",

    ## Optional: use a raw ODBC connection string instead of host/username/password/driver.
    # "--dsn", "Driver={IBM i Access ODBC Driver 64-bit};System=<ibm-i-host>;UID=DKUSER;PWD=<password>;",

    ## Optional query and timeout settings.
    # "--query-timeout", "30s",
    # "--job-query-timeout", "240s",
    # "--system-mq-query-timeout", "80s",
    # "--severity-threshold", "50",

    ## Repeat these arguments as needed.
    ## When --query is omitted, all default queries are enabled.
    ## On large systems, start with base queries and enable job detail
    ## queries only when needed.
    # "--query", "disk_usage",
    # "--query", "cpu_usage",
    # "--query", "memory_info",
    # "--query", "subsystem",
    # "--query", "job_queue",

    ## Limit message_queue_info to selected queues to reduce target load.
    # "--message-queue", "QSYSOPR",
    # "--message-queue", "QSYSMSG",
  ]
  envs = [
    "ENV_INPUT_IBM_I_PASSWORD=<password>",
    "LD_LIBRARY_PATH=/opt/ibm/iaccess/lib64:$LD_LIBRARY_PATH",
  ]

  [inputs.external.tags]
    # some_tag = "some_value"
    # more_tag = "some_other_value"

配置好后,重启 DataKit 即可。

目前可以通过 ConfigMap 方式注入采集器配置来开启采集器。

也可以通过 --dsn 传入完整的 ODBC connection string。配置 --dsn 后,--host--username--password--driver 不再参与连接串构造:

args = [
  "--dsn", "DSN=IBMI;UID=DKUSER;PWD=<password>;",
]

为避免密码出现在配置文件或命令行中,建议通过环境变量传递密码:

envs = [
  "ENV_INPUT_IBM_I_PASSWORD=<password>",
  "LD_LIBRARY_PATH=/opt/ibm/iaccess/lib64:$LD_LIBRARY_PATH",
]

参数说明

参数 说明
--dsn 完整 ODBC connection string,配置后优先使用
--driver IBM i Access ODBC Driver 名称,默认 IBM i Access ODBC Driver 64-bit
--host IBM i 主机地址
--username IBM i 采集账号
--password IBM i 采集账号密码,建议使用环境变量 ENV_INPUT_IBM_I_PASSWORD
--interval 指标采集间隔,默认 60s;启用全部查询时建议不低于 60s
--query-timeout 普通查询超时,默认 30s
--job-query-timeout Job 查询超时,默认 240s
--system-mq-query-timeout Message Queue 查询超时,默认 80s
--query 指定启用的查询,可重复配置;未配置时启用全部默认查询
--severity-threshold Message Queue 严重消息阈值,默认 50
--message-queue 限制采集的 Message Queue 名称,可重复配置
--metric-enabled 是否上报指标,默认 true

默认会启用全部查询。Job 明细查询会按 Job 产生指标,在 Job 数量较多的 IBM i 上会产生较多时间线。生产环境可以先只启用基础查询,确认开销后再按需启用 Job 明细。

message_queue_info 默认会查询全部 Message Queue。消息量较大的环境建议通过 --message-queue 限制需要关注的队列,例如 QSYSOPRQSYSMSG

--query 支持以下取值:

disk_usage
cpu_usage
jobq_job_status
active_job_status
job_memory_usage
memory_info
subsystem
job_queue
message_queue_info

指标

ibm_i

Tags & Fields Description
asp_number
(tag)
ASP number.
host
(tag)
IBM i host name or connection address.
job_active_status
(tag)
Active job status.
job_id
(tag)
IBM i job identifier.
job_name
(tag)
IBM i job name.
job_queue_library
(tag)
Job queue library.
job_queue_name
(tag)
Job queue name.
job_queue_status
(tag)
Job queue status.
job_status
(tag)
IBM i job status.
job_user
(tag)
IBM i job user.
memory_pool_name
(tag)
Memory pool name used by a job.
message_queue_library
(tag)
Message queue library.
message_queue_name
(tag)
Message queue name.
partition_id
(tag)
IBM i partition ID.
pool_name
(tag)
Memory pool name.
resource_name
(tag)
Disk resource name. Available on IBM i 7.3 or later.
serial_number
(tag)
Disk serial number.
subsystem_name
(tag)
Subsystem name.
unit_number
(tag)
Disk unit number.
unit_type
(tag)
Disk unit type.
asp_io_requests_per_s IO requests per second. Available on IBM i 7.3 or later.
Type: float | (gauge)
Unit: throughput,reqps
Tagged by: asp_number, resource_name, serial_number, unit_number, unit_type
asp_percent_busy Disk busy percentage. Available on IBM i 7.3 or later.
Type: float | (gauge)
Unit: percent,percent
Tagged by: asp_number, resource_name, serial_number, unit_number, unit_type
asp_percent_used Disk unit used percentage.
Type: float | (gauge)
Unit: percent,percent
Tagged by: asp_number, serial_number, unit_number, unit_type
asp_unit_space_available Available disk unit space.
Type: int | (gauge)
Unit: digital,B
Tagged by: asp_number, serial_number, unit_number, unit_type
asp_unit_storage_capacity Disk unit capacity.
Type: int | (gauge)
Unit: digital,B
Tagged by: asp_number, serial_number, unit_number, unit_type
job_active_duration Active job duration.
Type: float | (gauge)
Unit: time,s
Tagged by: job_active_status, job_id, job_name, job_status, job_user, subsystem_name
job_cpu_usage Job CPU usage.
Type: float | (gauge)
Unit: percent,percent
Tagged by: job_active_status, job_id, job_name, job_status, job_user, subsystem_name
job_cpu_usage_pct Job CPU usage percentage.
Type: float | (gauge)
Unit: percent,percent
Tagged by: job_active_status, job_id, job_name, job_status, job_user, subsystem_name
job_queue_duration Duration spent in job queue.
Type: float | (gauge)
Unit: time,s
Tagged by: job_id, job_name, job_queue_library, job_queue_name, job_queue_status, job_status, job_user, subsystem_name
job_queue_held_size Held job count.
Type: int | (gauge)
Unit: count
Tagged by: job_queue_name, job_queue_status, subsystem_name
job_queue_released_size Released job count.
Type: int | (gauge)
Unit: count
Tagged by: job_queue_name, job_queue_status, subsystem_name
job_queue_scheduled_size Scheduled job count.
Type: int | (gauge)
Unit: count
Tagged by: job_queue_name, job_queue_status, subsystem_name
job_queue_size Total jobs in the job queue.
Type: int | (gauge)
Unit: count
Tagged by: job_queue_name, job_queue_status, subsystem_name
job_status_value Job status marker. Returned job records are set to 1.
Type: int | (gauge)
Unit: count
Tagged by: job_active_status, job_id, job_name, job_queue_library, job_queue_name, job_queue_status, job_status, job_user, subsystem_name
job_temp_storage Temporary storage used by the job.
Type: int | (gauge)
Unit: digital,MB
Tagged by: job_active_status, job_id, job_name, job_user, memory_pool_name, subsystem_name
message_queue_critical_size Message count with severity greater than or equal to the configured threshold.
Type: int | (gauge)
Unit: count
Tagged by: message_queue_library, message_queue_name
message_queue_size Total messages in the message queue.
Type: int | (gauge)
Unit: count
Tagged by: message_queue_library, message_queue_name
pool_defined_size Defined pool size.
Type: float | (gauge)
Unit: digital,MB
Tagged by: pool_name, subsystem_name
pool_reserved_size Reserved pool size.
Type: float | (gauge)
Unit: digital,MB
Tagged by: pool_name, subsystem_name
pool_size Current pool size.
Type: float | (gauge)
Unit: digital,MB
Tagged by: pool_name, subsystem_name
subsystem_active Whether the subsystem is active. Active is 1.
Type: int | (gauge)
Unit: count
Tagged by: subsystem_name
subsystem_active_jobs Current active job count.
Type: int | (gauge)
Unit: count
Tagged by: subsystem_name
system_configured_cpus Configured CPU count.
Type: float | (gauge)
Unit: count
Tagged by: partition_id
system_cpu_usage Average CPU utilization.
Type: float | (gauge)
Unit: percent,percent
Tagged by: partition_id
system_current_cpu_capacity Current CPU capacity.
Type: float | (gauge)
Unit: count
Tagged by: partition_id
system_normalized_cpu_usage Normalized CPU usage.
Type: float | (gauge)
Unit: percent,percent
Tagged by: partition_id
system_shared_cpu_usage Shared CPU usage.
Type: float | (gauge)
Unit: percent,percent
Tagged by: partition_id

collector

Tags & Fields Description
instance
(tag)
Server addr of the instance
job
(tag)
Server name of the instance
up Whether the collector successfully scraped the target during the last collection cycle: 1 means true and 0 means false.
Type: int | (gauge)
Unit: bool

FAQ

如何验证 ODBC?

如果需要先独立验证 ODBC,可在 odbcinst -j 显示的 odbc.ini 中添加测试 DSN:

[IBMI]
Description=IBM i
Driver=IBM i Access ODBC Driver 64-bit
System=10.0.0.10

然后依次执行以下命令:

odbcinst -j
odbcinst -q -d
ldd /opt/ibm/iaccess/lib64/libcwbodbc.so
isql -v IBMI DKUSER '<password>'

确保驱动已注册、动态库依赖完整,并且 isql 可以正常连接 IBM i。

IBM i 侧需要检查什么?

IBM i 需要启动 TCP/IP 和 Database Host Server。采集账号需要具备登录 IBM i 和执行 Db2 for i SQL Services 查询的权限。

为什么没有指标?

请检查以下内容:

  • DataKit 主机是否可以加载 unixODBC 和 IBM i Access ODBC Driver。
  • odbcinst -q -d 是否能列出配置的驱动名称。
  • isql 是否能使用采集账号连接 IBM i。
  • IBM i Database Host Server 是否已启动,网络和防火墙是否允许访问。
  • 采集账号是否有权限访问文档列出的 Db2 for i SQL Services。
  • [DataKit 安装目录]/externals/ibm_i.log 中是否存在连接或查询错误。

文档评价

文档内容是否对您有帮助? ×