Last active
May 24, 2020 11:41
-
-
Save mahirchavda/bb98ad0a4962fada4a408bfe596ce267 to your computer and use it in GitHub Desktop.
Make Splunk CLI Commands Shorter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: mahirchavda | |
# Live on : https://repl.it/@MahirChavda/WTF | |
# To Make Splunk CLI Commands Shorter run below command in terminal for linux or in git bash for windows | |
# command: curl "http://wtf.mahirchavda.repl.co/splunk_alias/?splunk_home=/opt/splunk&alias_suffix=" >> ~/.bashrc && source ~/.bashrc | |
from flask import Flask, request | |
from threading import Thread | |
app = Flask('') | |
@app.route('/') | |
def home(): | |
return """<title>wtf!</title><style>.fun{font-family:cursive;font-style: italic;font-weight:bold;font-size:xx-large;}</style><center style="margin-top:47px;" class="fun">wtf!</center>""" | |
@app.route('/splunk_alias/') | |
def splunk_alias(): | |
return ( | |
"""# Make Splunk CLI Commands Shorter | |
sp{alias_suffix}_home="{splunk_home}" | |
export sp{alias_suffix}_home | |
alias sp{alias_suffix}="$sp{alias_suffix}_home/bin/splunk" | |
alias log{alias_suffix}="cd $sp{alias_suffix}_home/var/log/splunk" | |
alias modinput{alias_suffix}="cd $sp{alias_suffix}_home/var/lib/splunk/modinputs" | |
alias app{alias_suffix}="cd $sp{alias_suffix}_home/etc/apps" | |
alias rr{alias_suffix}="sp{alias_suffix} restart" | |
alias sclean{alias_suffix}="sp{alias_suffix} clean eventdata -f" | |
alias ssclean{alias_suffix}="sp{alias_suffix} stop && sp{alias_suffix} clean eventdata -f && sp{alias_suffix} start" | |
""").format(splunk_home=request.args.get("splunk_home", "/opt/splunk"), alias_suffix=request.args.get("alias_suffix", "")) | |
def run(): | |
app.run(host='0.0.0.0',port=8080) | |
def keep_alive(): | |
t = Thread(target=run) | |
t.start() | |
if __name__ == '__main__': | |
keep_alive() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment