Skip to content

Commit

Permalink
Add new arg --no_checks_in_passive_mode (#84)
Browse files Browse the repository at this point in the history
* chore: update requirements.txt

* feat: add new arg --no_checks_in_passive_mode
  • Loading branch information
phsmith authored Mar 5, 2024
1 parent 8fdb629 commit 4429d2a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 21 deletions.
25 changes: 15 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.6.4] - 2024-03-05
### Added
- Issue [#83](https://github.com/phsmith/rundeck_exporter/issues/83), added new `--no_checks_in_passive_mode` argument and `RUNDECK_EXPORTER_NO_CHECKS_IN_PASSIVE_MODE=<False|True>` env var introduced to keep the rundeck_exporter idle while the Rundeck host is in `passive` execution mode.

## [2.6.3] - 2023-11-10
### Added
- Added Helm Chart by @nataliagranato in https://github.com/phsmith/rundeck_exporter/pull/76
Expand Down Expand Up @@ -207,7 +211,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [2.0.0] - 2020-08-12
### Added
- Added param --rundeck.projects.executions.cache and env RUNDECK_PROJECTS_EXECUTIONS_CACHE
- Added argument `--rundeck.projects.executions.cache` and `RUNDECK_PROJECTS_EXECUTIONS_CACHE` env var
- Added counter metrics rundeck_services_[services,controllers,api,web]_total

### Changed
Expand All @@ -216,21 +220,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
- Removed all gauge metrics rundeck_[services,controllers,api,web]...{type="..."}
- Removed metrics rundeck_system_stats_[cpu,memory,uptime_duration]...
- Removed param --rundeck.token. Need RUNDECK_TOKEN env now.
- Removed param --rundeck.projects.executions.limit
- Removed argument `--rundeck.token`. Need `RUNDECK_TOKEN` env now.
- Removed argument `--rundeck.projects.executions.limit`
- Removed rundeck_node label from all metrics

### Fixed
- Fixed json response validation

## [1.2.0] - 2020-08-06
### Added
- Added new params:
* --debug: Enable debug mode
* --rundeck.projects.executions: Get projects executions metrics
* --rundeck.projects.filter: Get executions only from listed projects (delimiter = space)
* --rundeck.projects.executions.limit: Limit project executions metrics query. Default: 20
* --rundeck.cached.requests.ttl: Rundeck cached requests (by now, only for rundeck.projects.executions) expiration time. Default: 120
- Added new argument:
* `--debug`: Enable debug mode
* `--rundeck.projects.executions`: Get projects executions metrics
* `--rundeck.projects.filter`: Get executions only from listed projects (delimiter = space)
* `--rundeck.projects.executions.limit`: Limit project executions metrics query. Default: 20
* `--rundeck.cached.requests.ttl`: Rundeck cached requests (by now, only for rundeck.projects.executions) expiration time. Default: 120
- Added code improvements
- Added cachetools to pip install on Dockerfile
- Added logging module to replace print calls
Expand All @@ -254,7 +258,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial release

[unreleased]: https://github.com/phsmith/rundeck_exporter/compare/v2.6.3...HEAD
[unreleased]: https://github.com/phsmith/rundeck_exporter/compare/v2.6.4...HEAD
[2.6.4]: https://github.com/phsmith/rundeck_exporter/compare/v2.6.3...v2.6.4
[2.6.3]: https://github.com/phsmith/rundeck_exporter/compare/v2.6.2...v2.6.3
[2.6.2]: https://github.com/phsmith/rundeck_exporter/compare/v2.6.1...v2.6.2
[2.6.1]: https://github.com/phsmith/rundeck_exporter/compare/v2.6.0...v2.6.1
Expand Down
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@ More detailed information about the metrics can be found in [Documentations](doc

* A Rundeck token with permissions to make API requests
* The following python modules:
```
pip install prometheus-client requests cachetools
```

```sh
pip install prometheus-client requests cachetools
```

Or:

```sh
pip install -r requirements.txt
```

## API Authentication

Expand Down Expand Up @@ -98,12 +105,12 @@ context:
The rundeck_exporter supports the following paramenters:
```
```text
$ ./rundeck_exporter.py --help

usage: rundeck_exporter.py [-h] [--debug] [-v] [--host RUNDECK_EXPORTER_HOST] [--port RUNDECK_EXPORTER_PORT] [--rundeck.url RUNDECK_URL] [--rundeck.skip_ssl] [--rundeck.api.version RUNDECK_API_VERSION] [--rundeck.username RUNDECK_USERNAME] [--rundeck.projects.executions]
[--rundeck.projects.executions.filter RUNDECK_PROJECT_EXECUTIONS_FILTER] [--rundeck.projects.executions.limit RUNDECK_PROJECTS_EXECUTIONS_LIMIT] [--rundeck.projects.executions.cache]
[--rundeck.projects.filter RUNDECK_PROJECTS_FILTER [RUNDECK_PROJECTS_FILTER ...]] [--rundeck.cached.requests.ttl RUNDECK_CACHED_REQUESTS_TTL] [--rundeck.cpu.stats] [--rundeck.memory.stats]
usage: rundeck_exporter.py [-h] [--debug] [-v] [--host RUNDECK_EXPORTER_HOST] [--port RUNDECK_EXPORTER_PORT] [--no_checks_in_passive_mode] [--rundeck.url RUNDECK_URL] [--rundeck.skip_ssl] [--rundeck.api.version RUNDECK_API_VERSION] [--rundeck.username RUNDECK_USERNAME] [--rundeck.projects.executions]
[--rundeck.projects.executions.filter RUNDECK_PROJECT_EXECUTIONS_FILTER] [--rundeck.projects.executions.limit RUNDECK_PROJECTS_EXECUTIONS_LIMIT] [--rundeck.projects.executions.cache] [--rundeck.projects.filter RUNDECK_PROJECTS_FILTER [RUNDECK_PROJECTS_FILTER ...]] [--rundeck.cached.requests.ttl RUNDECK_CACHED_REQUESTS_TTL]
[--rundeck.cpu.stats] [--rundeck.memory.stats]

Rundeck Metrics Exporter

Expand All @@ -119,6 +126,8 @@ options:
Host binding address. Default: 127.0.0.1.
--port RUNDECK_EXPORTER_PORT
Host binding port. Default: 9620.
--no_checks_in_passive_mode
The rundeck_exporter will not perform any checks while the Rundeck host is in passive execution mode.
--rundeck.url RUNDECK_URL
Rundeck Base URL [ REQUIRED ].
--rundeck.skip_ssl Rundeck Skip SSL Cert Validate.
Expand All @@ -129,7 +138,7 @@ options:
--rundeck.projects.executions
Get projects executions metrics.
--rundeck.projects.executions.filter RUNDECK_PROJECT_EXECUTIONS_FILTER
Project executions filter by a period of time. Can be in: [s]: seconds, [n]: minutes, [h]: hour, [d]: day, [w]: week, [m]: month, [y]: year. Default: 5n.
Get the latest project executions filtered by time period. Can be in: [s]: seconds, [n]: minutes, [h]: hour, [d]: day, [w]: week, [m]: month, [y]: year. Default: 5n.
--rundeck.projects.executions.limit RUNDECK_PROJECTS_EXECUTIONS_LIMIT
Project executions max results per query. Default: 20.
--rundeck.projects.executions.cache
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cachetools==4.2.2
prometheus-client==0.11.0
cachetools==5.3.3
prometheus-client==0.20.0
requests==2.31.0
15 changes: 14 additions & 1 deletion rundeck_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
__author__ = 'Phillipe Smith'
__author_email__ = 'phsmithcc@gmail.com'
__app__ = 'rundeck_exporter'
__version__ = '2.6.3'
__version__ = '2.6.4'

# Disable InsecureRequestWarning
requests.urllib3.disable_warnings()
Expand Down Expand Up @@ -87,6 +87,12 @@ class RundeckMetricsCollector(object):
type=int,
default=getenv('RUNDECK_EXPORTER_PORT', default_port)
)
args_parser.add_argument('--no_checks_in_passive_mode',
dest='no_checks_in_passive_mode',
help='The rundeck_exporter will not perform any checks while the Rundeck host is in passive execution mode.',
action='store_true',
default=getenv('RUNDECK_EXPORTER_NO_CHECKS_IN_PASSIVE_MODE', False)
)
args_parser.add_argument('--rundeck.url',
dest='rundeck_url',
help='Rundeck Base URL [ REQUIRED ].',
Expand Down Expand Up @@ -406,12 +412,19 @@ def collect(self):
"""
system_info = self.request_data_from('/system/info')
api_version = int(system_info['system']['rundeck']['apiversion'])
execution_mode = system_info['system'].get('executions', {}).get('executionMode')
rundeck_system_info = InfoMetricFamily(
name='rundeck_system',
documentation='Rundeck system info',
labels=self.default_labels
)
rundeck_system_info.add_metric(self.default_labels_values, {x: str(y) for x, y in system_info['system']['rundeck'].items()})

logging.debug(f'Rundeck execution mode: {execution_mode}.')

if self.args.no_checks_in_passive_mode and execution_mode == 'passive':
return

yield rundeck_system_info

"""
Expand Down

0 comments on commit 4429d2a

Please sign in to comment.