Skip to content

Instantly share code, notes, and snippets.

View ashokarun's full-sized avatar
👋

Arunlal A ashokarun

👋
View GitHub Profile
@ashokarun
ashokarun / gist:8c6cbae2266dc03a5d600700b0d2d6f5
Created October 1, 2017 08:43
Bulk database user password script
#!/bin/sh
echo "This script is useful for only commonly using CMSs like WP, Joomla, Drupal, Magento, Drupal etc with known configuration location. If nothing listing and you are getting db conntction error check configuration manually.. Thanks by Arunlal"
echo "" > details.txt
echo "Please enter the cPanel username: "
read username
grep -irl ${username}_ /home/$username/*{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php /home/$username/*/{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php /home/$username/*/*/{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php 2>/dev/null grep -v -E "mail|error_log|sql|html|var">> ${username}confs.txt
var=`cat ${username}confs.txt`
if [ -n "$var" ]; then
for i in `cat ${username}confs.txt`; do echo $i >> details.txt; grep -E "DB_USER|user|username|DB_PASSWORD|secret|password" $i |grep -v -E "cookies|generate"
@ashokarun
ashokarun / gist:7a5f697d3f71f243372b6526fccc810a
Created October 1, 2017 16:37
To backup all the databases in the server as separate individual sql files
#!/bin/bash
#Author : Arunlal A
#Website: https://www.crybit.com
echo "Staring database backup process..."
for db in `echo 'show databases;' |mysql |grep -Ev "Database|information_schema|performance_schema"`; do mysqldump $db | gzip > /backup/$db.sql.gz ;done
echo "Done! Check /backup/ directory for your SQL files."
@ashokarun
ashokarun / gist:fef83b5949057187c1723597247155b6
Created October 1, 2017 16:56
Script to kill all MySQL processes for database user
#!/bin/bash
#Author : Arunlal A
#Website: https://www.crybit.com
echo -n "Enter databse user name: "
read THEUSER
skill -9 -u $THEUSER ; for i in `mysqladmin processlist | grep $THEUSER | awk '{print $2}'` ; do mysqladmin kill $i ; done ; echo "$THEUSER has been killed!"
# Automated AMI Backups
#
# @author Robert Kozora <[email protected]> [I made some changes.]
#
# This script will search for all instances from all region and
# as soon as we have the instances list, we loop through each instance
# and create an AMI of it. Also, it will look for a "Retention" tag key which
# will be used as a retention policy number in days. If there is no tag with
# that name, it will use a 7 days default value for each AMI.
#
# Automated AMI and Snapshot Deletion
#
# @author Robert Kozora <[email protected]> [I made some changes]
#
# This script will search for all instances having a tag with "Backup" or "backup"
# on it. As soon as we have the instances list, we loop through each instance
# and reference the AMIs of that instances which has backup tag as "filter_date_fmt" variable value.
# We check that the latest daily backup
# succeeded then we store every image that's reached its DeleteOn tag's date for
# deletion. We then loop through the AMIs, deregister them and remove all the
@ashokarun
ashokarun / gist:83db353f82c7637a46f3b040a4aa70f5
Last active July 31, 2021 19:49
Dump Mongo DB and move it to an S3 bucket.
#!/bin/bash
# This will create a full db dump and store it to s3 bucket my-db-backup-bucket in folder full-db-backup
# You can modify all variables as you wish
# Here we are making dump to /data/database-backup/ make sure that the directory is there.
# Here we're not keeping dumps locally.
echo "Enter DB name: "
read db
echo "removing current backups from /data/database-backup/"
#!/usr/bin/python3.6
# This script call the prometheus target API and check the status of target's status.
# If it found any down in targets it will append failed_hosts list and print it with exit code 2
# Auther: arunlal.a
# Importing modules
import json
import requests
import collections
import sys
@ashokarun
ashokarun / gist:0997ca58be24f3b4baa6fb5750d21bb4
Last active July 27, 2021 09:24
Find LAG on Kafta topics
#!/bin/python3
import sys
import socket
import kafka
"""
Variables defined
"""
TOPICS = ['topic1', 'topic2']