Skip to content

Instantly share code, notes, and snippets.

@johnteslade
johnteslade / check_apt_autoremove
Created February 15, 2015 10:39
Nagios plugin to check if a machine has packages that apt can autoremove
#!/bin/bash
# Nagios plugin to check if a machine has packages that apt can autoremove
# Author: John Slade (http://jtes.net)
AUTOREM_OUTPUT=$(apt-get --dry-run autoremove)
TO_REMOVE=$(echo $AUTOREM_OUTPUT | perl -pe 's/^.*?, (\d*) to remove.*$/$1 to remove/g')
if echo $AUTOREM_OUTPUT | grep -q "0 to remove"; then
# no pacakges to remove (0=OK)
@johnteslade
johnteslade / check_reboot_required.sh
Created February 15, 2015 09:54
Nagios plugin for ubuntu machine needing reboot
#!/bin/bash
# Nagios plugin to check if a machine needs to be rebooted after run apt
# Original source http://serverfault.com/a/268528/41649
if [ ! -f /var/run/reboot-required ]; then
# no reboot required (0=OK)
echo "OK: no reboot required"
exit 0
else
@johnteslade
johnteslade / chromecast_dl.sh
Created November 20, 2014 16:21
Download chromecast backgrounds to computer
#!/bin/sh
curl https://raw.githubusercontent.com/dconnolly/chromecast-backgrounds/master/README.md | sed -e "s/^\!\[\](//g" | sed -e "s/)$//g" > urls.txt
cat urls.txt | parallel --gnu -n 1 wget -nc -P out
@johnteslade
johnteslade / pysqliteosquery.py
Created October 30, 2014 17:00
Query your OS using sqlite and apsw
import os, sys, time
import apsw
import psutil
class PortsSource(object):
""" List of ports """
def Create(self, db, modulename, dbname, tablename, *args):
columns = ['pid', 'name', 'username']
data = []
alert('yay');