• Stars
    star
    169
  • Rank 224,453 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created about 8 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Like `du` but for S3

s3_disk_util

  • What -- A tool that allows a user to visualize which buckets (and parts of buckets) are using the most data storage.
  • Why -- Because I'm trying to pare down my S3 bill, and the S3 control panels (even CloudWatch) do not really provide anything similar.
  • Inspiration -- This script is meant to be like the du tool for linux, except for inspecting the disk usage of s3 buckets.
  • How -- It will traverse s3 buckets and provide high level disk usage information to stdout.

Usage

% python3 du.py --help
usage: du.py [-h] [-b BUCKET] [-p PROFILE] [-d DEPTH] [-di DIR]

This script is meant to be like the `du` tool for linux, except for inspecting
the disk usage of s3 buckets. It will traverse s3 buckets and provide high
level disk usage information to stdout.

optional arguments:
  -h, --help            show this help message and exit
  -b BUCKET, --bucket BUCKET
                        Bucket to examine (ex: 'com.owocki.assets')
  -p PROFILE, --profile PROFILE
                        AWS credentials profile name (default: 'default')
  -d DEPTH, --depth DEPTH
                        Depth to examine bucket (ex: 4)
  -di DIR, --dir DIR    Directory to examine (ex: 'logs/')

Example

% python3 du.py --depth=1 --bucket=BUCKETNAME --profile=mytestaccount
BUCKETNAME
(Cloudwatch bucket size estimate: 22.7GiB)
  / : 22.7GiB
 - DIR1/ : 22.6GiB
 - DIR2/ : 452.6KiB
 - DIR3/ : 1.6MiB
 - DIR4/ : 119.0MiB
 - DIR5/ : 0.0B

% python3 du.py --depth=2 --bucket=BUCKETNAME
BUCKETNAME
(Cloudwatch bucket size estimate: 22.7GiB)
  / : 22.7GiB
 - DIR1/ : 22.6GiB
 -- DIR1/SUBDIR1/ : 31.1MiB
 -- DIR1/SUBDIR2/ : 12.7GiB
 -- DIR1/SUBDIR3/ : 0.0B
 -- DIR1/SUBDIR4/ : 9.9GiB
 - DIR2/ : 452.6KiB
 -- DIR2/SUBDIR1/ : 429.5KiB
 - DIR3/ : 1.6MiB
 -- DIR3/SUBDIR1/ : 254.4KiB
 - DIR4/ : 119.0MiB
 - DIR5/ : 0.0B

Setup

  1. Create an AWS IAM user account at (https://console.aws.amazon.com/iam/home).
    • Make sure your user has AmazonS3FullAccess and CloudWatchReadOnlyAccess policies.
  2. Use your existing ~/.aws/credentials file and profile names or create a config file that looks like this:
% cat ~/.aws/credentials

[default]
aws_access_key_id = ACCESS_KEY_GOES_HERE
aws_secret_access_key = SECRET_KEY_GOES_HERE
region=REGION
  1. Clone this repo.
  2. Install python3 (if needed) and boto3 (if needed).
    • To install python3, instructions differ depending upon your OS. Using Homebrew is probably the easiest (brew install python3), or here are some instructions for Mac OS X
    • To install boto3, pip install -r requirements.txt
  3. Run du.py with the usage described above.

What else

This script can run a little slow on larger buckets. Thats okay; This is a limitation inherent to the way this information is provided via AWS APIs. Pipe du.py's' output to a file (perhaps inside of a screen or tmux) and come back later.

More Repositories

1

pytrader

cryptocurrency trading robot
Python
1,932
star
2

adblock-to-bitcoin

A project that turns ads into bitcoin donation solicitations when adblock is enabled
JavaScript
183
star
3

Interview_prep_checklist

This is a work-in-progress interview prep sheet that I started whilst job hunting for web development jobs in July 2013
93
star
4

emojibot

Slack bot that adds custom emojis to your team; *inline in Slack*. No more putzing around in your web browser.
Python
38
star
5

mindhacking

cliffs notes on various mind hacking things i've learned
32
star
6

quotify

Quotify: A python library for creating inspirational quote images
Python
28
star
7

slack_gamebot

A python gamebot for slack.
Python
22
star
8

agile_a_la_carte

An agile reference for organizations that are problem, not process, oriented.
18
star
9

coloradocoin

A Corporeal CryptoCoin for Coloradians
JavaScript
17
star
10

web3_revenue_primitives

17
star
11

DecentralizationLayerCake

Decentralization Across the Stack
6
star
12

markov_playground

A playground for me to do some markov bot things.
Python
4
star
13

gpu_mining_munin_plugins

Munin Plugins for monitoring a GPU mining rig
Shell
3
star
14

TOSAmend

The easy way to modify TOS agreements on the fly
JavaScript
3
star
15

feedlessfacebook

A chrome extension that removes the newsfeed from facebook
JavaScript
3
star
16

photo_workflow_tools

Tools to automate photography batch post-processing
Python
1
star
17

slowordown

Slowordown.com - an experiment in SEO built in Ruby on Rails
HTML
1
star
18

hntrends

Google Trends for Hacker News
Ruby
1
star
19

blockchain-conference-bingo

A bingo card for blockchain conferences
1
star