Skip to content

Instantly share code, notes, and snippets.

@shino
Created June 28, 2013 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shino/5882750 to your computer and use it in GitHub Desktop.
Save shino/5882750 to your computer and use it in GitHub Desktop.
Example usage and outputs of `tools/internal/riak_cs_inspector.erl`

Wrapper shell script:

$ cat ./riak_cs_inspector.sh
#!/bin/bash
ERL_LIBS=dev/dev1/lib dev/dev1/erts-5.9.3.1/bin/escript \
    dev/dev1/lib/riak_cs/priv/tools/internal/riak_cs_inspector.erl $*

Usage:

$ ./riak_cs_inspector.sh
List buckets     : $ riak_cs_inspector.erl PB-IP PB-Port
List CS keys     : $ riak_cs_inspector.erl PB-IP PB-Port CS-Bucket
Show manifest    : $ riak_cs_inspector.erl PB-IP PB-Port CS-Bucket    key=Key
List blocks      : $ riak_cs_inspector.erl PB-IP PB-Port CS-Bucket    key=Key uuid=UUIDPrefix
List GC bucket   : $ riak_cs_inspector.erl PB-IP PB-Port riak-cs-gc
Count GC bucket  : $ riak_cs_inspector.erl PB-IP PB-Port riak-cs-gc   count
Show GC manifest : $ riak_cs_inspector.erl PB-IP PB-Port riak-cs-gc   key=Key
List CS buckets  : $ riak_cs_inspector.erl PB-IP PB-Port moss.buckets
Show CS bucket   : $ riak_cs_inspector.erl PB-IP PB-Port moss.buckets name=CsBucket
List CS users    : $ riak_cs_inspector.erl PB-IP PB-Port moss.users
Show CS user     : $ riak_cs_inspector.erl PB-IP PB-Port moss.users   name=Name
Show CS user     : $ riak_cs_inspector.erl PB-IP PB-Port moss.users   key=KeyPrefix

NOTE1: Make sure riak_cs is in ERL_LIBS or code paths.
  e.g. $ ERL_LIBS=/path/to/riak-cs/lib riak_cs_inspector.erl ...
NOTE2: PB-Port aliases, rel=8087, dev1=10017, etc..
  e.g. $ riak_cs_inspector.erl 127.0.0.1 dev1 ...

List buckets:

$ ./riak_cs_inspector.sh 127.0.0.1 10017
Connecting to 127.0.0.1:10017...
All buckets:
[type   ] cs-bucket-name ================= = riak-bucket-name ===============
[blocks ] test                             = <<48,98,58,9,143,107,205,70,33,211,115,202,222,78,131,38,39,180,246>>
[blocks ] test2                            = <<48,98,58,173,2,52,130,146,5,185,3,49,150,186,129,143,122,135,43>>
[objects] test                             = <<48,111,58,9,143,107,205,70,33,211,115,202,222,78,131,38,39,180,246>>
[objects] test2                            = <<48,111,58,173,2,52,130,146,5,185,3,49,150,186,129,143,122,135,43>>
[riak-cs] moss.access                      = <<109,111,115,115,46,97,99,99,101,115,115>>
[riak-cs] moss.buckets                     = <<109,111,115,115,46,98,117,99,107,101,116,115>>
[riak-cs] moss.users                       = <<109,111,115,115,46,117,115,101,114,115>>
[riak-cs] riak-cs-gc                       = <<114,105,97,107,45,99,115,45,103,99>>
[riak-cs] test                             = <<116,101,115,116>>

List objects in CS buckets test2:

$ ./riak_cs_inspector.sh 127.0.0.1 10017 test2
Connecting to 127.0.0.1:10017...
Key ============================: Sibl. == State ========== UUID =========================== Content-Length== First Block ====
folsom/.git/HEAD                : 1        active           d9d9e6f6a8cf4f2db066b91d4f75a6a0               41 Found
folsom/.git/config              : 1        active           abcaa2b4df7941e3bf056eff8f2b4c83              257 Found
folsom/.git/description         : 1        active           295cfe9ff6ea4ad092083bf84fa3d5ba               73 Found
folsom/.git/hooks/applypatch-msg: 1        active           18f459089985494990d313743d0fe3bc              452 Found
folsom/.git/hooks/commit-msg.sam: 1        active           a38a038ba6c643ad89d3740edc4296e2              896 Found
folsom/.git/hooks/post-update.sa: 1        active           8d3edfc9d4754b17820e977bf5f73b58              189 Found
folsom/.git/hooks/pre-applypatch: 1        active           aa4cbbd2d41a4c9facb2222080bd992e              398 Found
[snip]

Show CS manifest for folsom/rebar.config in bucket test2:

$ ./riak_cs_inspector.sh 127.0.0.1 10017 test2 key=folsom/rebar.config
Connecting to 127.0.0.1:10017...
----- 1 instance(s) -----

Sibling=1: test2/folsom/rebar.config [lfs_manifest_v3]
                          uuid: "e4613596d7d8426f8227aa627c42b4d2"
                    block_size: 1048576
                      metadata: [{"Content-Encoding","UTF-8"}]
                       created: "2013-06-27T13:24:59.000Z"
                content_length: 234
                  content_type: <<"binary/octet-stream">>
                   content_md5: "a67d76b75bd193baffc1393b5b85e47a"
                         state: active
              write_start_time: {1372,339499,614306}
       last_block_written_time: {1372,339499,620494}
            delete_marked_time: undefined
       last_block_deleted_time: undefined
       delete_blocks_remaining: undefined
         scheduled_delete_time: undefined
                           acl: {acl_v2,
                                    {"alice",
                                     "f5b0febff81fd17d5408df839c6c8e2ddb9169b026e1207677bb373f27df0d47",
                                     "-22HHCRGO2ZED6KN18ME"},
                                    [{{"alice",
                                       "f5b0febff81fd17d5408df839c6c8e2ddb9169b026e1207677bb373f27df0d47"},
                                      ['FULL_CONTROL']}],
                                    {1372,327233,995767}}
                         props: []
                    cluster_id: undefined

List blocks for specific manifest:

$ ./riak_cs_inspector.sh 127.0.0.1 10017 test2 key=folsom/rebar.config uuid=e461
Connecting to 127.0.0.1:10017...
Blocks in object [folsom/rebar.config/e4613596d7d8426f8227aa627c42b4d2]:
UUID =========================== Block ==: Size ===== Value(first 8 or 32 bytes) =====================================
e4613596d7d8426f8227aa627c42b4d2        0:        234                                <<123,115,117,98,95,100,105,114>>

List objects in CS GC bucket:

$ ./riak_cs_inspector.sh 127.0.0.1 10017 riak-cs-gc
Connecting to 127.0.0.1:10017...
Key ============================: Sibl. == State ========== UUID =========================== Content-Length== CS Key =========================
1372401116                      : 1        pending_delete   2b764e32acd34ed2824512119cff9734               10 0
1372401116                      : 1        pending_delete   3cdb8831e3684003b73fac426f57190d               10 1
1372401117                      : 1        pending_delete   543964c8bee143af9d8992ebe6773775               10 3
1372401117                      : 1        pending_delete   a52b2bd2d1054f5492d4862cb8f01c50               10 4
1372401117                      : 1        pending_delete   a5940f528ae84936ad3b5932c5bf4c14               10 2
1372401118                      : 1        pending_delete   5a7dcaf263ff42bca0ef8cab8316851a               10 7
1372401118                      : 1        pending_delete   c8e95dd0a3f5451992fc2558752b23f3               10 6
1372401118                      : 1        pending_delete   d277e2b1d8ed4519b944c6f7fc3a3c80               10 5
1372401119                      : 1        pending_delete   0340b1182d314230958bed61b086c76a               10 9
1372401119                      : 1        pending_delete   436182286d704647979fcfa5cbcc7890               10 10
[snip]

Show CS minifests in one Riak object in CS GC bucket:

$ ./riak_cs_inspector.sh 127.0.0.1 10017 riak-cs-gc key=1372401153
Connecting to 127.0.0.1:10017...
----- 3 instance(s) -----

Sibling=1: test/99 [lfs_manifest_v3]
                          uuid: "2e5b869da93248debc350fd2fbf0b6e9"
                    block_size: 1048576
                      metadata: []
                       created: "2013-06-27T06:30:56.000Z"
                content_length: 10
                  content_type: <<"application/octet-stream">>
                   content_md5: "3fc26dc90ab296e41bc5fc8f9a2a7d40"
                         state: pending_delete
              write_start_time: {1372,314656,296516}
       last_block_written_time: {1372,314656,299217}
            delete_marked_time: {1372,314753,627869}
       last_block_deleted_time: undefined
       delete_blocks_remaining: undefined
         scheduled_delete_time: undefined
                           acl: {acl_v2,
                                    {"alice",
                                     "f5b0febff81fd17d5408df839c6c8e2ddb9169b026e1207677bb373f27df0d47",
                                     "-22HHCRGO2ZED6KN18ME"},
                                    [{{"alice",
                                       "f5b0febff81fd17d5408df839c6c8e2ddb9169b026e1207677bb373f27df0d47"},
                                      ['FULL_CONTROL']}],
                                    {1372,314656,296268}}
                         props: []
                    cluster_id: undefined

Sibling=1: test/97 [lfs_manifest_v3]
                          uuid: "84a92415447a4b7fbee731eb17282574"
                    block_size: 1048576
                      metadata: []
                       created: "2013-06-27T06:30:56.000Z"
                content_length: 10
                  content_type: <<"application/octet-stream">>
                   content_md5: "3fc26dc90ab296e41bc5fc8f9a2a7d40"
                         state: pending_delete
              write_start_time: {1372,314656,260726}
       last_block_written_time: {1372,314656,263461}
            delete_marked_time: {1372,314753,33417}
       last_block_deleted_time: undefined
       delete_blocks_remaining: undefined
         scheduled_delete_time: undefined
                           acl: {acl_v2,
                                    {"alice",
                                     "f5b0febff81fd17d5408df839c6c8e2ddb9169b026e1207677bb373f27df0d47",
                                     "-22HHCRGO2ZED6KN18ME"},
                                    [{{"alice",
                                       "f5b0febff81fd17d5408df839c6c8e2ddb9169b026e1207677bb373f27df0d47"},
                                      ['FULL_CONTROL']}],
                                    {1372,314656,260490}}
                         props: []
                    cluster_id: undefined

Sibling=1: test/98 [lfs_manifest_v3]
                          uuid: "c5f6c49f4fe040a0959728dd84c54b91"
                    block_size: 1048576
                      metadata: []
                       created: "2013-06-27T06:30:56.000Z"
                content_length: 10
                  content_type: <<"application/octet-stream">>
                   content_md5: "3fc26dc90ab296e41bc5fc8f9a2a7d40"
                         state: pending_delete
              write_start_time: {1372,314656,276531}
       last_block_written_time: {1372,314656,279918}
            delete_marked_time: {1372,314753,367992}
       last_block_deleted_time: undefined
       delete_blocks_remaining: undefined
         scheduled_delete_time: undefined
                           acl: {acl_v2,
                                    {"alice",
                                     "f5b0febff81fd17d5408df839c6c8e2ddb9169b026e1207677bb373f27df0d47",
                                     "-22HHCRGO2ZED6KN18ME"},
                                    [{{"alice",
                                       "f5b0febff81fd17d5408df839c6c8e2ddb9169b026e1207677bb373f27df0d47"},
                                      ['FULL_CONTROL']}],
                                    {1372,314656,276319}}
                         props: []
                    cluster_id: undefined

List objects in moss.buckets:

$ ./riak_cs_inspector.sh 127.0.0.1 10017 moss.buckets
Connecting to 127.0.0.1:10017...
CS Bucket Name ================================================= Sibl. ==: Owner Key ==============================
test                                                             1       : -22HHCRGO2ZED6KN18ME
test2                                                            1       : -22HHCRGO2ZED6KN18ME

Show information of CS bucket test2:

$ ./riak_cs_inspector.sh 127.0.0.1 10017 moss.buckets key=test2
Connecting to 127.0.0.1:10017...

Bucket   : test2
SiblingNo: 1
Owner    : -22HHCRGO2ZED6KN18ME
Acl:
#acl_v2{owner = {"alice",
                 "f5b0febff81fd17d5408df839c6c8e2ddb9169b026e1207677bb373f27df0d47",
                 "-22HHCRGO2ZED6KN18ME"},
        grants = [{{"alice",
                    "f5b0febff81fd17d5408df839c6c8e2ddb9169b026e1207677bb373f27df0d47"},
                   ['FULL_CONTROL']}],
        creation_time = {1372,327226,551088}}
Policy:
undefined

List objects in moss.users:

$ ./riak_cs_inspector.sh 127.0.0.1 10017 moss.users
Connecting to 127.0.0.1:10017...
Key ID ================================= Sibl. ==: Name =================================== Secret =================================
-22HHCRGO2ZED6KN18ME                            1: alice                                    x68DrxRrqjtoth_6Rv9xHABPqWENk0rh-UmSYQ==

Show information of CS user which name is alice:

$ ./riak_cs_inspector.sh 127.0.0.1 10017 moss.users name=alice
Connecting to 127.0.0.1:10017...

User Key : alice
SiblingNo: 1
Record   :
#rcs_user_v2{
    name = "alice",display_name = "alice",email = "alice@example.com",
    key_id = "-22HHCRGO2ZED6KN18ME",
    key_secret = "x68DrxRrqjtoth_6Rv9xHABPqWENk0rh-UmSYQ==",
    canonical_id =
        "f5b0febff81fd17d5408df839c6c8e2ddb9169b026e1207677bb373f27df0d47",
    buckets =
        [#moss_bucket_v1{
             name = "test2",last_action = created,
             creation_date = "2013-06-27T13:24:52.000Z",
             modification_time = {1372,339492,406432},
             acl = undefined},
         #moss_bucket_v1{
             name = "test",last_action = created,
             creation_date = "2013-06-27T05:51:00.000Z",
             modification_time = {1372,312260,878895},
             acl = undefined}],
    status = enabled}

Show information of CS user which key_id starts with -22H:

$ ./riak_cs_inspector.sh 127.0.0.1 10017 moss.users key=-22H
Connecting to 127.0.0.1:10017...

User Key : alice
SiblingNo: 1
Record   :
#rcs_user_v2{
    name = "alice",display_name = "alice",email = "alice@example.com",
    key_id = "-22HHCRGO2ZED6KN18ME",
    key_secret = "x68DrxRrqjtoth_6Rv9xHABPqWENk0rh-UmSYQ==",
    canonical_id =
        "f5b0febff81fd17d5408df839c6c8e2ddb9169b026e1207677bb373f27df0d47",
    buckets =
        [#moss_bucket_v1{
             name = "test2",last_action = created,
             creation_date = "2013-06-27T13:24:52.000Z",
             modification_time = {1372,339492,406432},
             acl = undefined},
         #moss_bucket_v1{
             name = "test",last_action = created,
             creation_date = "2013-06-27T05:51:00.000Z",
             modification_time = {1372,312260,878895},
             acl = undefined}],
    status = enabled}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment