Skip to content

Instantly share code, notes, and snippets.

@sheeplogh
sheeplogh / long_delete-update-merge_query_with_qc_info.sql
Created November 7, 2017 07:54
[long_delete-update-merge_query_with_qc_info.sql] Display DELETE / UPDATE / MERGE running for more than 30 minutes (with SID / serial of parallel coordinator process) #Oracle
select sql_exec_start,username,machine,module,program,
(select px.QCSID||','||px.QCSERIAL# ||',@'||px.QCINST_ID from gv$px_session px where px.sid=vs.sid and px.serial#=vs.serial#) as QC_info,
(select substr(sql_text,1,80) from gv$sql vsql where vsql.sql_id = vs.sql_id and rownum = 1) as SQLTEXT
from v$session vs
where
vs.sql_exec_start < SYSDATE - 1 / 48
and
EXISTS (
SELECT
1
@sheeplogh
sheeplogh / swapsize_per_proc_2.pl
Created May 26, 2016 08:40
Linuxでプロセス毎のswapsizeを表示する( http://www.maepachi.com/blog/entry/130 を元に小改造させていただきました)
#!/bin/env perl
# pachi
#
# This script find out process currently swapped by /proc/$PID/status
use strict;
use warnings;
# When you want to debug, you should exec "export SCRIPT_DEBUG=1".
my $debug = $ENV{SCRIPT_DEBUG} ? 1 : 0;
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget.
### You can download all the binaries one-shot by just giving the BASE_URL.
### Script might be useful if you need Oracle JDK on Amazon EC2 env.
### Script is updated for every JDK release.
## Features:-
# 1. Resumes a broken / interrupted [previous] download, if any.
# 2. Renames the file to a proper name with including platform info.
# 3. Downloads the following from Oracle Website with one shell invocation.
# a. Windows 64 and 32 bit;
@sheeplogh
sheeplogh / gist:8cc3dcf285c64c462bb5
Last active August 29, 2015 14:21
[Oracle] Monitoring Parallel Execution Performance
-- Monitoring parallel execution
-- http://www.oracle.com/technetwork/jp/database/enterprise-edition/db11gr2-12-130999-ja.pdf
select status, queuing_time, sql_id, SQL_EXEC_START, SQL_EXEC_ID from gv$sql_monitor where sql_text is not null order by SQL_EXEC_START;
select * from gv$sql_monitor
where STATUS = 'EXECUTING' order by SQL_EXEC_START;
<Location />
### COMPRESS EVERYTHING EXCEPT IMAGES >> ###
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
@sheeplogh
sheeplogh / gist:7701112
Last active December 29, 2015 16:59
count hits of some URLs per day from access_log
#!/bin/sh -e
TODAY=`date +%Y%m%d`
if [ $# -eq 1 ]
then
TARGET_DATE=$1
else
TARGET_DATE=`date -d "1 day ago" +%Y%m%d`
@sheeplogh
sheeplogh / get_connections_from_accesslog.pl
Created October 16, 2013 08:52
ApacheのCombined + %D 形式のアクセスログから1秒毎の同時接続数を集計するスクリプト。 タイムスタンプを接続が開始された時刻とみなして、%D の間は接続が維持されているものとする。 結果はあくまで参考値。 スクリプトと同じディレクトリに access_log をおいてから実行する。
#!/usr/bin/perl
###
### ApacheのCombined + %D 形式のアクセスログから1秒毎の同時接続数を集計するスクリプト。
### タイムスタンプを接続が開始された時刻とみなして、%D の間は接続が維持されているものとする。
### 結果はあくまで参考値。
### スクリプトと同じディレクトリに access_log をおいてから実行する。
###
use strict;
@sheeplogh
sheeplogh / maintenance.conf
Last active December 16, 2015 02:09
apache conf for display maintenance page with 503. (for VirtualHost context)
ExpiresActive On
ExpiresDefault A0
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
ErrorDocument 503 /maintenance/index.html
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/maintenance/.*$
RewriteRule ^.*$ - [R=503,L]
@sheeplogh
sheeplogh / akamai_esw3c_2_combined.sh
Created April 9, 2013 10:57
Akamai's standard log format (esw3c (W3c–style) Log Format) to combined(JST)
#!/bin/sh
LANG=C
/bin/gawk -F"\t" '$0 !~ /^#/ {
## make epochtime from timestamp
split($1, d, "-");
split($2, t, ":");
timestamp=d[1]" "d[2]" "d[3]" "t[1]" "t[2]" "t[3];
epochtime=mktime(timestamp);
@sheeplogh
sheeplogh / gist:4379059
Last active December 10, 2015 04:08
[shell] Get network throughput (Mbps, Average 10 minutes) on Linux machines from sar.
## Rx
$ LANG=C sudo sar -n DEV | grep eth0 | grep -v Average | awk '{print $1, $5*8/1048576}'
## Tx
$ LANG=C sudo sar -n DEV | grep eth0 | grep -v Average | awk '{print $1, $6*8/1048576}'
# Ex.
$ LANG=C sudo sar -n DEV -f /var/log/sa/sa24 | grep eth0 | grep -v Average | awk '{print $1, $6*8/1048576}'
...
23:20:01 4.32473