https://github.com/yuce/catnats
cat for NATS gnatsd server
https://github.com/yuce/catnats
Last synced: 14 days ago
JSON representation
cat for NATS gnatsd server
- Host: GitHub
- URL: https://github.com/yuce/catnats
- Owner: yuce
- License: other
- Created: 2016-04-09T23:42:39.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-02-25T10:21:25.000Z (over 7 years ago)
- Last Synced: 2025-11-12T22:06:05.864Z (8 months ago)
- Language: Python
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# catnats
`cat` for [NATS](http://nats.io) gnatsd server. Works for both TLS and non-TLS connections.
## NEWS
* **2016-06-19**: Version 0.1.2:
* Bug fixes.
* **2016-03-29**: Version 0.1.1:
* Added `--raw` option.
* **2016-04-29**: Version 0.1.0:
* Changed how the server address is specified. You can now use `--addr host:port`
* If no adddress is specified, the default `127.0.0.1:4222` is used.
* Added the following `CONNECT` message parameters: `--user`, `--pass` and `--verbose`. If any of
these parameters is given in the command line, a `CONNECT` message is sent to the server.
## Requirements
A recent version of Python
## Usage
`catnats.py [options]`
### Options:
* `-addr`: Specify the server address and port in the form of `HOST:PORT`
* `-q` or `--quiet`: Suppress output
* `--raw`: Raw input. Do not process data coming from STDIN
* `--pong`: Enable automatically sending a `PONG` message to gnatsd
when a `PING` message is received (to keep the connection alive)
* `--no-exit`: Do not exit automatically (unless there is an error)
* `--user USER`: Send a `CONNECT` message with `user` field set to `USER`
* `--pass PASSWORD`: Send a `CONNECT` message with `pass` field set to `PASSWORD`
* `--verbose true | false`: Send a `CONNECT` message with `verbose` field set to `VERBOSE`
### Examples
Works with pipes:
```
$ printf 'connect {}\r\nping\r\n' | ./catnats.py -q --addr demo.nats.io:4443
```
And without:
```
$ ./catnats.py --pong --addr demo.nats.io:4443
```
Publish time and date every 5 seconds:
```
$ while true; do time=`date` && \
printf "PUB device-time.$(hostname) ${#time}\r\n${time}\r\n" | \
./catnats.py --quiet --addr demo.nats.io:4443; sleep 5; done
```
Send load average every 5 seconds (on Linux)
```
$ while true; do payload=`cat /proc/loadavg | cut -f 1-3 -d" "` && \
printf "PUB device-avgload.$(hostname) ${#payload}\r\n${payload}\r\n" | \
./catnats.py --quiet --addr demo.nats.io:4222; sleep 5; done
```
The same on OSX
```
$ while true; do payload=`sysctl -n vm.loadavg | cut -f 2-4 -d" "` && \
printf "PUB device-avgload.$(hostname) ${#payload}\r\n${payload}\r\n" | \
./catnats.py --quiet --addr demo.nats.io:4222; sleep 5; done
```
## License
```
Copyright (c) 2016, Yuce Tekol .
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* The names of its contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```