Skip to content

Instantly share code, notes, and snippets.

View chluehr's full-sized avatar

Christoph Lühr chluehr

View GitHub Profile
@chluehr
chluehr / cakeagent.sh
Created June 29, 2018 12:41
Updated statuscake agent script to better deal with cpu usage and disk space reporting
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/etc/cakeagent
# Make sure we have some auth information
if [ -f /etc/cakeagent/auth.log ]
then
Authentication=($(cat /etc/cakeagent/auth.log))
else
echo "Something has gone wrong and we can not find your auth credentials. Please reinstall"
exit 1
@chluehr
chluehr / Makefile
Created May 7, 2018 10:35
Makefile to fetch(sync) Cloudfront S3 Logs and analyze them with goaccess Logfile Analyzer.
all: fetch report
fetch:
aws s3 sync --exclude "*" --include "*2018-03-*" --include "*2018-04-*" --include "*2018-05-*" s3://$BUCKET/$PATH/ .
report:
find . -name \*.gz | xargs gzcat | goaccess --log-format CLOUDFRONT --date-format CLOUDFRONT --time-format CLOUDFRONT -o ./report.html
@chluehr
chluehr / php-spawn-command-check-processp-status.php
Created January 30, 2018 11:01
Spawn a shell command from PHP, check Process status, respawn if not running.
<?php
/**
* $ php p.php
* S SPAWNED! RRRRS SPAWNED! RRRRRS SPAWNED! R
*/
function spawn() {
$descriptorspec = array(
@chluehr
chluehr / restic-backup.sh
Created November 5, 2017 10:57
Backup via restic to Backblaze
#!/bin/bash
#
# Setup:
# wget https://github.com/restic/restic/releases/download/v0.7.3/restic_0.7.3_linux_amd64.bz2
# bunzip2 restic_0.7.3_linux_amd64.bz2
# mv restic_0.7.3_linux_amd64 /usr/local/bin/restic
# chmod a+x /usr/local/bin/restic
#
# crontab -e
# 0 1 * * * /root/bin/restic-backup.sh 2>&1 >>/var/log/restic-backup.log
@chluehr
chluehr / sample-table-print.html
Created December 16, 2016 13:40
HTML Example for a printable print CSS with repeating table column headers suitable for wkhtmltopdf
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
margin: 60px;
}
@chluehr
chluehr / test.sh
Created May 2, 2016 14:16
test desc
#!/bin/bash
test
@chluehr
chluehr / 0_reuse_code.js
Created May 2, 2016 13:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
/* /website/static/js/editmode/wysiwyg.js */
CKEDITOR.stylesSet.add( 'custom_styles', [
// Paragraph Styles
{ name: 'Regular Text', element: 'p', attributes: { 'class': '' }},
{ name: 'Large Text', element: 'p', attributes: { 'class': 'content__text-L' } }
]);
CKEDITOR.editorConfig = function( config ) {
// add our custom styles
@chluehr
chluehr / find_inode_usage.sh
Created June 24, 2015 09:03
Finds where all your inodes are being used ..
#!/bin/bash
# see: http://unix.stackexchange.com/questions/117093/find-where-inodes-are-being-used
# show inode usage:
df -i
# find where all those files are (roughly) - starts at /
find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n
@chluehr
chluehr / purge_old_kernels.sh
Created June 16, 2015 09:04
Simple Script to delete all old kernels except the last recent 2 (after auto-updates) - use with caution
#!/bin/bash
OLD=$(ls -tr /boot/vmlinuz-* | head -n -3 | cut -d- -f2- |
awk '{print "linux-image-" $0 " linux-headers-" $0}' )
echo "OLD:"
echo "$OLD"
echo
echo -n "CURRENT: "
uname -r