metadata.py
#!/usr/bin/python
# This script returns metadata specific to AWS instances
# See Page 49, Amazon Elastic Compute Cloud - Developer Guide
from httplib import HTTPConnection
from sys import argv
import socket
if len(argv) > 1:try:
conn = HTTPConnection("169.254.169.254")
url = "/latest/meta-data/" + str(argv[1])
conn.request("GET",url)
r1 = conn.getresponse()
if r1.status == 200:
print r1.read()
else:
print r1.status,url
except socket.error,msg:
print msg[1]
else:
print "data key missing"
snmp.conf
rwcommunity EDF9ErIfzNFb 127.0.0.1
rocommunity public
syscontact user@host.com
syslocation AWS
com2sec notConfigUser default public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
# RFC1213-MIB.iso.org.dod.internet.mgmt.mib-2
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.2
# HOST-RESOURCES-MIB.iso.org.dod.internet.mgmt.mib-2.host
view systemview included .1.3.6.1.2.1.25 view systemview included .1.3.6.1.2.1.25.1.1
# UCD-SNMP-MIB.iso.org.dod.internet.private.enterprises.ucdavis
view systemview included .1.3.6.1.4.1.2021
access notConfigGroup "" any noauth exact systemview none none
# Added for support of bcm5820 cards.
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
#agentaddress 192.168.8.103
# Executable Scripts
# AWS Specific
exec ami-id /etc/snmp/aws_metadata.sh ami-id
exec ami-launch-index /etc/snmp/aws_metadata.sh ami-launch-index
exec ami-manifest-path /etc/snmp/aws_metadata.sh ami-manifest-path
exec ancestor-ami-ids /etc/snmp/aws_metadata.sh ancestor-ami-ids
exec block-device-mapping /etc/snmp/aws_metadata.sh block-device-mapping
exec instance-id /etc/snmp/aws_metadata.sh instance-id
exec instance-type /etc/snmp/aws_metadata.sh instance-type
exec local-hostname /etc/snmp/aws_metadata.sh local-hostname
exec local-ipv /etc/snmp/aws_metadata.sh local-ipv4
exec kernel-id /etc/snmp/aws_metadata.sh kernel-id
exec availability-zone /etc/snmp/aws_metadata.sh availability-zone
#exec product-codes /etc/snmp/aws_metadata.sh product-codes
exec public-hostname /etc/snmp/aws_metadata.sh public-hostname
exec public-ipv4 /etc/snmp/aws_metadata.sh public-ipv4
#exec public-keys /etc/snmp/aws_metadata.sh public-keys
exec ramdisk-id /etc/snmp/aws_metadata.sh ramdisk-id
exec reservation-id /etc/snmp/aws_metadata.sh reservation-id
exec security-groups /etc/snmp/aws_metadata.sh security-groups
# Disk Checks
disk /
# Process Checks
proc crond
proc ntpd
proc rsyslogd
proc sshd
Sample Output
[root@ami1 ~]# snmpwalk -Os -c public -v 2c localhost .1.3.6.1.4.1.2021.8.1.101.1
extOutput.1 = STRING: ami-08f41161
[root@ami1 ~]# snmpwalk -Os -c public -v 2c localhost .1.3.6.1.4.1.2021.8.1.101.2
extOutput.2 = STRING: 101
Hope this helps!
VVK
No comments:
Post a Comment