def sendclear(service): conf = ConfigParser() conf.read(("/etc/bernhard.conf", )) client = bernhard.SSLClient(host=conf.get('default', 'riemann_server'), port=int(conf.get('default', 'riemann_port')), keyfile=conf.get('default', 'tls_cert_key'), certfile=conf.get('default', 'tls_cert'), ca_certs=conf.get('default', 'tls_ca_cert')) host = socket.gethostname() client.send({ 'host': host, 'service': service, 'state': 'ok', 'tags': ['netflow-nfdump-alerting'], 'ttl': 3700, 'metric': 0 })
def sendalert(txt, service, state): conf = ConfigParser() conf.read(("/etc/bernhard.conf", )) client = bernhard.SSLClient(host=conf.get('default', 'riemann_server'), port=int(conf.get('default', 'riemann_port')), keyfile=conf.get('default', 'tls_cert_key'), certfile=conf.get('default', 'tls_cert'), ca_certs=conf.get('default', 'tls_ca_cert')) host = socket.gethostname() client.send({ 'host': host, 'service': service, 'state': state, 'description': txt, 'tags': ['netflow-nfdump-alerting'], 'ttl': 600, 'metric': 1 }) logging.info('%s', txt)
response = urllib2.urlopen(req) response.read() logging.info('Download completed for env %s', ENV) # main if __name__ == "__main__": args = main() ENV = args['env'] conf = ConfigParser() conf.read(("/etc/bernhard.conf", )) client = bernhard.SSLClient(host=conf.get('default', 'riemann_server'), port=int(conf.get('default', 'riemann_port')), keyfile=conf.get('default', 'tls_cert_key'), certfile=conf.get('default', 'tls_cert'), ca_certs=conf.get('default', 'tls_ca_cert')) logging.info('Test started for env %s', ENV) ENV = args['env'] state = args['state'] checkservice = "%s.download_canary.check" % ENV exectimeservice = "%s.download_canary.exectime" % ENV start_time = time.time() host = socket.gethostname() try: downloadtest(args) exectime = time.time() - start_time client.send({ 'host': host,
import bernhard c = bernhard.SSLClient(host='127.0.0.1', port=5555, keyfile='example/ssl/client.pkcs8', certfile='example/ssl/client.crt', ca_certs='example/ssl/cacert.pem') c.send({'host': 'myhost.foobar.com', 'service': 'myservice', 'metric': 12}) q = c.query('true')
stdout = proc.stdout.read() stderr = proc.stderr.read() description = """ STDOUT >>> %s <<< STDERR >>> %s <<< """ % (stdout, stderr) if options.keyfile and options.certfile and options.cafile: riemann = bernhard.SSLClient(host=options.riemann_host, port=options.riemann_port, keyfile=options.keyfile, certfile=options.certfile, ca_certs=options.cafile) else: riemann = bernhard.Client(host=options.riemann_host, port=options.riemann_port, transport=bernhard.TCPTransport if options.tcp else bernhard.UDPTransport) riemann_event = {} riemann_event["service"] = service riemann_event["description"] = description if options.state_from_stdout: riemann_event["state"] = stdout.strip() else: