We needed this to understand the source of a large influx of requests for a given URI pattern. import splunklib.client as client import splunklib.results as results service = client.connect(host=”*******”,port=”8089″,username=”showard”,password=”************”) job = “”” search host=\”cmhlpecomweb*\” sourcetype=access_combined karlie-kloss | eval temp=split(_raw,\”\t\”) |…
Category: Database
Pushing a file to Oracle database to write to database filesystem
import java.sql.*; import java.io.*; public class sendFile { public static void main (String args[]) throws Exception { File file = new File(“a.txt”); FileInputStream fis = new FileInputStream(file); byte[] data = new byte[(int)file.length()]; fis.read(data); fis.close(); String s = new String(data, “UTF-8”);…
Splunk query for custom Apache access log format
We have a kludgy access log format. It certainly isn’t standard. At any rate, the out of the box transforms.conf can’t handle it. Rather than change that, I elected to split the lines on the fly; not as fast, but…
Searching splunk and analyzing results with PyDbLite
We had a need to analyze how often a web shopper used more than one device to manage her shopping cart within a given time tolerance. We store our Apache access logs in Splunk, so this post is simply a…
Broken out into two routes… Consume web service and enqueuer in ActiveMQ Dequeue from ActiveMQ and persist in PO object in Oracle database <route id=”get-po”> <from uri=”timer://simpleTimer?period=30s”/> <to uri=”http://cmhlcarchapp01:8080/tradestone/send_po.jsp“/> <to uri=”jms:queue:testMQ” /> </route> <route id=”insert-db”> <from…
Query SQL Server XML column for value
Just an example of how to pull this type of value from an embedded XML document in a SQL Server database table column… select top 100 * from Transactions with (nolock) where trn_xml.value(‘(/Transaction/RetailStoreId)[1]’, ‘int’) = 2401
Oracle global temporary table and connection pool
Our question was what happens to the rows in a global temporary table when populated from a session obtained from a connection pool. Are they still there for the next application user to borrow the same session from the pool?…
Oracle materialized view and query rewrite
Just a simple example to show what it takes to get this to work… SQL> set lines 1000 trims on pages 100 SQL> explain plan for select count(*) from member; Explained. SQL> select * from table(dbms_xplan.display()); PLAN_TABLE_OUTPUT ——————————————————————————– Plan hash…
Loading compressed data into MySQL in batches from python
We used what is below to load 12 million rows into a laptop MySQL database in 48 minutes. I’m sure it can be improved, but we were initially OK with this result. import gzip, os, sys, string, mysql.connector fd =…
SQL Server – querying active users by database
use master go declare @table table( spid int, status varchar(max), login varchar(max), hostname varchar(max), blkby varchar(max), dbname varchar(max), command varchar(max), cputime int, diskio int, lastbatch varchar(max), programname varchar(max), …