[英]Aws::S3::Errors::BadDigest while trying to store a Tempfile
[英]Trying to find a Sensu plugin AWS S3
我正在嘗試查找或創建一個Sensu插件來計算文件夾中的AWS S3對象。 例如,
所有存儲桶/測試1 /測試2 /
我想知道test2中有多少個對象,如果數量超過閾值,請提醒我。
我找到了,但是無法使其正常工作。
# by default you only get 1000 objects at a time
# so you have to roll your own cursor
S3.connect!
objects = []
last_key = nil
begin
new_objects = AWS::S3::Bucket.objects(bucket_name, :marker => last_key)
objects += new_objects
last_key = objects.last.key
end while new_objects.size > 0
# you can easily define the above as an all_objects method on AWS::S3::Bucket
如果有人知道執行此操作的其他方法,請告訴我。
謝謝
德文郡
我決定走另一條路,我用這段代碼來完成我想做的事情。
#!/bin/bash
value=$(aws s3 ls bucket/dir1/dir2/ -- recursive --human-readable --summarize | grep .file type | wc -l)
if [ $value -gt 1000 ];
then
echo "$value Warning"
exit 2
fi
謝謝大家的幫助
德文郡
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.