Skip to content

Instantly share code, notes, and snippets.

Avatar

Josiah Ritchie flickerfly

View GitHub Profile
@flickerfly
flickerfly / Get-ServerDNSSettings.ps1
Created Nov 30, 2016
Check the DNS Settings for all Windows Servers
View Get-ServerDNSSettings.ps1
# 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 Nov 30, 2016
List Names of Domain Controllers
View Get-DCbyName.ps1
# 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 Nov 14, 2016
Show the PHP scripts sending email currently in the queue of a postfix server
View list-scripts-sending-mail.sh
#!/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 Oct 19, 2016
Output uptime of mysql in clean and human-readable format
View mysql_uptime.sh
#/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"
View prtg_mysql_replication_sensor.sh
### 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 Mar 25, 2020 — forked from ssimpson89/MySQL Replication Check
Just a simple Mysql Replication Health Check script I wrote. You can put this in a cron.
View MySQL Replication Check
#!/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 }' )
View keybase.md

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 Dec 9, 2013
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.
View OpenVPN_New_User
#!/bin/sh
user=$1
vpnconf="/etc/openvpn"
rsa="$vpnconf/easy-rsa"
cd $rsa
source vars
./build-key $user
mkdir ~/$user.vpnfiles
@flickerfly
flickerfly / zimbra
Created Oct 28, 2013
Zimbra ufw application profile
View zimbra
[Zimbra]
title=Zimbra Collaboration Server
description=Open source server for email, contacts, calendar, and more.
ports=25,80,110,143,443,465,993,995,7071/tcp
@flickerfly
flickerfly / crashplan
Created Oct 28, 2013
CrashPlan ufw firewall profile
View crashplan
[CrashPlan]
title=CrashPlan
description=CrashPlan is a simple and yet powerful backup solution that does not require a central server for management.
ports=4242/tcp