Skip to content

Instantly share code, notes, and snippets.

@wh13371
wh13371 / har.sh
Created March 18, 2022 12:21
use jq to delete data from a .har file
cat my.har | jq 'del(.log.entries[].response.content.text)' | jq 'del(.log.entries[].request.headers[])'
#! /bin/bash
_LOGFILE=/home/genesys/.@/$0.log
_NOW=$(date +"%Y-%m-%d %H:%M:%S.%6N")
_EPOCH=$(date +"%s.%6N")
_NOW_UTC=$(date --utc +%FT%T.%6N%Z)
_MSG="test message @ $_NOW_UTC"
_LOG="$(printf '{"timestamp": "%s", "epoch": "%s", "timestamp_utc": "%s", "message": "%s"}' "${_NOW}" "${_EPOCH}" "${_NOW_UTC}" "${_MSG}")"
@wh13371
wh13371 / send_scs_to_mattermost.py
Created December 22, 2020 13:51
send scs alarm data to Mattermost
def send_to_mattermost(mm_url, mm_channel, mm_username, redis_id, redis_data):
_text = {'@timestamp': get_now_iso(),
'epoch': int(get_epoch()),
"condid": int(redis_data.get(b'condid').decode()),
"condname": redis_data.get(b'condname').decode(),
"conddesc": redis_data.get(b'conddesc').decode(),
"msgid": int(redis_data.get(b'msgid').decode()),
"msgtext": redis_data.get(b'msgtext').decode(),
"appid": int(redis_data.get(b'appid').decode()),
@wh13371
wh13371 / send_scs_to_influxdb.py
Last active December 22, 2020 13:56
send scs alarm data to InfluxDB
def send_to_influxdb(redis_id, redis_data):
_data = [{
"measurement": "scs.alarms",
"tags": {
"host": redis_data.get(b'hostname'),
"app": redis_data.get(b'appname'),
"msgid": redis_data.get(b'msgid'),
},
"time": int(time.time()),
def start_redis_consumer():
dd("Starting Redis Consumer")
while True:
events = r.xread({REDIS_STREAM: '$'}, block=0, count=None)
for _, data in events:
stream = _
_redisid = data[0][0]
_redisdata = data[0][1]
@wh13371
wh13371 / jq_install.sh
Created December 17, 2020 11:12
jq - install
cd tmp
wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -O jq
chmod +x jq
sudo cp jq /usr/bin
@wh13371
wh13371 / docker-compose_REDIS.yml
Created November 24, 2020 12:41
A Redis Docker Container
version: '3'
services:
redis:
image: redis
container_name: redis
ports:
- 6379:6379
network_mode: host
sudo firewall-cmd --zone=public --add-masquerade --permanent
sudo firewall-cmd --reload

CentOS 8 - install "rsyslog"

sudo dnf install rsyslog -y
rpm -q rsyslog # check
dnf info rsyslog --verbose # check
sudo systemctl status rsyslog # status
sudo systemctl start rsyslog # start
sudo systemctl enable rsyslog # enable for reboot
echo "test message from fizz" | logger
version: '3'
services:
influx2:
image: quay.io/influxdb/influxdb:2.0.0-beta
container_name: influx2
volumes:
- $PWD/data:/root/.influxdbv2
- $PWD/data/engine:/root/.influxdbv2/engine
command:
- --reporting-disabled