Skip to content

Instantly share code, notes, and snippets.

@mcornea
Last active September 21, 2015 21:19
Show Gist options
  • Select an option

  • Save mcornea/ec355461be493a0099f8 to your computer and use it in GitHub Desktop.

Select an option

Save mcornea/ec355461be493a0099f8 to your computer and use it in GitHub Desktop.
SNMP meters
heat_template_version: 2014-10-16
parameters:
servers:
type: json
# Optional implementation specific parameters
snmp_user:
type: string
snmp_pass:
type: string
resources:
ExtraConfig:
type: OS::Heat::SoftwareConfig
properties:
group: script
config:
str_replace:
template: |
#!/bin/sh
systemctl stop snmpd
net-snmp-create-v3-user -ro -A _SNMPPASS_ -X _SNMPPASS_ -a MD5 _SNMPUSER_
cat > /etc/snmp/snmpd.conf << EOF
# Listen for connections on all interfaces (both IPv4 *and* IPv6)
agentAddress udp:161,udp6:[::1]:161
createUser _SNMPUSER_ MD5 "_SNMPPASS_"
view systemonly included .1.3.6.1.2.1.1
view systemonly included .1.3.6.1.2.1.25.1
rouser _SNMPUSER_
sysLocation Sitting on top of the cloud
sysContact Me <me@example.org>
sysServices 72
# Process Monitoring
proc cron
# Disk Monitoring
# 10MBs required on root disk, 5% free on /var, 10% free on all other disks
includeAllDisks 10%
# ACTIVE MONITORING
# send SNMPv1 traps
trapsink localhost public
iquerySecName internalUser
rouser internalUser
# generate traps on UCD error conditions
defaultMonitors yes
# generate traps on linkUp/Down
linkUpDownNotifications yes
# Arbitrary extension commands
extend OoOEnabled /bin/echo Yes
extend CheckProcOpenFiles /bin/bash /usr/lib/nagios/plugins/check_proc_open_files.py
# "Pass-through" MIB extension command
#pass .1.3.6.1.4.1.8072.2.255 /bin/sh PREFIX/local/passtest
#pass .1.3.6.1.4.1.8072.2.255 /usr/bin/perl PREFIX/local/passtest.pl
# AgentX Sub-agents
# Run as an AgentX master agent
master agentx
EOF
systemctl start snmpd
params:
_SNMPUSER_: {get_param: snmp_user}
_SNMPPASS_: {get_param: snmp_pass}
ExtraDeployments:
type: OS::Heat::SoftwareDeployments
properties:
servers: {get_param: servers}
config: {get_resource: ExtraConfig}
actions: ['CREATE', 'UPDATE'] # Only do this on CREATE
resource_registry:
OS::TripleO::NodeExtraConfigPost: my-overcloud/extraconfig/post_deploy/snmpd-user.yaml
parameter_defaults:
snmp_user: ro_snmp_user
snmp_pass: ro_snmp_user_pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment