https://github.com/sipcapture/hepgen-bash
An HEP generator written in bash
https://github.com/sipcapture/hepgen-bash
Last synced: 6 months ago
JSON representation
An HEP generator written in bash
- Host: GitHub
- URL: https://github.com/sipcapture/hepgen-bash
- Owner: sipcapture
- License: lgpl-2.1
- Created: 2017-05-11T10:59:25.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-15T14:37:02.000Z (almost 8 years ago)
- Last Synced: 2024-07-31T19:17:57.014Z (9 months ago)
- Language: Shell
- Size: 12.7 KB
- Stars: 4
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-hep - HEPgen-bash - HEP generator written in bash (Contribution Guidelines / Tools)
README
# hepgen-bash
A HEP generator written in bash
## Features
`hep_send_log` sends HEP3 log packets to a capture node, using mostly bash (see **Requirements** for details).
Example:
```
$ hep_send_log -i 1337 10.0.0.42:9060 '123-abc-foo' 'This is a NaN% important log message'
```sends a HEP3 log packet to **10.0.0.42:9060** with source capture id **1337**, **123-abc-foo** correlation ID and **This is a NaN% important log message** as a payload.
In combination with tools such as **tail** and **awk** or **grep**, it can be used to gather logs from any file and send them to Homer, without the requirement of any fancy dependency.
Example:
```bash
#!/bin/bashLOGFILE=/path/to/logfile
HOMER_PEER=10.0.0.42:9060
CAPTURE_ID=1337
PATTERN='^ERROR'tail -F "$LOGFILE" | grep --line-buffered "$PATTERN" |
while read line
do
correlation_id=$(sed 's/^ERROR \([^ ]*\) .*$/\1/' <<< "$line")
hep_send_log -i "$CAPTURE_ID" "$HOMER_PEER" "$correlation_id" "$line"
done
```While running this script, whenever a line such as
```
(...)
ERROR 46F5B0 problem with foo
(...)
```appears in `/path/to/logfile`, the log line is sent to the homer peer, with **46F5B0** as correlation id.
## Usage
```
hep_send_log [OPTIONS] :
OPTIONS:
-i : sets the HEP capture ID (default: 0)
-k : sets the HEP auth key (default: none)
-s : sets the HEP source IP (default: will use `ip route get` to guess)
-h : displays this message and exits
```## Requirements
- **bash** (>=4)
- **xxd** (part of **vim**)
- **ip** (for source IP automatic discovery)
- GNU **date**## License
LGPL-2.1
## Limitations
For now, `hep_send_log` only supports IPv4 as source or destination