#api-client #cli-client #icinga #problem #status #ticket #restart

bin+lib icingacli

用于与 icinga API 交互的 CLI 客户端

1 个不稳定版本

使用旧的 Rust 2015

0.1.2 2017年6月30日

#5#icinga

Apache-2.0

34KB
738

icingacli

用于与 icinga API 交互的 CLI 客户端

安装

OS X & Linux

cargo install icingacli

用法

默认情况下,它会在 $HOME/.icingacli 中查找,但您可以使用 -c 传递配置路径。


server = "localhost"
port = 5665
user = "root"
password = "toor"

运行 icingacli --help 以获取完整命令和选项列表。

william@server-1 $ ./target/debug/icingacli --help
icingacli 0.1.1
William Fleming <wfleming.fleming@deltadna.com>
icingai cli tool

USAGE:
    icingacli [FLAGS] [OPTIONS] [SUBCOMMAND]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
    -v               Sets the level of verbosity

OPTIONS:
    -c, --config <FILE>    Sets a custom config file

SUBCOMMANDS:
    acknowledge-problem    ack knowledge problem
    add-comment            Adds a comment from an author to services or hosts
    generate-ticket        generate a ticket for CSR signing
    group                  list hosts in group
    help                   Prints this message or the help of the given
                           subcommand(s)
    host                   list host info
    problems               print information on icinga problems
    remove-comment         removes a comment using the name attribute
    reschedule-check       reschedule a check for hosts and services
    restart                restart the icinga process
    shutdown               shutdown icinga process
    status                 prints status api page
    stream                 stream events from API

示例

列出所有当前问题


william@server-1 $ icingacli problems | jq

{
  "results": [
    {
      "attrs": {
        "name": "disks",
        "state": 2
      },
      "joins": {},
      "meta": {},
      "name": "server-3!disks",
      "type": "Service"
    }
  ]
}

承认服务问题

william@server-1 $ icingacli acknowledge-problem -a "william" -c "its all good" -h "server-3" -s "disks"
{
  "results": [
    {
      "code": 200.0,
      "status": "Successfully acknowledged problem for object 'server-3!disks'."
    }
  ]
}

远程重启 icinga

william@server-1 $ icingacli restart | jq

{
  "results": [
    {
      "code": 200,
      "status": "Restarting Icinga 2."
    }
  ]
}

为新的代理生成 PKI 票据

william@server-1 $ icingacli generate-ticket -c "server-3" | jq
{
  "results": [
    {
      "code": 200,
      "status": "Generated PKI ticket '6ef860c52aeafb282c2939098d503241b30438ba' for common name 'server-3'.",
      "ticket": "6ef860c52aeafb282c2939098d503241b30438ba"
    }
  ]
}

开发设置

william@server-1 $ git clone https://github.com/william20111/icingacli.git
william@server-1 $ cd icingacli
william@server-1 $ cargo build

发布历史

  • 0.1.2
    • 添加了安排停机时间和取消停机时间功能
  • 0.1.1
    • 添加了注释移除和添加注释命令
  • 0.1.0
    • 第一个版本为 WIP。

元数据

贡献

  1. 分叉它 (https://github.com/deltaDNA/icingacli)
  2. 创建您的功能分支 (git checkout -b feature/fooBar)
  3. 提交您的更改 (git commit -am 'Add some fooBar')
  4. 推送到分支 (git push origin feature/fooBar)
  5. 创建新的拉取请求

依赖关系

~6–16MB
~221K SLoC