Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce attributes, new example client
Also updates protobuf protocol version to newer version.
- Loading branch information
Showing
8 changed files
with
238 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Version 0.2 - Aug 18, 2016 | ||
- Created Makefile to add --require protobuf-python when building RPMs | ||
Dependency met in upstream RHEL7 repositories | ||
- Updated Protobuf protocol definition with later Riemann additions | ||
- Support attributes on messages | ||
- Introduced send-riemann-events.py as example, works out-of-the-box | ||
|
||
Version 0.1 - Mar 4-May 3, 2012 | ||
Initial version by Gleicon Moraes (gleicon) with patches Steve Losh (sjl). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
rpm: | ||
python setup.py bdist_rpm --requires protobuf-python --build_requires protobuf-compiler | ||
|
||
clean: | ||
python setup.py clean | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Send events to Riemann from CLI | ||
""" | ||
|
||
from riemann import RiemannClient | ||
import argparse | ||
import socket | ||
import time | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Send events to Riemann.') | ||
parser.add_argument('-r', '--riemann', dest='rie_host', action='store', | ||
type=str, required=True, | ||
help='IP/hostname for Riemann server') | ||
parser.add_argument('-R', '--riemann-port', dest='rie_port', action='store', | ||
type=int, default=5555, | ||
help='IP/hostname for Riemann server') | ||
|
||
parser.add_argument('-H', '--host', dest='evt_host', action='store', | ||
type=str, default=socket.getfqdn(), | ||
help='Hostname for event') | ||
parser.add_argument('-s', '--service', dest='evt_service', action='store', | ||
type=str, help='Service for event') | ||
parser.add_argument('-S', '--state', dest='evt_state', action='store', | ||
type=str, help='Current state for event') | ||
parser.add_argument('-T', '--time', dest='evt_time', action='store', | ||
type=int, default=int(time.time()), | ||
help='Timestamp for event') | ||
|
||
parser.add_argument('-a', '--attribute', dest='evt_attrib', action='append', | ||
type=str, help='Event attribute (key=value), multiple allowed') | ||
parser.add_argument('-d', '--description', dest='evt_description', | ||
action='store', type=str, help='Event description') | ||
parser.add_argument('-t', '--tags', dest='evt_tags', action='append', | ||
type=str, help='Event tags, multiple allowed') | ||
parser.add_argument('-m', '--metric', dest='evt_metric', action='store', | ||
type=float, help='Event metric') | ||
parser.add_argument('--ttl', dest='evt_ttl', action='store', type=int, | ||
default=60, help='Event TTL') | ||
args = parser.parse_args() | ||
|
||
|
||
event = {} | ||
for i in ['host', 'service', 'time', 'description', 'tags', 'metric', 'ttl']: | ||
if getattr(args, 'evt_' + i): | ||
event[i] = getattr(args, 'evt_' + i) | ||
|
||
if getattr(args, 'evt_attrib', None): | ||
event['attributes'] = dict(item.split('=') for item in getattr(args, 'evt_attrib')) | ||
|
||
print(repr(event)) | ||
|
||
rc = RiemannClient(host=args.rie_host, port=args.rie_port) | ||
rc.send(event) | ||
|
||
if __name__ == '__main__': | ||
main() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
PROTOC=/usr/local/bin/protoc | ||
PROTOC=/usr/bin/protoc | ||
MV = /bin/mv | ||
|
||
protobuf: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.