Skip to content

Instantly share code, notes, and snippets.

View zz's full-sized avatar
💭
I may be slow to respond.

ZZ zz

💭
I may be slow to respond.
  • Japan
View GitHub Profile
@zz
zz / gevent_ssl_patch.py
Created December 30, 2014 13:11
gevent ssl.py patch for python 2.7.9
# Re-add sslwrap to Python 2.7.9
import inspect
__ssl__ = __import__('ssl')
try:
_ssl = __ssl__._ssl
except AttributeError:
_ssl = __ssl__._ssl2
@zz
zz / rename.pl
Created November 14, 2014 12:19
rename script for perl user
#!/usr/bin/perl -w
#
# This script was developed by Robin Barker ([email protected]),
# from Larry Wall's original script eg/rename from the perl source.
#
# This script is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# Larry(?)'s RCS header:
# RCSfile: rename,v Revision: 4.1 Date: 92/08/07 17:20:30
# Nginx can serve FLV/MP4 files by pseudo-streaming way without any specific media-server software.
# To do the custom build we use 2 modules: --with-http_secure_link_module --with-http_flv_module
# This module "secure-link" helps you to protect links from stealing away.
#
# NOTE: see more details at coderwall: http://coderwall.com/p/3hksyg
cd /usr/src
wget http://nginx.org/download/nginx-1.5.13.tar.gz
tar xzvf ./nginx-1.5.13.tar.gz && rm -f ./nginx-1.5.13.tar.gz
@zz
zz / sendEmail
Created October 21, 2013 10:24
sendEmail used by nagios
#!/usr/bin/perl -w
##############################################################################
## sendEmail
## Written by: Brandon Zehm <[email protected]>
##
## License:
## sendEmail (hereafter referred to as "program") is free software;
## you can redistribute it and/or modify it under the terms of the GNU General
## Public License as published by the Free Software Foundation; either version
## 2 of the License, or (at your option) any later version.
curl --socks5 127.0.0.1:7070 http://cn.nytimes.com/ 2>/dev/null | grep -o '<a href="[^"]\+" title="[^"]\+"' | sed -e 's/<a href="//g' | sed -e 's/" title="/ /g' | sed -e 's/"//g' | while read url title
do if [[ ${url:0:5} != "http:" ]]
then
url="http://cn.nytimes.com$url"
fi
echo $url | mail -s "$title" [email protected]
done
@zz
zz / gist:7003070
Created October 16, 2013 05:34
Nagio oracle check no primary key tables
Select tables.owner || '.' ||
tables.table_name
as table_owner
From all_tables tables,
(Select
owner,
TABLE_NAME,
constraint_type,
CONSTRAINT_NAME
FROM ALL_CONSTRAINTS
@zz
zz / gist:6987717
Created October 15, 2013 07:10
Create Nagios user
declare @dbname varchar(255)
declare @check_mssql_health_USER varchar(255)
declare @check_mssql_health_PASS varchar(255)
declare @check_mssql_health_ROLE varchar(255)
declare @source varchar(255)
declare @options varchar(255)
declare @backslash int
/*******************************************************************/
SET @check_mssql_health_USER = '"[Servername|Domainname]\nagios"'
select sql.last_load_time, sql.elapsed_time/1000000, sql.sql_text from v$sql sql where sql.last_load_time>to_char(systimestamp - INTERVAL '1' HOUR, 'YYYY-MM-DD/HH24:MI:SS') and sql.elapsed_time > 1000000 * 60 order by sql.elapsed_time desc;
#!/bin/sh
DB_USER="root"
DB_PASS="123456"
DB_NAME="blog"
LOG_PATH="/data/db/errlog.log"
TIME=`date +%Y-%m-%d" "%H:%M:%S`
TABLES=`/usr/bin/awk '/'"repair failed"'/ {print $6}' $LOG_PATH | sort -k1n | uniq -c | awk -F "'" '{print $2}' | awk -F '/' '{print $3}'`
if [ -n "$TABLES" ]
@zz
zz / orcl_find_sid_by_pid.sql
Created April 9, 2013 04:06
Find oracle database session ID using OS PID
SELECT a.sid,
b.spid
FROM v$session a,
v$process b
WHERE A.paddr = b.addr
AND b.spid = 41484400;