Skip to content

tecnickcom/natsping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

natsping

NATS Bus Test Component

Master Branch Master Build Status Master Coverage Status Go Report Card

Description

NATS Bus Ping Command.

This command-line program allows to ping a NATS bus to see if it is alive.

Requirements

An additional Python program is used to check the validity of the JSON configuration files against a JSON schema:

sudo pip install json-spec 

Quick Start

This project includes a Makefile that allows you to test and build the project in a Linux-compatible system with simple commands.
All the artifacts and reports produced using this Makefile are stored in the target folder.

All the packages listed in the resources/DockerDev/Dockerfile file are required in order to build and test all the library options in the current environment. Alternatively, everything can be built inside a Docker container using the command "make dbuild".

To see all available options:

make help

To build the project inside a Docker container (requires Docker):

make dbuild

To build a particular set of options inside a Docker container:

MAKETARGET='buildall' make dbuild

The list of pre-defined options can be listed by typing make

The base Docker building environment is defined in the following Dockerfile:

resources/DockerDev/Dockerfile

To execute all the default test builds and generate reports in the current environment:

make qa

To format the code (please use this command before submitting any pull request):

make format

Useful Docker commands

To manually create the container you can execute:

docker build --tag="tecnickcom/natspingdev" .

To log into the newly created container:

docker run -t -i tecnickcom/natspingdev /bin/bash

To get the container ID:

CONTAINER_ID=`docker ps -a | grep tecnickcom/natspingdev | cut -c1-12`

To delete the newly created docker container:

docker rm -f $CONTAINER_ID

To delete the docker image:

docker rmi -f tecnickcom/natspingdev

To delete all containers

docker rm $(docker ps -a -q)

To delete all images

docker rmi $(docker images -q)

Usage

Usage:
  natsping [flags]
  natsping [command]

Available Commands:
  version     print this program version

Flags:
  -c, --configDir   string  Configuration directory to be added on top of the search list
  -l, --logLevel     string  Log level: EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG
  -n, --natsAddress  string  NATS bus Address (nats://ip:port) (default "nats://127.0.0.1:4222")

Use "natsping [command] --help" for more information about a command.

How it works

The program can be started by issuing the following command (with the right parameters):

natsping --natsAddress="nats://127.0.0.1:4222 --logLevel=INFO"

If no command-line parameters are specified, then the ones in the configuration file (config.json) will be used.
The configuration files can be stored in the current directory or in any of the following (in order of precedence):

  • ./
  • config/
  • $HOME/natsping/
  • /etc/natsping/

This program also support secure remote configuration via Consul or Etcd.
The remote configuration server can be defined either in the local configuration file using the following parameters, or with environment variables:

  • remoteConfigProvider : remote configuration source ("consul", "etcd");
  • remoteConfigEndpoint : remote configuration URL (ip:port);
  • remoteConfigPath : remote configuration path where to search fo the configuration file (e.g. "/config/natsping");
  • remoteConfigSecretKeyring : path to the openpgp secret keyring used to decript the remote configuration data (e.g. "/etc/natsping/configkey.gpg"); if empty a non secure connection will be used instead;

The equivalent environment variables are:

  • NATSPING_REMOTECONFIGPROVIDER
  • NATSPING_REMOTECONFIGENDPOINT
  • NATSPING_REMOTECONFIGPATH
  • NATSPING_REMOTECONFIGSECRETKEYRING

The natsping command exit with the status 0 if the NATS bus is responding, otherwise it generates an error log message and exit with 1.

Logs

This program logs the log messages in json format. For example:

{"datetime":"2016-10-06T15:00:39Z","hostname":"nickxm","level":"debug","msg":"initializing NATS bus","nats":"nats://127.0.0.1:3333","program":"natsping","release":"1","timestamp":1475766039219189166,"version":"1.2.1"}

Developer(s) Contact