https://github.com/cscfi/pyops
Python wrapper for the Opsview REST API
https://github.com/cscfi/pyops
Last synced: 9 months ago
JSON representation
Python wrapper for the Opsview REST API
- Host: GitHub
- URL: https://github.com/cscfi/pyops
- Owner: CSCfi
- License: mit
- Created: 2016-03-24T06:42:33.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-07-04T10:37:12.000Z (almost 3 years ago)
- Last Synced: 2025-04-14T07:34:55.207Z (about 1 year ago)
- Language: Python
- Size: 30.3 KB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyops - Python bindings for the Opsview API
## Installation
```sh
pip install git+ssh://git@github.com/CSCfi/pyops.git
```
## Usage
See command help with `pyops-downtime --help`.
PyOPS expects to find the following variables:
- `prod_ops_base` -- The REST API endpoint of your OpsView-instance
- `prod_ops_user` -- username to be used to login to opsview
- `prod_ops_pass` -- password for the user
Can be setup with following:
```sh
export prod_ops_base="https:///opsview/rest/"
export prod_ops_user="$USER"
read -s prod_ops_pass && export prod_ops_pass # Read OpsView password from stdin
```
Optional arguments:
```none
-e ENDTIME, --endtime ENDTIME
Downtime end time in an opsview format (e.g. +10m, +2d or '2018-08-10 15:00').
-d, --delete Delete downtimes instead of adding them.
-c COMMENT, --comment COMMENT
Comment for the downtime
-s STARTTIME, --starttime STARTTIME
Start time in an opsview format ('2018-08-10 13:00'). Defaults to 'now'
-g, --group Interpret the host list as a list of hostgroup names,
and apply the downtime to all the hosts in the groups.
```
### Setting/Deleting a downtime for node(s)
```sh
# Individual nodes
pyops-downtime -e +1d -c "Server maintenance" testserver1 testserver2
## Delete
pyops-downtime -d testserver1 testserver2
# A named group of nodes
pyops-downtime -e +2h -c "Server maintenance" -g "My Monitoring Group"
pyops-downtime -d -g "My Monitoring Group"
```
### Other Examples
Example scripts for inspiration can be found from `./examples/`.
> Copy and edit as needed