Skip to content

Instantly share code, notes, and snippets.

@tmuth
tmuth / prstat-capture.sh
Created July 12, 2016 20:48
Capture prstat CPU data for Oracle user on Solaris and write to a file
#!/bin/bash
# parameter 1 is the name of the test
prstat -m -s cpu -u oracle | nawk '$1=="PID" { "date" | getline d ; close("date") } { print d,$0 }' | tee $1
@tmuth
tmuth / enable-threads-loop.sh
Created July 12, 2016 20:46
Enable 1 thread at a time in solaris
#!/bin/bash
# pass in the name of the test as parameter 1
SLEEP_TIME=1800
THREADS=97-111
ALL_THREADS=96-111
#THREADS=96-111
psradm -f $THREADS
psrinfo $ALL_THREADS
# This script will retrieve the latest version of splunk enterprise.
# Edit the filterString to include only the platform you need.
#filterString = ['windows', 'x86_64'] # Windows x64 RPM
filterString = ['linux', 'x86_64'] # Linux x64
#filterString = ['x86_64'] # all x64 platforms
#filterString = ['linux', 'x86_64', '.rpm'] # Linux x64 RPM
#filterString = ['linux', 'x86_64', '.deb'] # Linux x64 deb
import requests
create or replace procedure log_splunk_plugin(
p_rec in logger.rec_logger_log)
as
l_text logger_logs.text%type;
l_module varchar2(50);
v_body CLOB;
v_result CLOB;
l_splunk_hec_token varchar2(64) := 'F3C63E53-1EDA-4DF4-80F8-6BD5B047069A';
begin
dbms_output.put_line('In Plugin');
@tmuth
tmuth / check-sys-stats.sql
Created July 21, 2015 21:07
Check for valid stats on sys schema, specifically WRM$_SNAPSHOT table
declare
l_stat_rows number := 1;
l_last_analyzed_days number:= 0;
l_last_analyzed_threshold constant number:= 60;
l_actual_rows number;
l_pct_change number := 0;
begin
select nvl(NUM_ROWS,1) nrows,round(sysdate - S.LAST_ANALYZED) last_analyzed_days
into l_stat_rows,l_last_analyzed_days from sys.DBA_TAB_STATISTICS s where owner = 'SYS' and table_name = 'WRM$_SNAPSHOT';
# http://cran.r-project.org/web/packages/ROracle/index.html
# http://www.inside-r.org/node/48947
library(ROracle)
library(data.table)
library(stringr)
library(dplyr)
library(ggplot2)
library(scales)
library(reshape2)
library(ggthemes)
@tmuth
tmuth / px.sql
Created February 17, 2015 21:24
alter session file to set parallelism
set define "&" concat "."
set serveroutput on verify off echo off;
column PX_DEGREE_IN noprint new_value PX_DEGREE_NUM
column PX_LOCAL_IN noprint new_value PX_LOCAL
accept PX_DEGREE prompt 'Parallel Degree for Query, DML and DDL. Append an L to set parallel_force_local=true: '
select
regexp_replace('&PX_DEGREE','([[:digit:]]+).*','\1') PX_DEGREE_IN,
@tmuth
tmuth / gist:a811151014b84030cc96
Created February 13, 2015 22:50
single-row vs array update
-- row by row
for c1 in (select rowid rid, YEAR1,
QUARTER,
...
from flights_400k
)
loop
-- moderately complex PL/SQL logic
update flights_400k
set DEPARTUREDELAYGROUPS = l_group,
@tmuth
tmuth / gist:e036bdd65f730c8110aa
Created February 11, 2015 15:59
dplyr group_by needs ungroup() to get expected behavior
DF_SQL_BY_SNAPID.top_sql.sd.elap <- DF_SQL_BY_SNAPID %>%
group_by(PARSING_SCHEMA_NAME,SQL_ID,COMMAND_NAME) %>%
summarise(
elapsed.avg=mean(ELAP_S),
elapsed.stddev=sd(ELAP_S)
) %>%
ungroup() %>%
arrange(desc(elapsed.stddev)) %>%
head(30)
@tmuth
tmuth / pandoc-ant.xml
Created November 10, 2014 19:14
Pandoc Ant Task to Convert github README.md to local readme.html
<macrodef name="pandoc-convert">
<attribute name="input" />
<attribute name="output" />
<sequential>
<exec executable="pandoc" dir=".">
<arg line="--from=markdown_github " />
<arg line="--standalone" />
<arg line="-o @{output}" />
<arg line="@{input}" />
</exec>