Skip to content

Instantly share code, notes, and snippets.

@sheeplogh
sheeplogh / gist:3421464
Created August 22, 2012 02:06
grep an accesslog(apache) file within a specific time period
$ cat ACCESS_LOG | awk '$4 >= "[29/Jan/2012:12:00:00" && $4 < "[29/Jan/2012:13:00:00"'
@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;
<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
@sheeplogh
sheeplogh / gist:4372179
Created December 25, 2012 07:59
get total bytes transferred in MB from apache accesslog.
$ cat ACCESS_lOG | awk '{bytes = bytes + $10} END {print bytes/1048576}'