opsview api的python客户端
pyopsview的Python项目详细描述
#pyopsview:snake:
**用于opsview的python rest api客户端!**
!【Opsview logo】(https://raw.gitubububuusercontent.com/jpgxs/pyopsview/master/opsview.png)
安装
` `` bash
` ` bash
` ` ` ` ` ` bash
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` br/>使用“apt”
apt update&;apt install python使用“apt get”请求python 6
apt get update&;apt-get-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-python-python-install-python-6
`
pip安装pyopsview
git-clone git-clone https://github.com/jpgxs/pyopsview
cd pyopsview
python setup.py install
````
``python
``` python
br/>从pyopsview.exceptions导入opsviewclientexception
客户端并为特定OpsView版本加载适当的API架构
client=OpsView客户端(username='admin',password='initial',
endpoint='https://opsview.example.com')
必须对每个操作执行
auth_token=client.token
client=opsviewclient(username='admin',token=auth_token,
endpoint='https://opsview.example.com')
这将返回一个生成器。
all_hosts=client.config.hosts.list()
所有_hosts中的主机:
打印(主机['检查间隔')
主机
update\u host=all\u hosts[-1]
update\u host['address']='127.128.129.130'
update\u host=client.config.hosts.update(update\u host['id'],**update\u host)
;找到主opsview服务器
opsview
opsview.opt view\u master client.config.hosts.find\u one(name='opsview')
如果opsview主节点没有主节点,如果opsview主节点没有主节点,则查找一个主节点(name='opsview.opsvie找到opsview主服务器!')
获取OpsView主控上所有服务检查的列表
主控服务检查=[]
主控服务检查+=OpsView主控[服务检查]
OpsView主控[主机模板]中模板的列表:
模板详细信息=客户端。主机模板。查找一个(模板[名称])
主控服务检查+=模板详细信息[“服务检查”]
````
\todo
*为其他版本的opsview添加架构
*为以下版本添加api操作:
*停机
*服务/主机状态
*实时对象信息(运行时)
*确认
*调度复查
*图形数据
*事件/历史数据
*注释
*SNMP查询
叉开!
2.创建功能分支:`git checkout-b my new feature`
3.提交更改:`git commit-am'添加一些功能'`
4.推到分支:`git push origin my new feature`
5.提交拉取请求
**用于opsview的python rest api客户端!**
!【Opsview logo】(https://raw.gitubububuusercontent.com/jpgxs/pyopsview/master/opsview.png)
安装
` `` bash
` ` bash
` ` ` ` ` ` bash
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` br/>使用“apt”
apt update&;apt install python使用“apt get”请求python 6
apt get update&;apt-get-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-install-python-python-python-install-python-6
`
pip安装pyopsview
git-clone git-clone https://github.com/jpgxs/pyopsview
cd pyopsview
python setup.py install
````
``python
``` python
br/>从pyopsview.exceptions导入opsviewclientexception
客户端并为特定OpsView版本加载适当的API架构
client=OpsView客户端(username='admin',password='initial',
endpoint='https://opsview.example.com')
必须对每个操作执行
auth_token=client.token
client=opsviewclient(username='admin',token=auth_token,
endpoint='https://opsview.example.com')
这将返回一个生成器。
all_hosts=client.config.hosts.list()
所有_hosts中的主机:
打印(主机['检查间隔')
主机
update\u host=all\u hosts[-1]
update\u host['address']='127.128.129.130'
update\u host=client.config.hosts.update(update\u host['id'],**update\u host)
;找到主opsview服务器
opsview
opsview.opt view\u master client.config.hosts.find\u one(name='opsview')
如果opsview主节点没有主节点,如果opsview主节点没有主节点,则查找一个主节点(name='opsview.opsvie找到opsview主服务器!')
获取OpsView主控上所有服务检查的列表
主控服务检查=[]
主控服务检查+=OpsView主控[服务检查]
OpsView主控[主机模板]中模板的列表:
模板详细信息=客户端。主机模板。查找一个(模板[名称])
主控服务检查+=模板详细信息[“服务检查”]
````
\todo
*为其他版本的opsview添加架构
*为以下版本添加api操作:
*停机
*服务/主机状态
*实时对象信息(运行时)
*确认
*调度复查
*图形数据
*事件/历史数据
*注释
*SNMP查询
叉开!
2.创建功能分支:`git checkout-b my new feature`
3.提交更改:`git commit-am'添加一些功能'`
4.推到分支:`git push origin my new feature`
5.提交拉取请求