bheisig / idoitcli
通过命令行界面访问您的CMDB
Requires
- php: >=7.1.0
- ext-phar: *
- ext-zlib: *
- bheisig/cli: @dev
- bheisig/idoitapi: @dev
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^0.5.0
- j13k/yaml-lint: ^1.1
- jakub-onderka/php-parallel-lint: ^1.0
- macfja/phar-builder: ^0.2.6
- phpcompatibility/php-compatibility: *
- phploc/phploc: ^4.0
- phpmd/phpmd: @stable
- phpstan/phpstan: ^0.11.6
- phpunit/phpunit: ^7
- povils/phpmnd: ^2
- roave/security-advisories: dev-master
- sclable/xml-lint: ^0.2.4
- sebastian/phpcpd: ^4.1.0
- seld/jsonlint: ^1.7
- sensiolabs/security-checker: ^5
- sllh/composer-lint: ^1.0
- squizlabs/php_codesniffer: *
Suggests
- ext-xdebug: Needed for code coverage with phpunit
README
通过命令行界面访问您的CMDB
关于
i-doit 是一款用于IT文档和CMDB(配置管理数据库)的软件应用程序。此应用程序非常有用,可以收集您所处理的IT基础设施的所有知识。i-doit 是一个Web应用程序,并且拥有一个详尽的API,这对于自动化您的基础设施非常有用。
此应用程序提供了一个简单但强大的命令行界面,以访问存储在 i-doit 中的 CMDB 数据。
特性
- 读取关于对象、其类型以及其属性的信息
- 在被称为CMDB的乱糟糟的东西中找到您需要的东西
- 您需要特定子网中的免费IP地址吗?此应用程序为您建议一个。
- 测试您的系统:自动生成数千个对象
要求
在开始使用此应用程序之前,您的系统必须满足以下要求
- 当然,i-doit pro/open,版本 1.13 或更高
- i-doit API 扩展,版本 1.10.3 或更高
- 任何 POSIX 操作系统(GNU/Linux、*BSD、MacOS)或 Windows
- PHP >= 7.1(推荐使用 7.3)
- PHP 扩展
calendar
、cli
、cURL
、json
、phar
和zlib
- PHP 扩展
pcntl
是可选的,但强烈推荐(仅限非 Windows 系统)
安装和更新
您有下载和安装此应用程序的两个好方法
- 下载任何稳定版本(推荐)
- 使用 PHIVE
下载版本
从发布站点 下载最新的稳定版本的二进制文件 idoitcli
。然后将其安装到系统全局
curl -OL https://github.com/bheisig/i-doit-cli/releases/download/0.7/idoitcli
chmod 755 idoitcli
sudo mv idoitcli /usr/local/bin/
要保持最新,只需重复以上步骤。
使用 PHIVE
使用 PHIVE,您可以在您的系统上下载和安装 PHAR 文件。此外,它还将验证 SHA1 和 GPG 签名,这强烈推荐。如果您已经安装了 PHIVE,您可以获取此应用程序的最新版本
sudo phive install --global bheisig/i-doit-cli
这将将在 /usr/bin/idoitcli
中安装一个可执行二进制文件。
如果可用新版本,您可以执行更新
sudo phive update --global
用法
只需运行应用程序即可显示基本用法
idoitcli
第一步
此应用程序会本地缓存很多内容,以提供最佳用户体验。运行 init
命令
idoitcli init
将询问一些简单的问题,以确定如何访问您的 i-doit 安装。下一步是创建缓存文件
idoitcli cache
之后,您的家目录下的 ~/.idoitcli/
将创建一些文件:每个 i-doit 安装在 data/
下都有自己的缓存文件。您定义的配置文件称为 config.json
。
您可以运行以下命令来检查您的当前状态
idoitcli status
这将为您提供有关您的 i-doit 安装、您的设置和您的用户的一些基本信息。
访问您的 CMDB 数据
这可能是最好的部分:读取有关对象、其类型以及其属性的信息。
列出所有对象类型
idoitcli read
idoitcli read /
列出服务器对象
idoitcli read server/
idoitcli read server/host.example.net
idoitcli read server/*.example.net
idoitcli read server/host.*.net
idoitcli read server/*.*.net
idoitcli read server/host*
idoitcli read server/*
显示关于“host.example.net”服务器的常见信息
idoitcli read server/host.example.net
显示关于对象标识符“42”的常见信息
idoitcli read 42
显示关于一个或多个对象(通过其标题)的常见信息
idoitcli read *.example.net
idoitcli read host.*.net
idoitcli read *.*.net
idoitcli read host*
列出分配的类别
idoitcli read server/host.example.net/
显示关于此服务器的“型号”类别的值
idoitcli read server/host.example.net/model
显示关于一个或多个服务器的“型号”类别的值
idoitcli read server/*.example.net/model
idoitcli read server/host.*.net/model
idoitcli read server/*.*.net/model
idoitcli read server/host*/model
idoitcli read server/*/model
或者只显示模型名称
idoitcli read server/host.example.net/model/model
列出“模型”类别的可用属性
idoitcli read server/host.example.net/model/
对于特定对象,您可以将对象类型留空,例如
idoitcli read host.example.net/model
注意:这些示例与唯一名称配合得很好。这就是为什么通常会给对象赋予不与对象类型和类别冲突的唯一标题。
显示有关对象的所有信息
idoitcli show myserver
idoitcli show "My Server"
idoitcli show 42
查找您的数据
在被称为CMDB的乱糟糟的东西中找到您需要的东西
idoitcli search myserver
idoitcli search "My Server"
显示下一个可用的IPv4地址
为特定子网获取下一个可用的IPv4地址
idoitcli nextip SUBNET
SUBNET
可以是对象标题或其标识符。
自动生成对象
出于测试目的,对i-doit安装进行压力测试,并让应用程序创建数千个对象、属性以及对象之间的关系
idoitcli -c FILE random
一些示例位于docs/
目录下。
更新缓存
如果您的CMDB配置已更改,您需要运行cache
命令重新创建缓存文件
idoitcli cache
游乐场
执行自定义API请求 - 将请求作为参数传递
idoitcli call '{"version": "2.0","method": "idoit.version","params": {"apikey": "c1ia5q","language": "en"},"id": 1}'
管道请求
echo '{"version": "2.0","method": "idoit.version","params": {"apikey": "c1ia5q","language": "en"},"id": 1}' | idoitcli call
从文件中读取请求
cat request.txt | idoitcli call
从标准输入读取请求(输入两行以执行)
idoitcli call
配置
有一些方法可以设置配置设置
- 系统范围的设置存储在
/etc/idoitcli/config.json
下。 - 用户定义的设置存储在
~/.idoitcli/config.json
下。 - 使用选项
-c
或--config
传递运行时设置。
请注意,顺序很重要。每个文件都是可选的。任何组合都是可能的。此外,要包含更多配置文件,您可以多次传递选项-c
和--config
。
配置文件是JSON格式的。
贡献
请将任何问题报告给我们的问题跟踪器。合并请求和操作系统分发包非常受欢迎。有关更多信息,请参阅文件CONTRIBUTING.md
。
版权 & 许可
版权(C)2016-19 Benjamin Heisig
根据GNU Affero GPL版本3或更高(AGPLv3+)许可。这是免费软件:您可以自由更改和重新分发它。在法律允许的范围内,不提供任何保证。
名字和性别的列表:版权(C)2007-2008 Jörg Michael,根据GNU自由文档许可证许可
姓氏列表:版权(C)Heiko Behrens,根据GNU Lesser General Public License许可