Skip to content

Instantly share code, notes, and snippets.

View jagland's full-sized avatar

Jon Agland jagland

  • Wales
View GitHub Profile
@jagland
jagland / monit-slack-busybox.sh
Created May 14, 2024 21:12
monit-slack-busybox.sh
#!/bin/ash
# Alternative script for use with busybox (OpenWRT etc..), which uses wget rather than curl
SLACK_WEBHOOK="https://hooks.slack.com/services/..."
SLACK_CHANNEL="#alerts"
SLACK_USERNAME="monit on $MONIT_HOST"
if [[ "$MONIT_DESCRIPTION" =~ .*"succeeded".* ]]; then
SLACK_ICON=":white_check_mark:"
@jagland
jagland / range-expander.sh
Last active June 22, 2023 10:01
range-expander.sh
#!/bin/bash
# range-expander.sh, expands a range of ports/numbers e.g. VLANs, or Port/Interface numbers to a long list.
# intention is to plug into Ansible roles, but likely more to-do./
# Note, this will only sequence or expand the last numbers so "1/1/1-1/2/24" will work, but
# other combintations will only yield the start and ending left most parts e.g. "1/1/1-1/3/24" will not give
# any of "1/2/x".
# Please split that to "1/1/1-1/1/24,1/2/1-1/3/24" etc..
# Example usage
# ./range-expander.sh "1,2,3,1-1,9-17,1002"
#!/bin/bash
SLACK_WEBHOOK="https://hooks.slack.com/services/..."
SLACK_CHANNEL="#alerts"
SLACK_USERNAME="monit on $MONIT_HOST"
if [[ "$MONIT_DESCRIPTION" =~ .*"succeeded".* ]]; then
SLACK_ICON=":white_check_mark:"
SLACK_USERNAME="monit on $MONIT_HOST - service up"
elif [[ "$MONIT_DESCRIPTION" =~ .*"failed".* ]]; then
SLACK_ICON=":exclamation:"
#!/bin/bash
# AWS secrets from the IAM account.
export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""
# Passphrase for duplicity backups (GPG encrypted)
export PASSPHRASE=""
duplicity restore boto3+s3://example-s3-bucket/$j /data/testrestore/$1 --tempdir=/data/tmp
#!/bin/bash
# AWS secrets from the IAM account.
export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""
# Passphrase for duplicity backups (GPG encrypted)
export PASSPHRASE=""
# Backup folders
backupfolders=""
@jagland
jagland / smartgraphprobe.sh
Last active January 16, 2022 14:38
smartgraphprobe - Probe HDDs via smartctl, export data as json, use jq to create a csv, then gnuplot to create a graph showing Power_on_time in years
#!/bin/bash
outfile=smart.csv
outgraph=smart.png
rm $outfile
array=('hosts=(root@host1 user@host2 userb@host3)' 'sudo=(root sudo sudo)' 'devices=(sdb,sdd sda,sdb,sdc sda,sdb)')
for j in "${array[@]}"; do eval $j; done
tmpfile=$(mktemp)
let i=0
for h in ${hosts[@]}
do
version: "3.6"
networks:
splunknet:
driver: bridge
attachable: true
services:
splunk:
networks:
@jagland
jagland / syslog-ng-conf.d-remote.conf
Created November 13, 2021 10:33
syslog-ng-conf.d-remote.conf
options {
time-reap(30);
mark-freq(10);
keep-hostname(yes);
};
source s_network {
syslog(transport(udp) port(514));
};
destination d_logs {
file(
#!/bin/bash
# check epson printer ink levels on an XP-235.
typeset -l PRINTERNAME
PRTINFO=`mktemp`
wget -q -O $PRTINFO http://IP/PRESENTATION/HTML/TOP/PRTINFO.HTML
VALUES=`cat $PRTINFO | grep Ink | awk -F\' '{ print $6 }' | xargs | sed -e 's/ /, /g'`
PRINTERNAME=`cat $PRTINFO | grep "Printer Name" | awk -F\> '{ print $7}' | sed -e 's$</td$
SLACKWEBHOOK="https://hooks.slack.com/services/blah"
echo $PRINTERNAME
COLOURS=(Black Yellow Magenta Cyan)
@jagland
jagland / ldap-search-freeradius.sh
Last active March 27, 2019 15:47
ldapsearch based on FreeRADIUS configuration
#!/bin/bash
#
# ldapsearch based on FreeRADIUS configuration
# Known issue(s) - Checks only the first LDAP server, doesn't read the configuration file properly, i.e. it's just greping for what might work...
if [ -z "$1" ]; then
FILE=/etc/freeradius/mods-enabled/ldap
else
FILE=$1
fi