Skip to content

Instantly share code, notes, and snippets.

@tyzbit
tyzbit / interactive-tcp.sh
Last active September 21, 2017 03:15
Connect to an arbitrary TCP port to Read/Write. Very basic, will probably break easily but robust enough to test FTP credentials sans FTP
#!/bin/bash
if [ ! -z $2 ]; then
host=$1
port=$2
exec 5<>/dev/tcp/$host/$port
cat <&5 &
trap "exec 5>&- " EXIT
while true; do
read p
echo "$p" >&5
@tyzbit
tyzbit / plex-dashboard.xml
Last active September 14, 2021 22:54 — forked from Dirrk/plex-dashboard.xml
splunk dashboard for plex
<dashboard>
<label>my-plex-dashboard</label>
<row>
<panel>
<chart>
<title>Plex memory usage - 6 hours</title>
<search>
<query>index="os" source=ps COMMAND=Plex | rex field=ARGS ".*?-i_.*\/media\/.*\/(?&lt;t_file&gt;.*?)_-(?:filter|map_inline|map_[\d])" | rex field=ARGS "Plug.*\/(?&lt;plugin_name&gt;.*)$" | eval memMB=mem_used/1048576 | eval name=if(ARGS LIKE "New_Transcoder%",if(isnull(t_file),"Unknown Video Source",t_file),if(ARGS LIKE "Plug-in%", plugin_name, ARGS)) | timechart limit=20 avg(memMB) by name</query>
<earliest>-6h</earliest>
<latest>now</latest>
@tyzbit
tyzbit / plex-status.js
Last active February 9, 2016 14:31 — forked from Dirrk/plex-status.js
Plex status.js
#!/usr/bin/node
/*
Install nodejs
create directory with this file in it and run the following commands:
npm install wreck@7.0.0 lodash@3.10.1
Setup with crontab:
* * * * * /usr/bin/node /home/dirrk/scripts/plex-info/plex-status.js >> /var/log/plex/plexstatus.log 2>/dev/null
Setup splunk to consume json with timestamp from utc on timestamp field
^(?:(?P<timestamp>\d+\/\d+\/\d+\s+\d+:\d+:\d+) (?:(?P<failed_file>[^:]+): (?P<failure_status>[^:]+): HTTP code (?P<http_code>\d+): \"(?P<http_status>[^"]+)\", (?:.+: (?P<failure_json>{.*})|.+)|(Amazon cloud drive root '(?P<acd_root>.*)': )?(?<acd_status>[\w\s]+)|(?P<file_path>(?:.*\/)?(?<filename>[^\/]+\.[a-z0-9]{3,5}))?[a-zA-Z\/\s\.0-9]*: (?<acd_action>[^\n]+)))?(\n?Transferred:\s+(?<transferred_bytes>\d+)\s+Bytes\s*\(\s*(?<transfer_speed>[\d\.]+) kByte\/s\)\nErrors:\s+(?<errors>\d+)\nChecks:\s+(?<checks>\d+)\nTransferred:\s+(?<files_transferred>\d+)\nElapsed time:\s+((?P<hour>[0-9\.]+)h)?((?P<min>[0-9\.]+)m)?(?P<sec>[0-9\.]*)s)?$
^<W>(?P<timestamp>\d+\-\d+\-\d+\s+\d+:\d+:\d+\.\d+)\s+(?P<server_number>\d+)\s+=>\s+<(?P<connection_number>[^:]+):((?P<user>\w+))?\((?P<userid>[\d\-]+)[^ \n]* (?P<full_message>(.*to (?P<channel>[ \-=\w\#\[\]\{\}\(\)\@\|\'\.]+)\[)?(.*connection: (?P<ipaddress>[0-9\.]+))?(.*version (?P<version>[0-9\.]+))?(.* \((?P<version_full>.*))?.+)
[Plex - Top transcoded media]
dispatch.earliest_time = -7d@h
dispatch.latest_time = now
display.general.type = statistics
display.page.search.mode = fast
display.page.search.tab = statistics
display.visualizations.charting.chart = area
display.visualizations.show = 0
request.ui_dispatch_app = search
request.ui_dispatch_view = search
^(?<timestamp>\w+\s+\d+,\s+\d+\s+\d+:\d+:\d+\.\d+)[^\]\n]*\]\s+(?<loglevel>\w+) - (?<full_message>(?:(?:Request: \[(?<request_ip>[^:]+).*Token \((?<username>[^)]+))?(?:\[?(?<status_source>[\w\s]+)((\]|: )))?(?:Adding (?<session_number>\d) sessions\.)?(?:Found session GUID of (?<session_guid>[^\s]+))??(?:Session (?<playback_session_guid>[^\s]+) \((?<playback_session_number>[^\)]+)\) is (?<placyback_session_status>\w+))?(?:using profile (?<transcode_profile>.*))?(?:.*\/transcode\/session\/(?<transcode_session_guid>[^\/]+))?(?:It took (?<time_taken>[\d\.]+) sec to (?<action_taken>.*))?)?(?:Content-Length of (?<file_path>.*\/(?<file_name>[\w\s]+\.(avi|mp4|mkv|m4v|wmv|mpg|mpeg|divx))(\s|$)))?.*)$
@tyzbit
tyzbit / discord commands.md
Last active March 31, 2021 14:42
Discord Commands

General Dyno commands can be found here

https://www.dynobot.net/commands


Toggleable server roles (so people can use @[role] to ping you)

Command Role Additional Permissions
#!/bin/bash
#
# Prints out information from bitcoin-cli about the previous Bitcoin difficulty
# adjustment and the projected difficulty adjustment.
#
# Requires: bitcoin-cli
# jq
# bc
#
#!/bin/bash
# date,wallet_balance,channel_balance,total_capacity,remote_balance,unsettled_balance,sent_balance,received_balance,off_chain_updates,active_nodes,inactive_nodes,pending_channels,limbo_channels,pending_open,pending_close,pending_force_close
lncli="/home/lightning/gocode/bin/lncli"
file="~/lightning-monitor.csv"
# Date
newline="$(date +%s%3N)"
#set the separator to not be space
IFS=""