-
-
Save gudata/3d2a1aee7297c791da8c34845d3a9674 to your computer and use it in GitHub Desktop.
Monitor S3 with Zabbix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'aws-sdk' | |
require 'optparse' | |
require 'json' | |
discovery = {'data' => []} | |
s3 = AWS::S3.new | |
s3.buckets.each do |bucket| | |
discovery['data'] << { | |
'{#BUCKET_NAME}' => bucket.name, | |
} | |
end | |
puts discovery.to_json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'aws-sdk' | |
require 'optparse' | |
params = ARGV.getopts( | |
'', | |
'mode:', | |
'bucket_name:' | |
) | |
s3 = AWS::S3.new | |
bucket = s3.buckets[params['bucket_name']] | |
exit unless s3.buckets.include? bucket | |
case params['mode'] | |
when 'count' | |
puts bucket.objects.count | |
when 'size' | |
puts bucket.objects.inject(0){|total_size, object| total_size + object.content_length} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<zabbix_export> | |
<version>2.0</version> | |
<date>2014-05-16T03:21:48Z</date> | |
<groups> | |
<group> | |
<name>AWS templates</name> | |
</group> | |
</groups> | |
<templates> | |
<template> | |
<template>Template AWS S3</template> | |
<name>Template AWS S3</name> | |
<groups> | |
<group> | |
<name>AWS templates</name> | |
</group> | |
</groups> | |
<applications> | |
<application> | |
<name>S3</name> | |
</application> | |
</applications> | |
<items/> | |
<discovery_rules> | |
<discovery_rule> | |
<name>Bucket discovery</name> | |
<type>10</type> | |
<snmp_community/> | |
<snmp_oid/> | |
<key>discover_s3</key> | |
<delay>3600</delay> | |
<status>0</status> | |
<allowed_hosts/> | |
<snmpv3_contextname/> | |
<snmpv3_securityname/> | |
<snmpv3_securitylevel>0</snmpv3_securitylevel> | |
<snmpv3_authprotocol>0</snmpv3_authprotocol> | |
<snmpv3_authpassphrase/> | |
<snmpv3_privprotocol>0</snmpv3_privprotocol> | |
<snmpv3_privpassphrase/> | |
<delay_flex/> | |
<params/> | |
<ipmi_sensor/> | |
<authtype>0</authtype> | |
<username/> | |
<password/> | |
<publickey/> | |
<privatekey/> | |
<port/> | |
<filter>:</filter> | |
<lifetime>30</lifetime> | |
<description/> | |
<item_prototypes> | |
<item_prototype> | |
<name>Number of objects in {#BUCKET_NAME}</name> | |
<type>10</type> | |
<snmp_community/> | |
<multiplier>0</multiplier> | |
<snmp_oid/> | |
<key>s3[--bucket_name, {#BUCKET_NAME}, --mode, count]</key> | |
<delay>3600</delay> | |
<history>90</history> | |
<trends>365</trends> | |
<status>0</status> | |
<value_type>3</value_type> | |
<allowed_hosts/> | |
<units/> | |
<delta>0</delta> | |
<snmpv3_contextname/> | |
<snmpv3_securityname/> | |
<snmpv3_securitylevel>0</snmpv3_securitylevel> | |
<snmpv3_authprotocol>0</snmpv3_authprotocol> | |
<snmpv3_authpassphrase/> | |
<snmpv3_privprotocol>0</snmpv3_privprotocol> | |
<snmpv3_privpassphrase/> | |
<formula>1</formula> | |
<delay_flex/> | |
<params/> | |
<ipmi_sensor/> | |
<data_type>0</data_type> | |
<authtype>0</authtype> | |
<username/> | |
<password/> | |
<publickey/> | |
<privatekey/> | |
<port/> | |
<description/> | |
<inventory_link>0</inventory_link> | |
<applications> | |
<application> | |
<name>S3</name> | |
</application> | |
</applications> | |
<valuemap/> | |
</item_prototype> | |
<item_prototype> | |
<name>Size of {#BUCKET_NAME}</name> | |
<type>10</type> | |
<snmp_community/> | |
<multiplier>0</multiplier> | |
<snmp_oid/> | |
<key>s3[--bucket_name, {#BUCKET_NAME}, --mode, size]</key> | |
<delay>3600</delay> | |
<history>90</history> | |
<trends>365</trends> | |
<status>0</status> | |
<value_type>3</value_type> | |
<allowed_hosts/> | |
<units>B</units> | |
<delta>0</delta> | |
<snmpv3_contextname/> | |
<snmpv3_securityname/> | |
<snmpv3_securitylevel>0</snmpv3_securitylevel> | |
<snmpv3_authprotocol>0</snmpv3_authprotocol> | |
<snmpv3_authpassphrase/> | |
<snmpv3_privprotocol>0</snmpv3_privprotocol> | |
<snmpv3_privpassphrase/> | |
<formula>1</formula> | |
<delay_flex/> | |
<params/> | |
<ipmi_sensor/> | |
<data_type>0</data_type> | |
<authtype>0</authtype> | |
<username/> | |
<password/> | |
<publickey/> | |
<privatekey/> | |
<port/> | |
<description/> | |
<inventory_link>0</inventory_link> | |
<applications> | |
<application> | |
<name>S3</name> | |
</application> | |
</applications> | |
<valuemap/> | |
</item_prototype> | |
</item_prototypes> | |
<trigger_prototypes/> | |
<graph_prototypes> | |
<graph_prototype> | |
<name>Usage of {#BUCKET_NAME}</name> | |
<width>900</width> | |
<height>200</height> | |
<yaxismin>0.0000</yaxismin> | |
<yaxismax>100.0000</yaxismax> | |
<show_work_period>1</show_work_period> | |
<show_triggers>1</show_triggers> | |
<type>0</type> | |
<show_legend>1</show_legend> | |
<show_3d>0</show_3d> | |
<percent_left>0.0000</percent_left> | |
<percent_right>0.0000</percent_right> | |
<ymin_type_1>1</ymin_type_1> | |
<ymax_type_1>0</ymax_type_1> | |
<ymin_item_1>0</ymin_item_1> | |
<ymax_item_1>0</ymax_item_1> | |
<graph_items> | |
<graph_item> | |
<sortorder>1</sortorder> | |
<drawtype>0</drawtype> | |
<color>C80000</color> | |
<yaxisside>1</yaxisside> | |
<calc_fnc>2</calc_fnc> | |
<type>0</type> | |
<item> | |
<host>Template AWS S3</host> | |
<key>s3[--bucket_name, {#BUCKET_NAME}, --mode, count]</key> | |
</item> | |
</graph_item> | |
<graph_item> | |
<sortorder>0</sortorder> | |
<drawtype>0</drawtype> | |
<color>00C800</color> | |
<yaxisside>0</yaxisside> | |
<calc_fnc>2</calc_fnc> | |
<type>0</type> | |
<item> | |
<host>Template AWS S3</host> | |
<key>s3[--bucket_name, {#BUCKET_NAME}, --mode, size]</key> | |
</item> | |
</graph_item> | |
</graph_items> | |
</graph_prototype> | |
</graph_prototypes> | |
<host_prototypes/> | |
</discovery_rule> | |
</discovery_rules> | |
<macros/> | |
<templates/> | |
<screens/> | |
</template> | |
</templates> | |
</zabbix_export> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment