Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

final=800
counter=0
while [ $counter -le $final ]; do
printf "\r %75s/%4s" $counter $final
sleep 1
((counter++));
done
@flickerfly
flickerfly / upgrade-postgres-9.3-to-9.5.md
Created January 16, 2017 17:38 — forked from johanndt/upgrade-postgres-9.3-to-9.5.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
@flickerfly
flickerfly / Get-ServerDNSSettings.ps1
Created November 30, 2016 20:44
Check the DNS Settings for all Windows Servers
# Source: http://www.jbmurphy.com/2013/09/23/quick-powershell-script-to-check-dns-settings-on-all-servers/
# Could use error checking to not throw an alert when the server isn't accessible
$AllServers=Get-ADComputer -Filter {OperatingSystem -Like "Windows Server*"}
ForEach ($Server in $AllServers){
$Result=Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = 'True'" -Property DNSServerSearchOrder -ComputerName $Server.Name
$output = new-object PSObject
$output | add-member NoteProperty "ComputerName" $Server.Name
$output | add-member NoteProperty "DNSServerSearchOrder" $Result.DNSServerSearchOrder
$output
@flickerfly
flickerfly / Get-DCbyName.ps1
Created November 30, 2016 19:35
List Names of Domain Controllers
# http://use-powershell.blogspot.com/2013/04/find-all-domain-controllers-in-domain.html
Get-ADDomainController -Filter * |Select-Object name
@flickerfly
flickerfly / list-scripts-sending-mail.sh
Last active November 14, 2016 21:34
Show the PHP scripts sending email currently in the queue of a postfix server
#!/bin/bash
# This works only if postfix is running. It is complete, but when dealing with large queues due to spam loads,etc., it can take a long time
#mailq |cut -f 1 -d " "|egrep -v "^\(|^$|^-|\*" |xargs postcat -q |grep "X-PHP-Originating-Script"|sort|uniq
# This will work when postfix is not running. It may run faster, but it may also get stuck due to long argument lists.
postcat /var/spool/postfix/maildrop/* |grep "X-PHP-Originating-Script"|sort|uniq
postcat /var/spool/postfix/*/* |grep "X-PHP-Originating-Script"|sort|uniq
postcat /var/spool/postfix/*/*/* |grep "X-PHP-Originating-Script"|sort|uniq
@flickerfly
flickerfly / mysql_uptime.sh
Created October 19, 2016 19:34
Output uptime of mysql in clean and human-readable format
#/bin/sh
# Prints the uptime of mysql
# Optional: Takes one argument for the servername, default is localhost
# Set $host
if [ $1 ]; then
host=$1
else
host="localhost"
### VARIABLES ### \
SERVER=$(hostname)
MYSQL_CHECK=$(mysql -e "SHOW VARIABLES LIKE '%version%';" || echo 1)
SLAVE_STATUS=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G"|grep -v row)
LAST_ERRNO=$(echo "${SLAVE_STATUS}" | grep "Last_Errno:" | awk '{ print $2 }' )
SECONDS_BEHIND_MASTER=$(echo "${SLAVE_STATUS}" | grep "Seconds_Behind_Master:" | awk '{ print $2 }' )
IO_IS_RUNNING=$(echo "${SLAVE_STATUS}" | grep "Slave_IO_Running:" | awk '{ print $2 }' )
SQL_IS_RUNNING=$(echo "${SLAVE_STATUS}" | grep "Slave_SQL_Running:" | awk '{ print $2 }' )
SLAVE_IO_STATE=$(echo "${SLAVE_STATUS}" | grep "Slave_IO_State:" | awk -F':' '{gsub(/^[ \t]+/,"",$2);gsub(/[ \t]+$/,"",$2); print $2 }' )
ERRORS=()
@flickerfly
flickerfly / MySQL Replication Check
Last active February 22, 2022 15:55 — forked from ssimpson89/MySQL Replication Check
Just a simple Mysql Replication Health Check script I wrote. You can put this in a cron.
#!/bin/bash
### VARIABLES ### \
EMAIL=flickerfly@email.com
SERVER=$(hostname)
MYSQL_CHECK=$(mysql -e "SHOW VARIABLES LIKE '%version%';" || echo 1)
SLAVE_STATUS=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G"|grep -v row)
LAST_ERRNO=$(echo "${SLAVE_STATUS}" | grep "Last_Errno:" | awk '{ print $2 }' )
SECONDS_BEHIND_MASTER=$(echo "${SLAVE_STATUS}" | grep "Seconds_Behind_Master:" | awk '{ print $2 }' )
IO_IS_RUNNING=$(echo "${SLAVE_STATUS}" | grep "Slave_IO_Running:" | awk '{ print $2 }' )

Keybase proof

I hereby claim:

  • I am flickerfly on github.
  • I am josiah (https://keybase.io/josiah) on keybase.
  • I have a public key whose fingerprint is 7CB4 B7B7 E9FD 0CC9 F1C7 80EF B368 C6FB 4C9E F4AA

To claim this, I am signing this object:

@flickerfly
flickerfly / OpenVPN_New_User
Created December 9, 2013 15:16
Create a new user and assemble the required files to setup the VPN connection on the client side. First argument on the command line is the username.
#!/bin/sh
user=$1
vpnconf="/etc/openvpn"
rsa="$vpnconf/easy-rsa"
cd $rsa
source vars
./build-key $user
mkdir ~/$user.vpnfiles