ipmi

package
v0.0.0-...-5655933 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 18 Imported by: 0

README

IPMI 插件

telegraf fork的ipmi_sensor ,略作改动。 采集硬件温度、风扇转速、电压、功率等信息。

  • 本插件依赖ipmitool
  • 采集的是ipmitool sdr的输出

Get bare metal metrics using the command line utility ipmitool.

If no servers are specified, the plugin will query the local machine sensor stats via the following command:

ipmitool sdr

or with the version 2 schema:

ipmitool sdr elist

When one or more servers are specified, the plugin will use the following command to collect remote host sensor stats:

ipmitool -I lan -H SERVER -U USERID -P PASSW0RD sdr

Any of the following parameters will be added to the aformentioned query if they're configured:

-y hex_key -L privilege

Metrics

Version 1 schema:

  • ipmi_xxxx:
    • tags:
      • unit
      • host
      • server (only when retrieving stats from remote servers)
      • status_code
      • description
    • fields:
      • xxxx

Version 2 schema:

  • ipmi_xxxx:
    • tags:
      • entity_id (can help uniquify duplicate names)
      • status_code (two letter code from IPMI documentation)
      • status_desc (extended status description field)
      • unit (only on analog values)
      • host
      • server (only when retrieving stats from remote)
      • description
    • fields:
      • xxxx
Permissions

本地采集,需要免密sudo权限

KERNEL=="ipmi*", MODE="660", GROUP="categraf采集所使用的用户组"

Alternatively, it is possible to use sudo. You will need the following in your categraf config:

[[instances]]
  use_sudo = true

You will also need to update your sudoers file:

$ visudo
# Add the following line:
Cmnd_Alias IPMITOOL = /usr/bin/ipmitool *
UserOfCategraf  ALL=(root) NOPASSWD: IPMITOOL
Defaults!IPMITOOL !logfile, !syslog, !pam_session

Example Output

Version 1 Schema

When retrieving stats from a remote server:

ipmi_cpu1_temp agent_hostname=1.2.3.4 description=40_degrees_c entity_id=3.1 server=192.168.10.173 status_code=ok unit=degrees_c 40
ipmi_cpu2_temp agent_hostname=1.2.3.4 description=42_degrees_c entity_id=3.2 server=192.168.10.173 status_code=ok unit=degrees_c 42
ipmi_pch_temp agent_hostname=1.2.3.4 description=66_degrees_c entity_id=7.1 server=192.168.10.173 status_code=ok unit=degrees_c 66
ipmi_fan3 agent_hostname=1.2.3.4 description=500_rpm entity_id=29.3 server=192.168.10.173 status_code=lnc unit=rpm 500
ipmi_fan4 agent_hostname=1.2.3.4 description=500_rpm entity_id=29.4 server=192.168.10.173 status_code=lnc unit=rpm 500
ipmi_fan5 agent_hostname=1.2.3.4 description=no_reading entity_id=29.5 server=192.168.10.173 status_code=ns status_desc=no_reading 0

When retrieving stats from the local machine (no server specified):

ipmi_cpu1_temp agent_hostname=1.2.3.4 description=40_degrees_c status_code=ok unit=degrees_c 40
ipmi_cpu2_temp agent_hostname=1.2.3.4 description=43_degrees_c status_code=ok unit=degrees_c 43
ipmi_pch_temp agent_hostname=1.2.3.4 description=66_degrees_c status_code=ok unit=degrees_c 66
ipmi_fan3 agent_hostname=1.2.3.4 description=500_rpm status_code=nc unit=rpm 500
ipmi_fan4 agent_hostname=1.2.3.4 description=500_rpm status_code=nc unit=rpm 500
ipmi_fan5 agent_hostname=1.2.3.4 description=no_reading status_code=ns 0
Version 2 Schema
ipmi_cpu1_temp agent_hostname=1.2.3.4 description=40_degrees_c entity_id=3.1 server=192.168.10.173 status_code=ok unit=degrees_c 40
ipmi_cpu2_temp agent_hostname=1.2.3.4 description=42_degrees_c entity_id=3.2 server=192.168.10.173 status_code=ok unit=degrees_c 42
ipmi_pch_temp agent_hostname=1.2.3.4 description=66_degrees_c entity_id=7.1 server=192.168.10.173 status_code=ok unit=degrees_c 66
ipmi_fan5 agent_hostname=1.2.3.4 description=no_reading entity_id=29.5 server=192.168.10.173 status_code=ns status_desc=no_reading 0
ipmi_fan6 agent_hostname=1.2.3.4 description=500_rpm entity_id=29.6 server=192.168.10.173 status_code=lnc unit=rpm 500
ipmi_fana agent_hostname=1.2.3.4 description=no_reading entity_id=29.7 server=192.168.10.173 status_code=ns status_desc=no_reading 0

When retrieving stats from the local machine (no server specified):

ipmi_cpu1_temp agent_hostname=1.2.3.4 description=39_degrees_c entity_id=3.1 status_code=ok unit=degrees_c 39
ipmi_cpu2_temp agent_hostname=1.2.3.4 description=42_degrees_c entity_id=3.2 status_code=ok unit=degrees_c 42
ipmi_pch_temp agent_hostname=1.2.3.4 description=66_degrees_c entity_id=7.1 status_code=ok unit=degrees_c 66
ipmi_fan5 agent_hostname=1.2.3.4 description=no_reading entity_id=29.5 status_code=ns status_desc=no_reading 0
ipmi_fan6 agent_hostname=1.2.3.4 description=500_rpm entity_id=29.6 status_code=lnc unit=rpm 500
ipmi_fana agent_hostname=1.2.3.4 description=no_reading entity_id=29.7 status_code=ns status_desc=no_reading 0

示例配置

categraf 采集所在的机器需要有ipmitool 命令,如果没有,需要安装

  • 本地采集
[[instances]]
## optionally specify the path to the ipmitool executable
# path = "/usr/bin/ipmitool"
##
## Setting 'use_sudo' to true will make use of sudo to run ipmitool.
## Sudo must be configured to allow the categraf user to run ipmitool
## without a password.
## 本地采集,需要免密sudo权限
    use_sudo = true
##
## optionally force session privilege level. Can be CALLBACK, USER, OPERATOR, ADMINISTRATOR
# privilege = "ADMINISTRATOR"
##
## optionally specify one or more servers via a url matching
##  [username[:password]@][protocol[(address)]]
##  e.g.
##    root:passwd@lan(127.0.0.1)
##
## if no servers are specified, local machine sensor stats will be queried
##

## Recommended: use metric 'interval' that is a multiple of 'timeout' to avoid
## gaps or overlap in pulled data
interval = "30s"

## Timeout for the ipmitool command to complete. Default is 20 seconds.
timeout = "20s"

## Schema Version: (Optional, defaults to version 1)
metric_version = 2

## Optionally provide the hex key for the IMPI connection.
# hex_key = ""

## If ipmitool should use a cache
## for me ipmitool runs about 2 to 10 times faster with cache enabled on HP G10 servers (when using ubuntu20.04)
## the cache file may not work well for you if some sensors come up late
# use_cache = false

## Path to the ipmitools cache file (defaults to OS temp dir)
## The provided path must exist and must be writable
# cache_path = ""
  • 远程采集
[[instances]]
  ## optionally specify the path to the ipmitool executable
  # path = "/usr/bin/ipmitool"
  ##
  ## Setting 'use_sudo' to true will make use of sudo to run ipmitool.
  ## Sudo must be configured to allow the categraf user to run ipmitool
  ## without a password.
  #  use_sudo = true
  ##
  ## optionally force session privilege level. Can be CALLBACK, USER, OPERATOR, ADMINISTRATOR
  # privilege = "ADMINISTRATOR"
  ##
  ## optionally specify one or more servers via a url matching
  ##  [username[:password]@][protocol[(address)]]
  ##  e.g.
  ##    root:passwd@lan(127.0.0.1)
  ##
  ## if no servers are specified, local machine sensor stats will be queried
  ##
  ## 替换远程服务器的ip地址 用户名 密码
    servers = ["root:password@lan(192.168.10.173)"]

  ## Recommended: use metric 'interval' that is a multiple of 'timeout' to avoid
  ## gaps or overlap in pulled data
  interval = "30s"

  ## Timeout for the ipmitool command to complete. Default is 20 seconds.
  timeout = "20s"

  ## Schema Version: (Optional, defaults to version 1)
  metric_version = 1

  ## Optionally provide the hex key for the IMPI connection.
  # hex_key = ""

  ## If ipmitool should use a cache
  ## for me ipmitool runs about 2 to 10 times faster with cache enabled on HP G10 servers (when using ubuntu20.04)
  ## the cache file may not work well for you if some sensors come up late
  # use_cache = false

  ## Path to the ipmitools cache file (defaults to OS temp dir)
  ## The provided path must exist and must be writable
  # cache_path = ""

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	Hostname  string
	Username  string
	Password  string
	Port      int
	Interface string
	Privilege string
	HexKey    string
}

Connection properties for a Client

func NewConnection

func NewConnection(server, privilege, hexKey string) *Connection

func (*Connection) LocalIP

func (c *Connection) LocalIP() string

LocalIP returns the local (client) IP address of the Connection

func (*Connection) RemoteIP

func (c *Connection) RemoteIP() string

RemoteIP returns the remote (bmc) IP address of the Connection

type Instance

type Instance struct {
	config.InstanceConfig

	Path          string          `toml:"path"`
	Privilege     string          `toml:"privilege"`
	HexKey        string          `toml:"hex_key"`
	Servers       []string        `toml:"servers"`
	Timeout       config.Duration `toml:"timeout"`
	MetricVersion int             `toml:"metric_version" default:"1"`
	UseSudo       bool            `toml:"use_sudo"`
	UseCache      bool            `toml:"use_cache"`
	CachePath     string          `toml:"cache_path"`
}

Instance stores the configuration values for the ipmi_sensor input plugin

func (*Instance) Drop

func (m *Instance) Drop()

func (*Instance) Gather

func (m *Instance) Gather(slist *types.SampleList)

Gather is the main execution function for the plugin

func (*Instance) Init

func (m *Instance) Init() error

type Ipmi

type Ipmi struct {
	config.PluginConfig
	Instances []*Instance `toml:"instances"`
}

func (*Ipmi) Clone

func (i *Ipmi) Clone() inputs.Input

func (*Ipmi) Drop

func (c *Ipmi) Drop()

func (*Ipmi) GetInstances

func (c *Ipmi) GetInstances() []inputs.Instance

func (*Ipmi) Name

func (c *Ipmi) Name() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL