Skip to content

Instantly share code, notes, and snippets.

# 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 / 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';
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');
# 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
@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
@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 / orcl-1-row-json.sql
Created June 26, 2017 21:47
Oracle get 1 row as JSON
SELECT regexp_replace(xml3,'(.+),.+$','{\1}',1,1,'n') xml4
FROM
(SELECT regexp_replace(xml2,'<(\w+)>(.+)</\1>','"\1" : "\2",',1,0,'n') xml3
FROM
(SELECT regexp_replace(xml,'(^.+<ROW>)(.*)(</ROW>.*)','\2',1,1,'n') xml2
FROM
(SELECT dbms_xmlgen.getXML('SELECT * from soe.customers where rownum=1') xml
FROM dual
)
)
@tmuth
tmuth / docker_exec.sh
Last active September 12, 2024 21:13
"Docker exec -it $1 bash" bash function for attaching to a running container
function docker_exec {
name="${1?needs one argument}"
containerId=$(docker ps | awk -v app="$name" '$2 ~ app{print $1}')
if [[ -n "$containerId" ]]; then
docker exec -it $containerId bash
else
echo "No docker container with name: $name is running"
fi
}
@tmuth
tmuth / export-splunk-apps.sh
Last active December 4, 2017 16:02
Export splunk apps out of docker containers
function get_container_id {
name="${1?needs one argument}"
containerId=$(docker ps | awk -v app="$name" '$2 ~ app{print $1}')
if [[ -n "$containerId" ]]; then
echo ${containerId}
else
echo "No docker container with name: $name is running"
fi
}
@tmuth
tmuth / docker-bash.sh
Created March 6, 2018 19:21
Docker-Bash-Functions
function docker_exec {
name="${1?needs one argument}"
containerId=$(docker ps | awk -v app="$name" '$2 ~ app{print $1}')
if [[ -n "$containerId" ]]; then
docker exec -it $containerId bash
else
echo "No docker container with name: $name is running"
fi
}