Skip to content

Instantly share code, notes, and snippets.

View LukeMurphey's full-sized avatar

Luke LukeMurphey

View GitHub Profile
@LukeMurphey
LukeMurphey / slideInPanel.js
Last active August 29, 2015 14:01
A chunk of Javascript that allows you to replace a panel on a page with another one and slide the panel in from the right (or left if going backwards)
/**
* Slide in a panel and slide out the old one.
*/
function slideInPanel(cur_el, next_el, forward){
// This is the speed of the animation. This should be a sane default.
var speed = 200;
//Define the CSS for the difference between the height and position
var cur = {
@LukeMurphey
LukeMurphey / basebuild.xml
Last active September 26, 2022 17:19
A basic Ant build file that contains targets useful for building Splunk apps that managed with Git. Tags: #splunk
<!--
This Ant build script contains operations that are useful for building Splunk apps from source-code.
See the following page for some more documentation: https://github.com/LukeMurphey/splunk-ant-build-script/blob/master/README.md
This is licensed under the Apache License Version 2.0
See https://www.apache.org/licenses/LICENSE-2.0.html
To use it with you app, do the following:
@LukeMurphey
LukeMurphey / macros.conf
Created February 22, 2015 00:12
Splunk readable duration macro Tags: #splunk
# readable_duration
# -----------------------------
# makes a human readable description of a duration
#
[readable_duration(2)]
args = sourceField,destField
definition = eval $destField$ = case( $sourceField$ > (2*86400), round(($sourceField$) / (86400)) . " days", $sourceField$ > (2*3600), round(($sourceField$) / (3600)) . " hours", $sourceField$ > (2*60), round(($sourceField$) / (60)) . " minutes", $sourceField$ > 0, $sourceField$ . " seconds" )
iseval = 0
@LukeMurphey
LukeMurphey / tabs.js
Last active February 9, 2017 18:19
Some Javascript that will enable using tabs in Splunk views #splunk
require(['jquery','underscore','splunkjs/mvc', 'bootstrap.tab', 'splunkjs/mvc/simplexml/ready!'],
function($, _, mvc){
/**
* The below defines the tab handling logic.
*/
// The normal, auto-magical Bootstrap tab processing doesn't work for us since it requires a particular
// layout of HTML that we cannot use without converting the view entirely to simpleXML. So, we are
// going to handle it ourselves.
@LukeMurphey
LukeMurphey / tabs.css
Created March 28, 2015 06:58
CSS for views that use tabs on Splunk dashboards #splunk
#tabs{
border-bottom: 0px;
}
#tabs > .dashboard-cell > .dashboard-panel{
margin-bottom: 0px;
border-bottom: 0px;
}
#element1 > .html{
@LukeMurphey
LukeMurphey / notable_edit_example.py
Last active May 26, 2023 13:34
An example of how to edit notable events using the REST API in the Enterprise Security app for Splunk. #splunk
import splunk
import json
def updateNotableEvents(sessionKey, comment, status=None, urgency=None, owner=None, eventIDs=None, searchID=None):
"""
Update some notable events.
Arguments:
sessionKey -- The session key to use
comment -- A description of the change or some information about the notable events
define([
"underscore",
"backbone",
"splunkjs/mvc",
"jquery",
"splunkjs/mvc/simplesplunkview",
'text!../app/CHANGEME/js/templates/CHANGEMEView.html', // CHANGE_THIS: Modify the path to use a template
"css!../app/CHANGEME/css/CHANGEMEView.css" // CHANGE_THIS: Modify the path to use a stylesheet
], function(
_,
@LukeMurphey
LukeMurphey / ConditionalSplunkDashboardLoad.js
Created September 15, 2015 21:27
Illustrates how to conditionally load dashboard.js in Splunk #Splunk
require([
"splunkjs/mvc",
"underscore",
"jquery",
"splunkjs/mvc/utils"
],
function(
mvc,
_,
$,
// ==UserScript==
// @name Splunk AutoLogin
// @namespace http://127.0.0.1:8000/en-US/account/login*
// @description Automatically logs into Splunk
// @include http://127.0.0.1:8000/en-US/account/login*
// @include https://127.0.0.1:8000/en-US/account/login*
// @include */en-US/account/login*
// ==/UserScript==
function splunkLogin(){
@LukeMurphey
LukeMurphey / modular_alert.py
Last active January 9, 2019 21:23
This is a base class that makes the creation of a Splunk modular alert easier. #splunk
import logging
from logging import handlers
import traceback
import sys
import re
import os
import json
import socket # Used for IP Address validation
from splunk.appserver.mrsparkle.lib.util import make_splunkhome_path