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 / check_backup.pl
Created August 9, 2012 10:23 — forked from n8v/check_backup.pl
Nagios Plugin for checking a backup file for existence, age and size.
#!/usr/bin/perl
### check_backup.pl
# By Nathan Vonnahme, Sept 2011
# An example for "Writing Custom Nagios Plugins in Perl" at the Nagios
# World Conference North America 2011.
# I. Prologue
@zz
zz / Oauth.php
Created October 14, 2012 15:11
Facbook App review codes
<?php
/**
* This is the model class for table "www_oauth".
*
* The followings are the available columns in table 'www_oauth':
* @property integer $id
* @property integer $user_id
* @property integer $service
* @property string $service_uid
#!/usr/bin/env python2
import re, sys, os, urllib
re_songs = re.compile(r'\'sid\': \'(.+?)\', \'sname\': \'(.+?)\'')
re_name = re.compile(r'\\&.+?;')
template_wgets = 'wget -nv -c -O "%s" %s'
durl = 'http://yinyueyun.baidu.com/data/cloud/downloadsongfile\?songIds\=%s\&rate\=320'
def modified_sname(sname):
sname = sname.replace('\\&#039;', '\'')
@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;
#!/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" ]
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;
@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"'
@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
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" readlater.xxxx@instapaper.com
done
@zz
zz / sendEmail
Created October 21, 2013 10:24
sendEmail used by nagios
#!/usr/bin/perl -w
##############################################################################
## sendEmail
## Written by: Brandon Zehm <caspian@dotconf.net>
##
## 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.