This project provides API endpoints to get my often-used scripts.
Hosted on HEROKU:
Script Endpoint: https://scripts.mahirchavda.com/<script_name>
Currently available script_names are:
install_miniconda: https://scripts.mahirchavda.com/install_miniconda
- returns the bash commands to install miniconda
Example to install miniconda
curl https://scripts.mahirchavda.com/install_miniconda | bash
splunk_alias: https://scripts.mahirchavda.com/splunk_alias
- returns the alias for often used splunk cli commands
To configure the alias run below command in your linux shell:
curl 'https://scripts.mahirchavda.com/splunk_alias' >> ~/.bashrc && source ~/.bashrc
Splunk cli commands and it's alias
Purpose | Splunk CLI command | Splunk alias |
---|---|---|
Restart Splunk | /opt/splunk/bin/splunk restart | rr |
Start/Stop/Restart Splunk | /opt/splunk/bin/splunk start/stop/restart | sp start/stop/restart |
cd into the Splunk apps folder | cd /opt/splunk/etc/apps | app |
cd into the Splunk log folder | cd /opt/splunk/var/log/splunk | log |
cd into Splunk modinput folder | cd /opt/splunk/var/lib/splunk/modinputs | modinput |
To just clean eventdata | /opt/splunk/bin/splunk clean eventdata -f | sclean |
To clean all the indexed eventdata; we have to perform below steps: 1) stop splunk 2) clean indexes data 3) start splunk |
1) /opt/splunk/bin/splunk stop 2) /opt/splunk/bin/splunk clean eventdata -f 3) /opt/splunk/bin/splunk start |
ssclean |
To clean all the indexed eventdata, remove logs and remove modinputs; we have to perform below steps: 1) stop splunk 2) clean indexes data 3) cd into log folder and remove all files 4) cd into modinput folder and remove all files 5) start splunk |
1) /opt/splunk/bin/splunk stop 2) /opt/splunk/bin/splunk clean eventdata -f 3) cd /opt/splunk/var/log/splunk && rm -rf * 4) cd /opt/splunk/var/lib/splunk/modinputs && rm -rf * 5) /opt/splunk/bin/splunk start |
sssclean |
1) Stop Splunk 2) Navigate to the Splunk log folder 3) Delete all files and folder 4) Navigate to the Splunk modinput folder 5) Delete all files and folder 6) Clean all the indexed data 7) Navigate to the Splunk apps folder 8) Remove Splunk_TA_cisco-ucs app 9) Start Splunk |
1) /opt/splunk/bin/splunk stop 2) cd /opt/splunk/var/log/splunk 3) rm -rf * 4) cd /opt/splunk/var/lib/splunk/modinputs 5) rm -rf * 6) /opt/splunk/bin/splunk clean eventdata -f 7) cd /opt/splunk/etc/apps 8) rm -rf Splunk_TA_cisco-ucs 9) /opt/splunk/bin/splunk start |
sp stop && log && rm -rf * && modinput && rm -rf * && sclean && app && rm -rf Splunk_TA_cisco-ucs && sp start |
The splunk_alias endpoint also supports two parameters: splunk_home and alias_suffix
param | default value | description |
---|---|---|
splunk_home | "/opt/splunk" | specify splunk home path |
alias_suffix | "" | specify suffix if you have mulitple splunk installed and you want to configure splunk alias for both the splunk |
Example:
$ curl 'https://scripts.mahirchavda.com/splunk_alias?splunk_home=/opt/splunk2&alias_suffix=2' >> ~/.bashrc && source ~/.bashrc
API Response:
### START splunk_alias
# Make Splunk CLI Commands Shorter
sp2_home="/opt/splunk2"
export sp2_home
alias sp2="$sp2_home/bin/splunk"
alias log2="cd $sp2_home/var/log/splunk"
alias modinput2="cd $sp2_home/var/lib/splunk/modinputs"
alias app2="cd $sp2_home/etc/apps"
alias rr2="sp2 restart"
alias sclean2="sp2 clean eventdata -f"
alias ssclean2="sp2 stop && sclean2 && sp2 start"
alias sssclean2="sp2 stop && sclean2 && log2 && rm -rf * && modinput2 && rm -rf * && sp2 start"
### END splunk_alias