This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> /* printf() */ | |
| #include <getopt.h> /* getopt() */ | |
| #include <stdbool.h> /* bool type */ | |
| #include <stdlib.h> /* atoi() & EXIT_FAILURE */ | |
| bool is_verbose = false; | |
| void usage(const char *prog_name) { | |
| printf("Usage: %s [-h/--help] [-v/--verbose] [-p/--port PORT] [-t/--time[=FORMAT]]\n", prog_name); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> // printf() | |
| #include <time.h> // time() | |
| #include <sys/time.h> // localtime() | |
| char timestamp[28]; | |
| char *now() { | |
| time_t t = time(NULL); | |
| struct tm* local_time = localtime(&t); | |
| struct timeval epoch; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> // printf() | |
| #include <time.h> // time() | |
| #include <unistd.h> // getpid() | |
| int main() { | |
| int PID = (int)getpid(); | |
| printf("pid = %d\n", PID); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <time.h> | |
| int main() { | |
| int epoch_seconds = (int)time(NULL); | |
| printf("epoch = %d\n", epoch_seconds); | |
| return 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| int main() { | |
| printf("Hello World!\n"); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cat my.har | jq 'del(.log.entries[].response.content.text)' | jq 'del(.log.entries[].request.headers[])' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /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}")" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] |
NewerOlder