Skip to content

Instantly share code, notes, and snippets.

View nirbhabbarat's full-sized avatar
🎯
Focusing

Nirbhab Barat nirbhabbarat

🎯
Focusing
  • Gurgaon
View GitHub Profile
@nirbhabbarat
nirbhabbarat / aws_cost_leak.py
Created February 12, 2018 17:18
find out idle_elb, idle_rds_instances, underutilized_ebs_volume, legacy_instance_type, low_utilization_ec2, idle_eip
#!/usr/bin/python
#This script is useful for reducing the unnecessary cost inccured while using AWS
#It checks
#1.for all the idle load balancers in your account
#2.Checks the number of RDS connections in the past 1 week
#3.Identifies all the idle EBS Volumes
#4.Checks for all the Legacy instances which are being used
#5.Checks whether the ec2 instances are being fully utilised or not
#6.Checks all the unassociated Elastic IP's
@nirbhabbarat
nirbhabbarat / aws_delete_ami_boto3.py
Created February 9, 2018 06:56
Delete/Deregister 30 days old AMI in AWS using boto3 and python
#!/usr/bin/env python
##### USE ON YOUR OWN RISK - THIS IS GOING TO DEREGISTER AMI OLDER THAN 30 DAYS
import boto3
from dateutil.parser import parse
import datetime
age = 30
aws_profile_name = 'prod'
def days_old(date):
get_date_obj = parse(date)
@nirbhabbarat
nirbhabbarat / monitor_and_restart_rabbitmq.sh
Created February 4, 2018 03:16
Check rabbitmq is running or not, else restart and send customer message to slack, email, sms or phone call API
#!/bin/bash
# port 15672 belongs to rabbitmq management portal, if not enabled use below command.
# rabbitmq-plugins enable rabbitmq_management
# guest:guest replace it with username:password of rabbitmq readonly user
status=$(curl -s -o /dev/null -w "%{http_code}" localhost:15672/api/overview --user guest:guest)
if [ $status = "200" ]; then
wget "https://packages.chef.io/files/stable/chef-server/12.14.0/el/6/chef-server-core-12.14.0-1.el6.x86_64.rpm"
rpm -Uvh chef-server-core-12.14.0-1.el6.x86_64.rpm
chef-server-ctl reconfigure
chef-server-ctl install chef-manage
chef-server-ctl reconfigure
chef-manage-ctl reconfigure
@nirbhabbarat
nirbhabbarat / percona56.sh
Last active August 29, 2015 14:03
Percona Server 5.6 installation on Centos 6.5
rpm --nodeps -e mysql-libs percona-xtrabackup-20
rpm -qa | grep percona-release-0.0-1* || rpm -ivh http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm
yum -y install perl-DBD-MySQL perl-DBI
yum -y install Percona-Server-client-56 Percona-Server-devel-56 Percona-Server-server-56 Percona-Server-shared-56 percona-xtrabackup percona-toolkit
touch /var/log/mysql-slow.log
chown mysql.mysql /var/log/mysql-slow.log
chmod 755 /var/log/mysql-slow.log