https://github.com/retailmenotsandbox/flapjack-syrup
Create or manipulate objects in your Flapjack environment
https://github.com/retailmenotsandbox/flapjack-syrup
Last synced: about 1 year ago
JSON representation
Create or manipulate objects in your Flapjack environment
- Host: GitHub
- URL: https://github.com/retailmenotsandbox/flapjack-syrup
- Owner: RetailMeNotSandbox
- License: other
- Created: 2014-12-19T16:41:27.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-19T19:08:31.000Z (over 11 years ago)
- Last Synced: 2025-04-10T20:55:10.802Z (about 1 year ago)
- Language: Ruby
- Homepage:
- Size: 220 KB
- Stars: 6
- Watchers: 7
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# flapjack-syrup
Syrup is a command-line utility for creating and modifying resources in a Flapjack environment.
## Installation
To install directly from source, checkout the repository, navigate to the directory, and then install:
$ bundle install
To build and install a gem instead:
$ gem build flapjack-syrup.gemspec
$ gem install flapjack-syrup-.gem
## Dependencies
* ruby 1.9.3
* flapjack-diner 1.0
* methadone 1.7
* trollop 2.0
## Usage
Syrup is a command-based app, similar to git, and is called with the following general form:
$ syrup --GLOBALS RESOURCE ACTION --OPTIONS
Global arguments:
--host, -h : Host to connect to (default: localhost)
--port, -p : Port to connect to (default: 3081)
--log, -l : Flapjack API log (default: flapjack_diner.log)
--pretty, -r: Pretty-print JSON output
--version, -v: Print version and exit
--help, -e: Show this message
Available commands are listed below.
### contact
* [contact create](#contact-create)
* [contact get](#contact-get)
* [contact update](#contact-update)
* [contact delete](#contact-delete)
### medium
* [medium create](#medium-create)
* [medium get](#medium-get)
* [medium update](#medium-update)
* [medium delete](#medium-delete)
### pagerduty
* [pagerduty create](#pagerduty-create)
* [pagerduty get](#pagerduty-get)
* [pagerduty update](#pagerduty-update)
* [pagerduty delete](#pagerduty-delete)
### rule
* [rule create](#rule-create)
* [rule get](#rule-get)
* [rule update](#rule-update)
* [rule delete](#rule-delete)
### entity
* [entity create-ALL](#entity-create-ALL)
* [entity get](#entity-get)
* [entity update](#entity-update)
* [entity status](#entity-create)
* [entity test](#entity-delete)
### check
* [check update](#check-update)
* [check status](#check-status)
* [check test](#check-test)
----
### contact create
Create a new contact.
By default, this will create a new e-mail medium attached to the contact.
NOTE: Flapjack creates and maintains a 'default' notification rule for all contacts. You can modify the 'blackhole' attributes on this rule, but any other changes will cause a new blank rule to be created.
Example:
syrup --GLOBALS contact create --first-name FIRST --last-name LAST --email EMAIL
Available options:
--id, -i : Unique identifier (generated if omitted)
--first-name, -f : First name (required)
--last-name, -l : Last name (required)
--email, -e : Email address (required)
--interval, -n : Notification interval for email (default: 7200)
--rollup-threshold, -r : Rollup threshold for email (default: 0)
--timezone, -t : Time zone
--tags, -a : Tags (comma-separated)
--no-media, -o: Do not automatically create the email medium
--help, -h: Show this message
### contact get
Get JSON contact data.
Specify IDs as comma-separated values, or no IDs to get all contacts.
Example:
syrup --GLOBALS contact get [--ids FIRST,SECOND,THIRD]
Available options:
--ids, -i : Contact identifiers (comma-separated, or get all if omitted)
--help, -h: Show this message
### contact update
Modify existing contacts.
Specify IDs as comma-separated values, or no IDs to update all contacts.
Example:
syrup --GLOBALS contact update [--ids FIRST,SECOND] [--first_name FIRST] [--add_entities ID1,ID2,ID3]
Options:
--ids, -i : Contact identifiers (comma-separated)
--first-name, -f : First name
--last-name, -l : Last name
--email, -e : Email address (of the CONTACT, not the notification medium)
--timezone, -t : Time zone
--tags, -a : Replace all tags on contact (comma-separated)
--add-entities, -d : Link to entities (comma-separated)
--remove-entities, -r : Unlink from entities (comma-separated)
--add-rules, -u : Apply notification rules (comma-separated)
--remove-rules, -m : Remove notification rules (comma-separated)
--help, -h: Show this message
### contact delete
Delete contacts.
Specify IDs as comma-separated values.
Example:
syrup --GLOBALS contact delete --ids FIRST,SECOND,THIRD
Options:
--ids, -i : Contact identifiers (comma-separated)
--help, -h: Show this message
### medium create
Create a new notification medium for a contact.
Supported media types are `email`, `jabber`, and `sms`. PagerDuty is handled separately - see `pagerduty create` below.
Example:
syrup --GLOBALS medium create --id CONTACT --type TYPE --address ADDRESS
Options:
--id, -i : Parent contact ID (required)
--type, -t : Medium type (required)
--address, -a : Medium address (required)
--interval, -n : Notification interval (default: 7200)
--rollup-threshold, -r : Rollup threshold (default: 0)
--help, -h: Show this message
### medium get
Get JSON medium data.
Specify IDs as comma-separated values, or no IDs to get all media.
Example:
syrup --GLOBALS medium get [--ids FIRST,SECOND,THIRD]
Options:
--ids, -i : Media Identifiers (comma-separated, form "_")
--help, -h: Show this message
### medium update
Modify existing media.
Specify IDs as comma-separated values, or no IDs to update all media.
Example:
syrup --GLOBALS medium update [--ids FIRST,SECOND] [--address ADDRESS] [--interval INTERVAL]
Options:
--ids, -i : Media identifiers (comma-separated, form "_")
--address, -a : New medium address
--interval, -n : New medium interval
--rollup-threshold, -r : New rollup threshold
--help, -h: Show this message
### medium delete
Delete media.
Specify IDs as comma-separated values.
Example:
syrup --GLOBALS medium delete --ids FIRST,SECOND,THIRD
Options:
--ids, -i : Media identifiers (comma-separated, form "_", required)
--help, -h: Show this message
### pagerduty create
Give PagerDuty credentials to a contact.
PagerDuty is handled separately from media because it uses its own unique API calls.
Example:
syrup --GLOBALS pagerduty create --id CONTACT --service-key KEY --username USER --password PASS [--subdomain DOMAIN]
Options:
--id, -i : Parent contact ID (required)
--service-key, -s : PagerDuty service key
--subdomain, -u : PagerDuty subdomain
--username, -e : PagerDuty username
--password, -p : PagerDuty password
--help, -h: Show this message
### pagerduty get
Get JSON pagerduty credentials.
Specify contact IDs as comma-separated values, or no IDs to get all.
Example:
syrup --GLOBALS pagerduty get [--ids FIRST,SECOND,THIRD]
Options:
--ids, -i : Contact identifiers (comma-separated, or get all if omitted)
--help, -h: Show this message
### pagerduty update
Modify existing pagerduty credentials.
Specify contact IDs as comma-separated values, or no IDs to update all.
Example:
syrup --GLOBALS pagerduty update [--ids FIRST,SECOND] [--username USER] [--password PASS]
Options:
--ids, -i : Parent contact IDs
--service-key, -s : PagerDuty service key
--subdomain, -u : PagerDuty subdomain
--username, -e : PagerDuty username
--password, -p : PagerDuty password
--help, -h: Show this message
### pagerduty delete
Delete PagerDuty credentials from a contact.
Specify contact IDs as comma-separated values.
Example:
syrup --GLOBALS pagerduty delete --ids FIRST,SECOND,THIRD
Options:
--ids, -i : Contact identifiers (comma-separated, required)
--help, -h: Show this message
### rule create
Create a notification rule.
Notification rules monitor a specific set of entities. This can be defined in any combination of four ways:
* A list of entity names
* A regular expression for entity names
* A list of entity tags
* A regular expression for entity tags
Each rule has a single contact to notify, and a set of media types to use for each alert type (`UNKNOWN`, `WARNING`, `CRITICAL`).
Notifications can be disabled for an alert type by setting the "blackhole" state on that type.
Example:
syrup --GLOBALS rule create --id CONTACT [--entities ONE,TWO] [--regex-entities /RX1/,/RX2/] [--critical-media email,jabber]
Options:
--id, -i : ID of contact to notify (required)
--entities, -e : Entities (comma-separated)
--regex-entities, -r : Entity regex (comma-separated)
--tags, -t : Tags (comma-separated)
--regex-tags, -g : Tag regex (comma-separated)
--unknown-media, -u : UNKNOWN notification media types (comma-separated)
--warning-media, -w : WARNING notification media types (comma-separated)
--critical-media, -c : CRITICAL notification media types (comma-separated)
--unknown-blackhole, -n: Flag to ignore UNKNOWN alerts
--warning-blackhole, -a: Flag to ignore WARNING alerts
--critical-blackhole, -l: Flag to ignore CRITICAL alerts
--help, -h: Show this message
### rule get
Get JSON notification rule data.
Specify IDs as comma-separated values, or no IDs to get all.
Example:
syrup --GLOBALS rule get [--ids FIRST,SECOND,THIRD]
Options:
--ids, -i : Rule identifiers (comma-separated, or get all if omitted)
--help, -h: Show this message
### rule update
Modify a notification rule.
Specify IDs as comma-separated values, or no IDs to modify all.
Notification rules monitor a specific set of entities. This can be defined in any combination of four ways:
* A list of entity names
* A regular expression for entity names
* A list of entity tags
* A regular expression for entity tags
Each rule has a single contact to notify, and a set of media types to use for each alert type (`UNKNOWN`, `WARNING`, `CRITICAL`).
Notifications can be disabled for an alert type by setting the "blackhole" flag, or reactivated with the "active" flag.
NOTE: Flapjack creates and maintains a 'default' notification rule for all contacts. You can modify the 'blackhole' attributes on this rule, but any other changes will cause a new blank rule to be created.
Example:
syrup --GLOBALS rule update [--ids ONE,TWO] [--entities ONE,TWO] [--regex-entities /RX1/,/RX2/] [--critical-media email,jabber] [--unknown-blackhole] [--critical-active]
Options:
--ids, -i : Rule IDs to apply changes to
--entities, -e : Entity names (comma-separated)
--regex-entities, -r : Entity regexes (comma-separated)
--tags, -t : Tags (comma-separated)
--regex-tags, -g : Tag regexes (comma-separated)
--unknown-media, -u : UNKNOWN notification media types (comma-separated)
--warning-media, -w : WARNING notification media types (comma-separated)
--critical-media, -c : CRITICAL notification media types (comma-separated)
--unknown-blackhole, -n: Ignore UNKNOWN alerts
--warning-blackhole, -a: Ignore WARNING alerts
--critical-blackhole, -l: Ignore CRITICAL alerts
--unknown-active, -k: Activate UNKNOWN alerts
--warning-active, -v: Activate WARNING alerts
--critical-active: Activate CRITICAL alerts
--help, -h: Show this message
### rule delete
Delete a notification rule.
Specify IDs as comma-separated values.
Example:
syrup --GLOBALS rule delete --ids FIRST,SECOND,THIRD
Options:
--ids, -i : Rule identifiers (comma-separated, required)
--help, -h: Show this message
### entity create-ALL
Create special 'ALL' entity.
The 'ALL' entity (ID ALL, name ALL) is a special entity that aggregates all entities.
To use ALL, attach a user to the entity. Update the user's default notification rule to enable 'blackhole' for all alert types, then add another rule to allow specific checks or entities.
Example:
syrup --GLOBALS entity create-ALL
Options:
--help, -h: Show this message
### entity get
Get JSON entity data.
Specify IDs as comma-separated values, or no IDs to get all.
Example:
syrup --GLOBALS entity get [--ids FIRST,SECOND,THIRD]
Options:
--ids, -i : Entity identifiers (comma-separated, or get all if omitted)
--help, -h: Show this message
### entity update
Modify an entity.
Specify IDs as comma-separated values, or no IDs to modify all.
Example:
syrup --GLOBALS entity update [--ids ONE,TWO] [--add-tags TAG1,TAG2] [--remove-tags TAG3] [--add-contacts ID1,ID2] [--remove-contacts ID3]
Options:
--ids, -i : Entity identifiers (comma-separated, or get all if omitted)
--add-contacts, -d : Add contacts for this entity (comma-separated)
--remove-contacts, -e : Remove contacts for this entity (comma-separated)
--help, -h: Show this message
### entity status
Get JSON entity status data.
Specify IDs as comma-separated values, or no IDs to get all.
Entity status includes detailed information on every check linked to that entity ID.
Example:
syrup --GLOBALS entity status [--ids FIRST,SECOND,THIRD]
Options:
--ids, -i : Entities to get status for (comma-separated)
--help, -h: Show this message
### entity test
Test notifications for an entity.
Specify IDs as comma-separated values, or no IDs to get all.
Running this command will send a test notification on every check for the entity, in the same way that a real alert would be
applied.
Example:
syrup --GLOBALS entity test [--ids FIRST,SECOND,THIRD] [--summary 'Testing entities']
Options:
--ids, -i : Entities to test notifications for (comma-separated)
--summary, -s : Notification text to send
--help, -h: Show this message
### check update
Modify a check.
Specify IDs as comma-separated values, or no IDs to update all.
Check IDS are a combination of the entity name and check name, separated by a colon.
Note that tagging support is listed on the flapjack-diner page, and may be coming with the next Flapjack release.
WARNING: There is no way to re-enable a check via the API once it has been disabled! Flapjack will re-enable it when a new event is received for it.
Example:
syrup --GLOBALS check update [--ids ENTITY:CHECK,ENTITY:CHECK] [--add_tags TAG,TAG] [--disable]
Options:
--ids, -i : Check identifiers (comma-separated, format ":")
--disable, -d: Disable the check
--help, -h: Show this message
### check status
Get JSON check status data.
Specify IDs as comma-separated values, or no IDs to get all. Check IDS are a combination of the entity name and check name,
separated by a colon.
Example:
syrup --GLOBALS check status [--ids ENTITY:CHECK,ENTITY:CHECK,ENTITY:CHECK]
Options:
--ids, -i : Checks to get status for (comma-separated, format ":")
--help, -h: Show this message
### check test
Test notifications for a check.
Specify IDs as comma-separated values. Check IDS are a combination of the entity name and check name, separated by a colon.
Running this command will send a test notification on the check, in the same way that a real alert would be applied.
Example:
syrup --GLOBALS check test --ids ENTITY:CHECK,ENTITY:CHECK,ENTITY:CHECK [--summary 'Testing checks']
Options:
--ids, -i : Checks to test notifications for (comma-separated, format ":")
--summary, -s : Notification text to send
--help, -h: Show this message
## Contributing
1. Create an issue on GitHub
2. Fork the project into your personal account
3. Make your changes
4. Submit a Pull Request
Please include tests with your changes. Adding tests for existing work is also greatly appreciated.
## License
This project is released under the MIT License. See LICENSE.txt for details.
Copyright (c) 2014 RetailMeNot, Inc.
Code developed by Geoff Hicks (ghicks-rmn and gffhcks on GitHub)