Browse Source

initial version of SNMP trap daemon for Zabbix plugin

Change-Id: I4041c15fdf09af5944b75f142a5c374b24af380f
tags/1.0.1-1-rc1
Piotr Misiak 4 years ago
parent
commit
8962ed0563

+ 5
- 0
.gitignore View File

@@ -0,0 +1,5 @@
1
+.build/
2
+*.noarch.rpm
3
+repositories/centos/*.rpm
4
+repositories/ubuntu/*.deb
5
+deployment_scripts/puppet/modules/snmp

+ 16
- 0
deployment_scripts/puppet/manifests/controller.pp View File

@@ -0,0 +1,16 @@
1
+#
2
+#    Copyright 2015 Mirantis, Inc.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+include plugin_zabbix_snmptrapd

+ 143
- 0
deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmpd View File

@@ -0,0 +1,143 @@
1
+#! /bin/sh -e
2
+### BEGIN INIT INFO
3
+# Provides:           snmpd snmptrapd
4
+# Required-Start:     $network $remote_fs $syslog
5
+# Required-Stop:      $network $remote_fs $syslog
6
+# Default-Start:      2 3 4 5
7
+# Default-Stop:       0 1 6
8
+# Short-Description:  SNMP agents
9
+# Description:        NET SNMP (Simple Network Management Protocol) Agents
10
+### END INIT INFO
11
+#
12
+# Author:      Jochen Friedrich <jochen@scram.de>
13
+# Modified by: Piotr Misiak <pmisiak@mirantis.com> (network namespaces support added)
14
+#
15
+set -e
16
+
17
+. /lib/lsb/init-functions
18
+
19
+export PATH=/sbin:/usr/sbin:/bin:/usr/bin
20
+
21
+# Defaults
22
+OLD_MIBS_DIR="/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp"
23
+MIBS_DIR="/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf"
24
+export MIBDIRS="$MIBS_DIR:$OLD_MIBS_DIR"
25
+
26
+IP_BINARY="/sbin/ip"
27
+
28
+SNMPD_BINARY="/usr/sbin/snmpd"
29
+SNMPD_PID="/run/snmpd.pid"
30
+SNMPDNS="haproxy"
31
+SNMPDRUN="yes"
32
+SNMPDOPTS="-Lsd -Lf /dev/null -p $SNMPD_PID"
33
+
34
+TRAPD_BINARY="/usr/sbin/snmptrapd"
35
+TRAPD_PID="/run/snmptrapd.pid"
36
+TRAPDNS="haproxy"
37
+TRAPDRUN="no"
38
+TRAPDOPTS="-Lsd -p $TRAPD_PID"
39
+
40
+# Reads config file (will override defaults above)
41
+[ -r /etc/default/snmpd ] && . /etc/default/snmpd
42
+
43
+test -x $SNMPD_BINARY || exit 0
44
+test -x $TRAPD_BINARY || exit 0
45
+
46
+if [ "x$SNMPDNS" != "x" ]; then
47
+  SNMPDOPTS="netns exec $SNMPDNS $SNMPD_BINARY $SNMPDOPTS"
48
+  SNMPDEXEC=$IP_BINARY
49
+else
50
+  SNMPDEXEC=$SNMPD_BINARY
51
+fi
52
+
53
+if [ "x$TRAPDNS" != "x" ]; then
54
+  TRAPDOPTS="netns exec $TRAPDNS $TRAPD_BINARY $TRAPDOPTS"
55
+  TRAPDEXEC=$IP_BINARY
56
+else
57
+  TRAPDEXEC=$TRAPD_BINARY
58
+fi
59
+
60
+# Cd to / before starting any daemons.
61
+cd /
62
+
63
+case "$1" in
64
+  start)
65
+    log_daemon_msg "Starting network management services:"
66
+    # remove old symlink with previous version
67
+    if [ -L /var/run/agentx ]; then
68
+      rm -f /var/run/agentx
69
+    fi
70
+    if [ ! -d /var/run/agentx ]; then
71
+      mkdir -p /var/run/agentx
72
+    fi
73
+    if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
74
+      start-stop-daemon --quiet --start --oknodo --exec $SNMPDEXEC -- $SNMPDOPTS
75
+      log_progress_msg " snmpd"
76
+    fi
77
+    if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
78
+      start-stop-daemon --quiet --start --oknodo --exec $TRAPDEXEC -- $TRAPDOPTS
79
+      log_progress_msg " snmptrapd"
80
+    fi
81
+    ;;
82
+  stop)
83
+    log_daemon_msg "Stopping network management services:"
84
+    start-stop-daemon --quiet --stop --oknodo --exec $SNMPD_BINARY && [ ! -f $SNMPD_PID ] || rm $SNMPD_PID
85
+    log_progress_msg " snmpd"
86
+    start-stop-daemon --quiet --stop --oknodo --exec $TRAPD_BINARY && [ ! -f $TRAPD_PID ] || rm $TRAPD_PID
87
+    log_progress_msg " snmptrapd"
88
+    ;;
89
+  restart)
90
+    log_daemon_msg "Restarting network management services:"
91
+    start-stop-daemon --quiet --stop --oknodo --exec $SNMPD_BINARY && [ ! -f $SNMPD_PID ] || rm $SNMPD_PID
92
+    start-stop-daemon --quiet --stop --oknodo --exec $TRAPD_BINARY && [ ! -f $TRAPD_PID ] || rm $TRAPD_PID
93
+    # Allow the daemons time to exit completely.
94
+    set +e
95
+    for i in `seq 0 10`; do
96
+      pgrep -f $SNMPD_BINARY >/dev/null
97
+      SNMPDSTATUS=$?
98
+      pgrep -f $TRAPD_BINARY >/dev/null
99
+      TRAPDSTATUS=$?
100
+      if [ $SNMPDSTATUS -eq 1 -a $TRAPDSTATUS -eq 1 ]; then
101
+        # both processes are not running
102
+        break
103
+      fi
104
+      if [ $i -eq 10 ]; then
105
+        log_failure_msg "ERROR: Network management services didn't stop within 10 seconds, exiting..."
106
+        exit 1
107
+      fi
108
+      sleep 1
109
+    done
110
+    set -e
111
+    if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
112
+      start-stop-daemon --quiet --start --exec $SNMPDEXEC -- $SNMPDOPTS
113
+      log_progress_msg " snmpd"
114
+    fi
115
+    if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
116
+      start-stop-daemon --quiet --start --exec $TRAPDEXEC -- $TRAPDOPTS
117
+      log_progress_msg " snmptrapd"
118
+    fi
119
+    ;;
120
+  reload|force-reload)
121
+    log_daemon_msg "Reloading network management services:"
122
+    if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
123
+      start-stop-daemon --quiet --stop --signal 1 \
124
+        --pidfile /var/run/snmpd.pid --exec $SNMPD_BINARY
125
+      log_progress_msg " snmpd"
126
+    fi
127
+    ;;
128
+  status)
129
+    status=0
130
+    if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
131
+      status_of_proc $SNMPD_BINARY snmpd || status=$?
132
+    fi
133
+    if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
134
+      status_of_proc $TRAPD_BINARY snmptrapd || status=$?
135
+    fi
136
+    exit $status
137
+    ;;
138
+  *)
139
+    echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload|status}"
140
+    exit 1
141
+esac
142
+
143
+exit 0

+ 110
- 0
deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmptrapd View File

@@ -0,0 +1,110 @@
1
+#!/bin/bash
2
+
3
+# ucd-snmp init file for snmptrapd
4
+#
5
+# chkconfig: - 50 50
6
+# description: Simple Network Management Protocol (SNMP) Trap Daemon
7
+#
8
+# processname: /usr/sbin/snmptrapd
9
+# config: /etc/snmp/snmptrapd.conf
10
+# config: /usr/share/snmp/snmptrapd.conf
11
+# pidfile: /var/run/snmptrapd.pid
12
+
13
+
14
+### BEGIN INIT INFO
15
+# Provides: snmptrapd
16
+# Required-Start: $local_fs $network
17
+# Required-Stop: $local_fs $network
18
+# Should-Start:
19
+# Should-Stop:
20
+# Default-Start:
21
+# Default-Stop:
22
+# Short-Description: start and stop Net-SNMP trap daemon
23
+# Description: Simple Network Management Protocol (SNMP) trap daemon
24
+### END INIT INFO
25
+
26
+# source function library
27
+. /etc/init.d/functions
28
+
29
+NS="haproxy"
30
+OPTIONS="-Lsd -p /var/run/snmptrapd.pid"
31
+if [ -e /etc/sysconfig/snmptrapd ]; then
32
+  . /etc/sysconfig/snmptrapd
33
+fi
34
+
35
+RETVAL=0
36
+prog="snmptrapd"
37
+binary=/usr/sbin/snmptrapd
38
+pidfile=/var/run/snmptrapd.pid
39
+
40
+if [ "x$NS" != "x" ]; then
41
+  cmd="/sbin/ip netns exec $NS $binary"
42
+else
43
+  cmd=$binary
44
+fi
45
+
46
+start() {
47
+  [ -x $binary ] || exit 5
48
+  echo -n $"Starting $prog: "
49
+        daemon --pidfile=$pidfile $cmd $OPTIONS
50
+  RETVAL=$?
51
+  echo
52
+  touch /var/lock/subsys/snmptrapd
53
+  return $RETVAL
54
+}
55
+
56
+stop() {
57
+  echo -n $"Stopping $prog: "
58
+  killproc -p $pidfile $binary
59
+  RETVAL=$?
60
+  echo
61
+  rm -f /var/lock/subsys/snmptrapd
62
+  return $RETVAL
63
+}
64
+
65
+reload(){
66
+  stop
67
+  start
68
+}
69
+
70
+restart(){
71
+  stop
72
+  start
73
+}
74
+
75
+condrestart(){
76
+    [ -e /var/lock/subsys/snmptrapd ] && restart
77
+    return 0
78
+}
79
+
80
+case "$1" in
81
+  start)
82
+  start
83
+  RETVAL=$?
84
+  ;;
85
+  stop)
86
+  stop
87
+  RETVAL=$?
88
+  ;;
89
+  restart)
90
+  restart
91
+  RETVAL=$?
92
+        ;;
93
+  reload|force-reload)
94
+  reload
95
+  RETVAL=$?
96
+        ;;
97
+  condrestart|try-restart)
98
+  condrestart
99
+  RETVAL=$?
100
+  ;;
101
+  status)
102
+        status $prog
103
+  RETVAL=$?
104
+        ;;
105
+  *)
106
+  echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
107
+  RETVAL=2
108
+esac
109
+
110
+exit $RETVAL

+ 2
- 0
deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/snmptt.conf View File

@@ -0,0 +1,2 @@
1
+EVENT netSnmpExampleHeartbeatNotification .1.3.6.1.4.1.8072.2.3.0.1 "Status Events" Normal
2
+FORMAT ZBXTRAP $aA netSnmpExampleHeartbeatNotification

+ 626
- 0
deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/snmptt.ini View File

@@ -0,0 +1,626 @@
1
+#
2
+# SNMPTT v1.4 Configuration File
3
+#
4
+# Linux / Unix
5
+#
6
+
7
+[General]
8
+# Name of this system for $H variable.  If blank, system name will be the computer's
9
+# hostname via Sys::Hostname.
10
+snmptt_system_name =
11
+
12
+# Set to either 'standalone' or 'daemon'
13
+# standalone: snmptt called from snmptrapd.conf
14
+# daemon: snmptrapd.conf calls snmptthandler
15
+# Ignored by Windows.  See documentation
16
+mode = standalone
17
+
18
+# Set to 1 to allow multiple trap definitions to be executed for the same trap.
19
+# Set to 0 to have it stop after the first match.
20
+# This option should normally be set to 1.  See the section 'SNMPTT.CONF Configuration
21
+# file Notes' in the SNMPTT documentation for more information.
22
+# Note: Wildcard matches are only matched if there are NO exact matches. This takes
23
+#       into consideration the NODES list. Therefore, if there is a matching trap, but
24
+#       the NODES list prevents it from being considered a match, the wildcard entry will
25
+#       only be used if there are no other exact matches.
26
+multiple_event = 1
27
+
28
+# SNMPTRAPD passes the IP address of device sending the trap, and the IP address of the
29
+# actual SNMP agent.  These addresses could differ if the trap was sent on behalf of another
30
+# device (relay, proxy etc).
31
+# If DNS is enabled, the agent IP address is converted to a host name using a DNS lookup
32
+# (which includes the local hosts file, depending on how the OS is configured).  This name
33
+# will be used for: NODES entry matches, hostname field in logged traps (file / database),
34
+# and the $A variable.  Host names on the NODES line will be resolved and the IP address
35
+# will then be used for comparing.
36
+# Set to 0 to disable DNS resolution
37
+# Set to 1 to enable DNS resolution
38
+dns_enable = 0
39
+
40
+# Set to 0 to enable the use of FQDN (Fully Qualified Domain Names).  If a host name is
41
+# passed to SNMPTT that contains a domain name, it will not be altered in any way by
42
+# SNMPTT.  This also affects resolve_value_ip_addresses.
43
+# Set to 1 to have SNMPTT strip the domain name from the host name passed to it.  For
44
+# example, server01.domain.com would be changed to server01
45
+# Set to 2 to have SNMPTT strip the domain name from the host name passed to it
46
+# based on the list of domains in strip_domain_list
47
+strip_domain = 0
48
+
49
+# List of domain names that should be stripped when strip_domain is set to 2.
50
+# List can contain one or more domains.  For example, if the FQDN of a host is
51
+# server01.city.domain.com and the list contains domain.com, the 'host' will be
52
+# set as server01.city.
53
+strip_domain_list = <<END
54
+domain.com
55
+END
56
+
57
+# Configures how IP addresses contained in the VALUE of the variable bindings are handled.
58
+# This only applies to the values for $n, $+n, $-n, $vn, $+*, $-*.
59
+# Set to 0 to disable resolving ip address to host names
60
+# Set to 1 to enable resolving ip address to host names
61
+# Note: net_snmp_perl_enable *must* be enabled.  The strip_domain settings influence the
62
+# format of the resolved host name.  DNS must be enabled (dns_enable)
63
+resolve_value_ip_addresses = 0
64
+
65
+# Set to 1 to enable the use of the Perl module from the UCD-SNMP / NET-SNMP package.
66
+# This is required for $v variable substitution to work, and also for some other options
67
+# that are enabled in this .ini file.
68
+# Set to 0 to disable the use of the Perl module from the UCD-SNMP / NET-SNMP package.
69
+# Note: Enabling this with stand-alone mode can cause SNMPTT to run very slowly due to
70
+#       the loading of the MIBS at startup.
71
+net_snmp_perl_enable = 1
72
+
73
+# Set to 1 to enable caching of OID and ENUM translations when net_snmp_perl_enable is
74
+# enabled.  Enabling this should result in faster translations.
75
+# Set to 0 to disable caching.
76
+# Note: Restart SNMPTT after updating the MIB files for Net-SNMP, otherwise the cache may
77
+# contain inaccurate data.  Defaults to 1.
78
+net_snmp_perl_cache_enable = 1
79
+
80
+# This sets the best_guess parameter used by the UCD-SNMP / NET-SNMP Perl module for
81
+# translating symbolic nams to OIDs and vice versa.
82
+# For UCD-SNMP, and Net-SNMP 5.0.8 and previous versions, set this value to 0.
83
+# For Net-SNMP 5.0.9, or any Net-SNMP with patch 722075 applied, set this value to 2.
84
+# A value of 2 is equivalent to -IR on Net-SNMP command line utilities.
85
+# UCD-SNMP and Net-SNMP 5.0.8 and previous may not be able to translate certain formats of
86
+# symbolic names such as RFC1213-MIB::sysDescr.  Net-SNMP 5.0.9 or patch 722075 will allow
87
+# all possibilities to be translated.  See the FAQ section in the README for more info
88
+net_snmp_perl_best_guess = 0
89
+
90
+# Configures how the OID of the received trap is handled when outputting to a log file /
91
+# database.  It does NOT apply to the $O variable.
92
+# Set to 0 to use the default of numerical OID
93
+# Set to 1 to translate the trap OID to short text (symbolic form) (eg: linkUp)
94
+# Set to 2 to translate the trap OID to short text with module name (eg: IF-MIB::linkUp)
95
+# Set to 3 to translate the trap OID to long text (eg: iso...snmpTraps.linkUp)
96
+# Set to 4 to translate the trap OID to long text with module name (eg:
97
+# IF-MIB::iso...snmpTraps.linkUp)
98
+# Note: -The output of the long format will vary depending on the version of Net-SNMP you
99
+#        are using.
100
+#       -net_snmp_perl_enable *must* be enabled
101
+#       -If using database logging, ensure the trapoid column is large enough to hold the
102
+#        entire line
103
+translate_log_trap_oid = 0
104
+
105
+# Configures how OIDs contained in the VALUE of the variable bindings are handled.
106
+# This only applies to the values for $n, $+n, $-n, $vn, $+*, $-*.  For substitutions
107
+# that include variable NAMES ($+n etc), only the variable VALUE is affected.
108
+# Set to 0 to disable translating OID values to text (symbolic form)
109
+# Set to 1 to translate OID values to short text (symbolic form) (eg: BuildingAlarm)
110
+# Set to 2 to translate OID values to short text with module name (eg: UPS-MIB::BuildingAlarm)
111
+# Set to 3 to translate OID values to long text (eg: iso...upsAlarm.BuildingAlarm)
112
+# Set to 4 to translate OID values to long text with module name (eg:
113
+# UPS-MIB::iso...upsAlarm.BuildingAlarm)
114
+# For example, if the value contained: 'A UPS Alarm (.1.3.6.1.4.1.534.1.7.12) has cleared.',
115
+# it could be translated to: 'A UPS Alarm (UPS-MIB::BuildingAlarm) has cleared.'
116
+# Note: net_snmp_perl_enable *must* be enabled
117
+translate_value_oids = 1
118
+
119
+# Configures how the symbolic enterprise OID will be displayed for $E.
120
+# Set to 1, 2, 3 or 4.  See translate_value_oids options 1,2,3 and 4.
121
+# Note: net_snmp_perl_enable *must* be enabled
122
+translate_enterprise_oid_format = 1
123
+
124
+# Configures how the symbolic trap OID will be displayed for $O.
125
+# Set to 1, 2, 3 or 4.  See translate_value_oids options 1,2,3 and 4.
126
+# Note: net_snmp_perl_enable *must* be enabled
127
+translate_trap_oid_format = 1
128
+
129
+# Configures how the symbolic trap OID will be displayed for $v, $-n, $+n, $-* and $+*.
130
+# Set to 1, 2, 3 or 4.  See translate_value_oids options 1,2,3 and 4.
131
+# Note: net_snmp_perl_enable *must* be enabled
132
+translate_varname_oid_format = 1
133
+
134
+# Set to 0 to disable converting INTEGER values to enumeration tags as defined in the
135
+# MIB files
136
+# Set to 1 to enable converting INTEGER values to enumeration tags as defined in the
137
+# MIB files
138
+# Example: moverDoorState:open instead of moverDoorState:2
139
+# Note: net_snmp_perl_enable *must* be enabled
140
+translate_integers = 1
141
+
142
+# Allows you to set the MIBS environment variable used by SNMPTT
143
+# Leave blank or comment out to have the systems enviroment settings used
144
+# To have all MIBS processed, set to ALL
145
+# See the snmp.conf manual page for more info
146
+#mibs_environment = ALL
147
+
148
+# Set what is used to separate variables when wildcards are expanded on the FORMAT /
149
+# EXEC line.  Defaults to a space.  Value MUST be within quotes.  Can contain 1 or
150
+# more characters
151
+wildcard_expansion_separator = " "
152
+
153
+# Set to 1 to allow unsafe REGEX code to be executed.
154
+# Set to 0 to prevent unsafe REGEX code from being executed (default).
155
+# Enabling unsafe REGEX code will allow variable interopolation and the use of the e
156
+# modifier to allow statements such as substitution with captures such
157
+# as:            (one (two) three)(five $1 six)
158
+# which outputs: five two six
159
+# or:            (one (two) three)("five ".length($1)." six")e
160
+# which outputs: five 3 six
161
+#
162
+# This is considered unsafe because the contents of the regular expression
163
+# (right) is executed (eval) by Perl which *could contain unsafe code*.
164
+# BE SURE THAT THE SNMPTT CONFIGURATION FILES ARE SECURE!
165
+allow_unsafe_regex = 0
166
+
167
+# Set to 1 to have the backslash (escape) removed from quotes passed from
168
+# snmptrapd.  For example, \" would be changed to just "
169
+# Set to 0 to disable
170
+remove_backslash_from_quotes = 0
171
+
172
+# Set to 1 to have NODES files loaded each time a trap is processed.
173
+# Set to 0 to have all NODES files loaded when the snmptt.conf files are loaded.
174
+# If NODES files are used (files that contain lists of NODES), then setting to 1
175
+# will cause the list to be loaded each time an EVENT is processed that uses
176
+# NODES files.  This will allow the NODES file to be modified while SNMPTT is
177
+# running but can result in many file reads depending on the number of traps
178
+# received.  Defaults to 0
179
+dynamic_nodes = 0
180
+
181
+# This option allows you to use the $D substitution variable to include the
182
+# description text from the SNMPTT.CONF or MIB files.
183
+# Set to 0 to disable the $D substitution variable.  If $D is used, nothing
184
+#  will be outputted.
185
+# Set to 1 to enable the $D substitution variable and have it use the
186
+#  descriptions stored in the SNMPTT .conf files.  Enabling this option can
187
+#  greatly increase the amount of memory used by SNMPTT.
188
+# Set to 2 to enable the $D substitution variable and have it use the
189
+#  description from the MIB files.  This enables the UCD-SNMP / NET-SNMP Perl
190
+#  module save_descriptions variable.  Enabling this option can greatly
191
+#  increase the amount of memory used by the Net-SNMP SNMP Perl module, which
192
+#  will result in an increase of memory usage by SNMPTT.
193
+description_mode = 0
194
+
195
+# Set to 1 to remove any white space at the start of each line from the MIB
196
+# or SNMPTT.CONF description when description_mode is set to 1 or 2.
197
+description_clean = 1
198
+
199
+# Warning: Experimental.  Not recommended for production environments.
200
+#          When threads are enabled, SNMPTT may quit unexpectedly.
201
+# Set to 1 to enable threads (ithreads) in Perl 5.6.0 or higher.  If enabled,
202
+# EXEC will launch in a thread to allow SNMPTT to continue processing other
203
+# traps.  See also threads_max.
204
+# Set to 0 to disable threads (ithreads).
205
+# Defaults to 0
206
+threads_enable = 0
207
+
208
+# Warning: Experimental.  Not recommended for production environments.
209
+#          When threads are enabled, SNMPTT may quit unexpectedly.
210
+# This option allows you to set the maximum number of threads that will
211
+# execute at once.  Defaults to 10
212
+threads_max = 10
213
+
214
+# The date format for $x in strftime() format.  If not defined, defaults
215
+# to %a %b %e %Y.
216
+#date_format = %a %b %e %Y
217
+
218
+# The time format for $X in strftime() format.  If not defined, defaults
219
+# to %H:%M:%S.
220
+#time_format = %H:%M:%S
221
+
222
+# The date time format in strftime() format for the date/time when logging
223
+# to standard output, snmptt log files (log_file) and the unknown log file
224
+# (unknown_trap_log_file).  Defaults to localtime().  For SQL, see
225
+# date_time_format_sql.
226
+# Example:  %a %b %e %Y %H:%M:%S
227
+date_time_format = %H:%M:%S %Y/%m/%d
228
+
229
+[DaemonMode]
230
+# Set to 1 to have snmptt fork to the background when run in daemon mode
231
+# Ignored by Windows.  See documentation
232
+daemon_fork = 1
233
+
234
+# Set to the numerical user id (eg: 500) or textual user id (eg: snmptt)
235
+# that snmptt should change to when running in daemon mode.  Leave blank
236
+# to disable.  The user used should have read/write access to all log
237
+# files, the spool folder, and read access to the configuration files.
238
+# Only use this if you are starting snmptt as root.
239
+# A second (child) process will be started as the daemon_uid user so
240
+# there will be two snmptt processes running.  The first process will
241
+# continue to run as the user that ran snmptt (root), waiting for the
242
+# child to quit.  After the child quits, the parent process will remove
243
+# the snmptt.pid file and exit.
244
+daemon_uid = snmptt
245
+
246
+# Complete path of file to store process ID when running in daemon mode.
247
+pid_file = /var/run/snmptt.pid
248
+
249
+# Directory to read received traps from.  Ex: /var/spool/snmptt/
250
+# Don't forget the trailing slash!
251
+spool_directory = /var/spool/snmptt/
252
+
253
+# Amount of time in seconds to sleep between processing spool files
254
+sleep = 5
255
+
256
+# Set to 1 to have SNMPTT use the time that the trap was processed by SNMPTTHANDLER
257
+# Set to 0 to have SNMPTT use the time the trap was processed.  Note:  Using 0 can
258
+# result in the time being off by the number of seconds used for 'sleep'
259
+use_trap_time = 1
260
+
261
+# Set to 0 to have SNMPTT erase the spooled trap file after it attempts to process
262
+# the trap even if it did not successfully log the trap to any of the log systems.
263
+# Set to 1 to have SNMPTT erase the spooled trap file only after it successfully
264
+# logs to at least ONE log system.
265
+# Set to 2 to have SNMPTT erase the spooled trap file only after it successfully
266
+# logs to ALL of the enabled log systems.  Warning:  If multiple log systems are
267
+# enabled and only one fails, the other log system will continuously be logged to
268
+# until ALL of the log systems function.
269
+# The recommended setting is 1 with only one log system enabled.
270
+keep_unlogged_traps = 1
271
+
272
+# How often duplicate traps will be processed.  An MD5 hash of all incoming traps
273
+# is stored in memory and is used to check for duplicates.  All variables except for
274
+# the uptime variable are used when calculating the MD5.  The larger this variable,
275
+# the more memory snmptt will require.
276
+# Note:  In most cases it may be a good idea to enable this but sometimes it can have a
277
+#        negative effect.  For example, if you are trying to troubleshoot a wireless device
278
+#        that keeps losing it's connection you may want to disable this so that you see
279
+#        all the associations and disassociations.
280
+# 5 minutes = 300
281
+# 10 minutes = 600
282
+# 15 minutes = 900
283
+duplicate_trap_window = 0
284
+
285
+[Logging]
286
+# Set to 1 to enable messages to be sent to standard output, or 0 to disable.
287
+# Would normally be disabled unless you are piping this program to another
288
+stdout_enable = 0
289
+
290
+# Set to 1 to enable text logging of *TRAPS*.  Make sure you specify a log_file
291
+# location
292
+log_enable = 1
293
+
294
+# Log file location.  The COMPLETE path and filename.  Ex: '/var/log/snmptt/snmptt.log'
295
+log_file = /var/log/snmptt/snmptt.log
296
+
297
+# Set to 1 to enable text logging of *SNMPTT system errors*.  Make sure you
298
+# specify a log_system_file location
299
+log_system_enable = 1
300
+
301
+# Log file location.  The COMPLETE path and filename.
302
+# Ex: '/var/log/snmptt/snmpttsystem.log'
303
+log_system_file = /var/log/snmptt/snmpttsystem.log
304
+
305
+# Set to 1 to enable logging of unknown traps.  This should normally be left off
306
+# as the file could grow large quickly.  Used primarily for troubleshooting.  If
307
+# you have defined a trap in snmptt.conf, but it is not executing, enable this to
308
+# see if it is being considered an unknown trap due to an incorrect entry or
309
+# simply missing from the snmptt.conf file.
310
+# Unknown traps can be logged either a text file, a SQL table or both.
311
+# See SQL section to define a SQL table to log unknown traps to.
312
+unknown_trap_log_enable = 0
313
+
314
+# Unknown trap log file location.  The COMPLETE path and filename.
315
+# Ex: '/var/log/snmptt/snmpttunknown.log'
316
+# Leave blank to disable logging to text file if logging to SQL is enabled
317
+# for unknown traps
318
+unknown_trap_log_file = /var/log/snmptt/snmpttunknown.log
319
+
320
+# How often in seconds statistics should be logged to syslog or the event log.
321
+# Set to 0 to disable
322
+# 1 hour = 216000
323
+# 12 hours = 2592000
324
+# 24 hours = 5184000
325
+statistics_interval = 0
326
+
327
+# Set to 1 to enable logging of *TRAPS* to syslog.  If you do not have the Sys::Syslog
328
+# module then disable this.  Windows users should disable this.
329
+syslog_enable = 1
330
+
331
+# Syslog facility to use for logging of *TRAPS*.  For example: 'local0'
332
+syslog_facility = local0
333
+
334
+# Set the syslog level for *TRAPS* based on the severity level of the trap
335
+# as defined in the snmptt.conf file.  Values must be one per line between
336
+# the syslog_level_* and END lines, and are not case sensitive.  For example:
337
+#   Warning
338
+#   Critical
339
+# Duplicate definitions will use the definition with the higher severity.
340
+syslog_level_debug = <<END
341
+END
342
+syslog_level_info = <<END
343
+END
344
+syslog_level_notice = <<END
345
+END
346
+syslog_level_warning = <<END
347
+END
348
+syslog_level_err = <<END
349
+END
350
+syslog_level_crit = <<END
351
+END
352
+syslog_level_alert = <<END
353
+END
354
+
355
+# Syslog default level to use for logging of *TRAPS*.  For example: warning
356
+# Valid values: emerg, alert, crit, err, warning, notice, info, debug
357
+syslog_level = warning
358
+
359
+# Set to 1 to enable logging of *SNMPTT system errors* to syslog.  If you do not have the
360
+# Sys::Syslog module then disable this.  Windows users should disable this.
361
+syslog_system_enable = 1
362
+
363
+# Syslog facility to use for logging of *SNMPTT system errors*.  For example: 'local0'
364
+syslog_system_facility = local0
365
+
366
+# Syslog level to use for logging of *SNMPTT system errors*..  For example: 'warning'
367
+# Valid values: emerg, alert, crit, err, warning, notice, info, debug
368
+syslog_system_level = warning
369
+
370
+[SQL]
371
+# Determines if the enterprise column contains the numeric OID or symbolic OID
372
+# Set to 0 for numeric OID
373
+# Set to 1 for symbolic OID
374
+# Uses translate_enterprise_oid_format to determine format
375
+# Note: net_snmp_perl_enable *must* be enabled
376
+db_translate_enterprise = 0
377
+
378
+# FORMAT line to use for unknown traps.  If not defined, defaults to $-*.
379
+db_unknown_trap_format = '$-*'
380
+
381
+# List of custom SQL column names and values for the table of received traps
382
+# (defined by *_table below).  The format is
383
+#   column name
384
+#   value
385
+#
386
+# For example:
387
+#
388
+#   binding_count
389
+#   $#
390
+#   uptime2
391
+#   The agent has been up for $T.
392
+sql_custom_columns = <<END
393
+END
394
+
395
+# List of custom SQL column names and values for the table of unknown traps
396
+# (defined by *_table_unknown below).  See sql_custom_columns for the format.
397
+sql_custom_columns_unknown = <<END
398
+END
399
+
400
+# MySQL: Set to 1 to enable logging to a MySQL database via DBI (Linux / Windows)
401
+# This requires DBI:: and DBD::mysql
402
+mysql_dbi_enable = 0
403
+
404
+# MySQL: Hostname of database server (optional - default localhost)
405
+mysql_dbi_host = localhost
406
+
407
+# MySQL: Port number of database server (optional - default 3306)
408
+mysql_dbi_port = 3306
409
+
410
+# MySQL: Database to use
411
+mysql_dbi_database = snmptt
412
+
413
+# MySQL: Table to use
414
+mysql_dbi_table = snmptt
415
+
416
+# MySQL: Table to use for unknown traps
417
+# Leave blank to disable logging of unknown traps to MySQL
418
+# Note: unknown_trap_log_enable must be enabled.
419
+mysql_dbi_table_unknown = snmptt_unknown
420
+
421
+# MySQL: Table to use for statistics
422
+# Note: statistics_interval must be set.  See also stat_time_format_sql.
423
+#mysql_dbi_table_statistics = snmptt_statistics
424
+mysql_dbi_table_statistics =
425
+
426
+# MySQL: Username to use
427
+mysql_dbi_username = snmpttuser
428
+
429
+# MySQL: Password to use
430
+mysql_dbi_password = password
431
+
432
+# MySQL: Whether or not to 'ping' the database before attempting an INSERT
433
+# to ensure the connection is still valid.  If *any* error is generate by
434
+# the ping such as 'Unable to connect to database', it will attempt to
435
+# re-create the database connection.
436
+# Set to 0 to disable
437
+# Set to 1 to enable
438
+# Note:  This has no effect on mysql_ping_interval.
439
+mysql_ping_on_insert = 1
440
+
441
+# MySQL: How often in seconds the database should be 'pinged' to ensure the
442
+# connection is still valid.  If *any* error is generate by the ping such as
443
+# 'Unable to connect to database', it will attempt to re-create the database
444
+# connection.  Set to 0 to disable pinging.
445
+# Note:  This has no effect on mysql_ping_on_insert.
446
+# disabled = 0
447
+# 5 minutes = 300
448
+# 15 minutes = 900
449
+# 30 minutes = 1800
450
+mysql_ping_interval = 300
451
+
452
+# PostgreSQL: Set to 1 to enable logging to a PostgreSQL database via DBI (Linux / Windows)
453
+# This requires DBI:: and DBD::PgPP
454
+postgresql_dbi_enable = 0
455
+
456
+# Set to 0 to use the DBD::PgPP module
457
+# Set to 1 to use the DBD::Pg module
458
+postgresql_dbi_module = 0
459
+
460
+# Set to 0 to disable host and port network support
461
+# Set to 1 to enable host and port network support
462
+# If set to 1, ensure PostgreSQL is configured to allow connections via TCPIP by setting
463
+# tcpip_socket = true in the $PGDATA/postgresql.conf file, and adding the ip address of
464
+# the SNMPTT server to $PGDATApg_hba.conf.  The common location for the config files for
465
+# RPM installations of PostgreSQL is /var/lib/pgsql/data.
466
+postgresql_dbi_hostport_enable = 0
467
+
468
+# PostgreSQL: Hostname of database server (optional - default localhost)
469
+postgresql_dbi_host = localhost
470
+
471
+# PostgreSQL: Port number of database server (optional - default 5432)
472
+postgresql_dbi_port = 5432
473
+
474
+# PostgreSQL: Database to use
475
+postgresql_dbi_database = snmptt
476
+
477
+# PostgreSQL: Table to use for unknown traps
478
+# Leave blank to disable logging of unknown traps to PostgreSQL
479
+# Note: unknown_trap_log_enable must be enabled.
480
+postgresql_dbi_table_unknown = snmptt_unknown
481
+
482
+# PostgreSQL: Table to use for statistics
483
+# Note: statistics_interval must be set.  See also stat_time_format_sql.
484
+#postgresql_dbi_table_statistics = snmptt_statistics
485
+postgresql_dbi_table_statistics =
486
+
487
+# PostgreSQL: Table to use
488
+postgresql_dbi_table = snmptt
489
+
490
+# PostgreSQL: Username to use
491
+postgresql_dbi_username = snmpttuser
492
+
493
+# PostgreSQL: Password to use
494
+postgresql_dbi_password = password
495
+
496
+# PostgreSQL: Whether or not to 'ping' the database before attempting an INSERT
497
+# to ensure the connection is still valid.  If *any* error is generate by
498
+# the ping such as 'Unable to connect to database', it will attempt to
499
+# re-create the database connection.
500
+# Set to 0 to disable
501
+# Set to 1 to enable
502
+# Note:  This has no effect on postgresqll_ping_interval.
503
+postgresql_ping_on_insert = 1
504
+
505
+# PostgreSQL: How often in seconds the database should be 'pinged' to ensure the
506
+# connection is still valid.  If *any* error is generate by the ping such as
507
+# 'Unable to connect to database', it will attempt to re-create the database
508
+# connection.  Set to 0 to disable pinging.
509
+# Note:  This has no effect on postgresql_ping_on_insert.
510
+# disabled = 0
511
+# 5 minutes = 300
512
+# 15 minutes = 900
513
+# 30 minutes = 1800
514
+postgresql_ping_interval = 300
515
+
516
+# ODBC: Set to 1 to enable logging to a database via ODBC using DBD::ODBC.
517
+# This requires both DBI:: and DBD::ODBC
518
+dbd_odbc_enable = 0
519
+
520
+# DBD:ODBC: Database to use
521
+dbd_odbc_dsn = snmptt
522
+
523
+# DBD:ODBC: Table to use
524
+dbd_odbc_table = snmptt
525
+
526
+# DBD:ODBC: Table to use for unknown traps
527
+# Leave blank to disable logging of unknown traps to DBD:ODBC
528
+# Note: unknown_trap_log_enable must be enabled.
529
+dbd_odbc_table_unknown = snmptt_unknown
530
+
531
+# DBD:ODBC: Table to use for statistics
532
+# Note: statistics_interval must be set.  See also stat_time_format_sql.
533
+#dbd_odbc_table_statistics = snmptt_statistics
534
+dbd_odbc_table_statistics =
535
+
536
+# DBD:ODBC: Username to use
537
+dbd_odbc_username = snmptt
538
+
539
+# DBD:DBC:: Password to use
540
+dbd_odbc_password = password
541
+
542
+
543
+# DBD:ODBC: Whether or not to 'ping' the database before attempting an INSERT
544
+# to ensure the connection is still valid.  If *any* error is generate by
545
+# the ping such as 'Unable to connect to database', it will attempt to
546
+# re-create the database connection.
547
+# Set to 0 to disable
548
+# Set to 1 to enable
549
+# Note:  This has no effect on dbd_odbc_ping_interval.
550
+dbd_odbc_ping_on_insert = 1
551
+
552
+# DBD:ODBC:: How often in seconds the database should be 'pinged' to ensure the
553
+# connection is still valid.  If *any* error is generate by the ping such as
554
+# 'Unable to connect to database', it will attempt to re-create the database
555
+# connection.  Set to 0 to disable pinging.
556
+# Note:  This has no effect on dbd_odbc_ping_on_insert.
557
+# disabled = 0
558
+# 5 minutes = 300
559
+# 15 minutes = 900
560
+# 30 minutes = 1800
561
+dbd_odbc_ping_interval = 300
562
+
563
+# The date time format for the traptime column in SQL.  Defaults to
564
+# localtime().  When a date/time field is used in SQL, this should
565
+# be changed to follow a standard that is supported by the SQL server.
566
+# Example:  For a MySQL DATETIME, use %Y-%m-%d %H:%M:%S.
567
+#date_time_format_sql =
568
+
569
+# The date time format for the stat_time column in SQL.  Defaults to
570
+# localtime().  When a date/time field is used in SQL, this should
571
+# be changed to follow a standard that is supported by the SQL server.
572
+# Example:  For a MySQL DATETIME, use %Y-%m-%d %H:%M:%S.
573
+#stat_time_format_sql =
574
+
575
+[Exec]
576
+
577
+# Set to 1 to allow EXEC statements to execute.  Should normally be left on unless you
578
+# want to temporarily disable all EXEC commands
579
+exec_enable = 1
580
+
581
+# Set to 1 to allow PREEXEC statements to execute.  Should normally be left on unless you
582
+# want to temporarily disable all PREEXEC commands
583
+pre_exec_enable = 1
584
+
585
+# If defined, the following command will be executed for ALL unknown traps.  Passed to the
586
+# command will be all standard and enterprise variables, similar to unknown_trap_log_file
587
+# but without the newlines.
588
+unknown_trap_exec =
589
+
590
+# FORMAT line that is passed to the unknown_trap_exec command.  If not defined, it
591
+# defaults to what is described in the unknown_trap_exec setting.  The following
592
+# would be *similar* to the default described in the unknown_trap_exec setting
593
+# (all on one line):
594
+# $x !! $X: Unknown trap ($o) received from $A at: Value 0: $A Value 1: $aR
595
+# Value 2: $T Value 3: $o Value 4: $aA Value 5: $C Value 6: $e Ent Values: $+*
596
+unknown_trap_exec_format =
597
+
598
+# Set to 1 to escape wildards (* and ?) in EXEC, PREEXEC and the unknown_trap_exec
599
+# commands.  Enable this to prevent the shell from expanding the wildcard
600
+# characters.  The default is 1.
601
+exec_escape = 1
602
+
603
+[Debugging]
604
+# 0 - do not output messages
605
+# 1 - output some basic messages
606
+# 2 - out all messages
607
+DEBUGGING = 0
608
+
609
+# Debugging file - SNMPTT
610
+# Location of debugging output file.  Leave blank to default to STDOUT (good for
611
+# standalone mode, or daemon mode without forking)
612
+DEBUGGING_FILE =
613
+# DEBUGGING_FILE = /var/log/snmptt/snmptt.debug
614
+
615
+# Debugging file - SNMPTTHANDLER
616
+# Location of debugging output file.  Leave blank to default to STDOUT
617
+DEBUGGING_FILE_HANDLER =
618
+# DEBUGGING_FILE_HANDLER = /var/log/snmptt/snmptthandler.debug
619
+
620
+[TrapFiles]
621
+# A list of snmptt.conf files (this is NOT the snmptrapd.conf file).  The COMPLETE path
622
+# and filename.  Ex: '/etc/snmp/snmptt.conf'
623
+snmptt_conf_files = <<END
624
+/etc/snmp/snmptt.conf
625
+END
626
+

+ 51
- 0
deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/init.pp View File

@@ -0,0 +1,51 @@
1
+#
2
+#    Copyright 2015 Mirantis, Inc.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+class plugin_zabbix_snmptrapd {
17
+
18
+  include plugin_zabbix_snmptrapd::params
19
+
20
+  $service_name    = $plugin_zabbix_snmptrapd::params::service_name
21
+  $server_ip       = hiera('management_vip')
22
+  $plugin_settings = hiera('zabbix_snmptrapd')
23
+
24
+  class { 'snmp':
25
+    snmptrapdaddr       => ["udp:${server_ip}:162"],
26
+    ro_community        => $plugin_settings['community'],
27
+    service_ensure      => 'stopped',
28
+    trap_service_ensure => 'running',
29
+    trap_service_enable => true,
30
+    trap_handlers       => ['default /usr/sbin/snmptthandler'],
31
+  }
32
+
33
+  file { "/etc/init.d/${service_name}":
34
+    ensure  => present,
35
+    owner   => 'root',
36
+    group   => 'root',
37
+    mode    => '0755',
38
+    source  => "puppet:///modules/plugin_zabbix_snmptrapd/initscripts/${service_name}",
39
+    require => Class['snmp'],
40
+    notify  => Service[$service_name],
41
+  }
42
+
43
+  class { 'plugin_zabbix_snmptrapd::snmptt':
44
+    require => Class['snmp'],
45
+  }
46
+
47
+  class { 'plugin_zabbix_snmptrapd::zabbix':
48
+    require => Class['plugin_zabbix_snmptrapd::snmptt'],
49
+  }
50
+
51
+}

+ 30
- 0
deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/params.pp View File

@@ -0,0 +1,30 @@
1
+#
2
+#    Copyright 2015 Mirantis, Inc.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+class plugin_zabbix_snmptrapd::params {
17
+
18
+  case $::osfamily {
19
+    'Debian': {
20
+      $service_name = 'snmpd'
21
+    }
22
+    'RedHat': {
23
+      $service_name = 'snmptrapd'
24
+    }
25
+    default: {
26
+      fail("unsuported osfamily ${::osfamily}, currently Debian and RedHat are the only supported platforms")
27
+    }
28
+  }
29
+
30
+}

+ 62
- 0
deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/snmptt.pp View File

@@ -0,0 +1,62 @@
1
+#
2
+#    Copyright 2015 Mirantis, Inc.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+class plugin_zabbix_snmptrapd::snmptt {
17
+
18
+  if $::osfamily == 'RedHat' {
19
+    package { 'net-snmp-perl':
20
+      ensure => present,
21
+      before => Package['snmptt'],
22
+    }
23
+  }
24
+
25
+  package { 'snmptt':
26
+    ensure   => present,
27
+  }
28
+
29
+  service { 'snmptt':
30
+    ensure   => running,
31
+    enable   => true,
32
+    require  => Package['snmptt'],
33
+  }
34
+
35
+  file { '/etc/snmp/snmptt.ini':
36
+    ensure   => present,
37
+    mode     => '0644',
38
+    owner    => 'root',
39
+    group    => 'root',
40
+    source   => 'puppet:///modules/plugin_zabbix_snmptrapd/snmptt.ini',
41
+    require  => Package['snmptt'],
42
+    notify   => Service['snmptt'],
43
+  }
44
+
45
+  file { '/etc/snmp/snmptt.conf':
46
+    ensure   => present,
47
+    mode     => '0644',
48
+    owner    => 'root',
49
+    group    => 'root',
50
+    source   => 'puppet:///modules/plugin_zabbix_snmptrapd/snmptt.conf',
51
+    require  => Package['snmptt'],
52
+    notify   => Service['snmptt'],
53
+  }
54
+
55
+  file_line { 'in logrotate disable compressing of snmptt logfiles':
56
+    path     => '/etc/logrotate.d/snmptt',
57
+    match    => 'compress',
58
+    line     => 'nocompress',
59
+    require  => Package['snmptt'],
60
+  }
61
+
62
+}

+ 38
- 0
deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/zabbix.pp View File

@@ -0,0 +1,38 @@
1
+#
2
+#    Copyright 2015 Mirantis, Inc.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+class plugin_zabbix_snmptrapd::zabbix {
17
+
18
+  file_line { 'enable SNMPTrapper in Zabbix':
19
+    path     => '/etc/zabbix/zabbix_server.conf',
20
+    match    => 'StartSNMPTrapper',
21
+    line     => 'StartSNMPTrapper=1',
22
+    notify   => Service['p_zabbix-server'],
23
+  }
24
+
25
+  file_line { 'set SNMPTrapperFile in Zabbix':
26
+    path     => '/etc/zabbix/zabbix_server.conf',
27
+    match    => 'SNMPTrapperFile',
28
+    line     => 'SNMPTrapperFile=/var/log/snmptt/snmptt.log',
29
+    notify   => Service['p_zabbix-server'],
30
+  }
31
+
32
+  service { 'p_zabbix-server':
33
+    ensure   => running,
34
+    enable   => true,
35
+    provider => 'pacemaker',
36
+  }
37
+
38
+}

+ 12
- 0
environment_config.yaml View File

@@ -0,0 +1,12 @@
1
+attributes:
2
+  metadata:
3
+    restrictions:
4
+      - condition: "settings:zabbix_monitoring.metadata.enabled == false"
5
+        action: disable
6
+        message: "This plugin requires Zabbix plugin"
7
+  community:
8
+    value: "public"
9
+    label: "SNMP community"
10
+    description: "SNMP community for traps authorization"
11
+    weight: 10
12
+    type: "password"

+ 33
- 0
metadata.yaml View File

@@ -0,0 +1,33 @@
1
+# Plugin name
2
+name: zabbix_snmptrapd
3
+title: SNMP trap daemon for Zabbix plugin
4
+# Plugin version
5
+version: 1.0.0
6
+# Description
7
+description: Gives ability to receive SNMP traps and pass them to Zabbix.
8
+# Required fuel version
9
+fuel_version: ['6.1']
10
+# Groups
11
+groups: []
12
+# Licenses
13
+licenses: ['Apache License, Version 2.0']
14
+# Homepage
15
+homepage: 'https://github.com/stackforge/fuel-plugin-zabbix-snmptrapd'
16
+# Authors
17
+authors: ['Dmitry Klenov <dklenov@mirantis.com>', 'Piotr Misiak <pmisiak@mirantis.com>', 'Szymon Banka <sbanka@mirantis.com>', 'Alexander Zatserklyany <azatserklyany@mirantis.com>']
18
+
19
+# The plugin is compatible with releases in the list
20
+releases:
21
+  - os: ubuntu
22
+    version: 2014.2-6.1
23
+    mode: ['ha']
24
+    deployment_scripts_path: deployment_scripts/
25
+    repository_path: repositories/ubuntu
26
+  - os: centos
27
+    version: 2014.2-6.1
28
+    mode: ['ha']
29
+    deployment_scripts_path: deployment_scripts/
30
+    repository_path: repositories/centos
31
+
32
+# Version of plugin package
33
+package_version: '2.0.0'

+ 43
- 0
pre_build_hook View File

@@ -0,0 +1,43 @@
1
+#!/bin/bash
2
+set -eux
3
+
4
+ROOT="$(dirname `readlink -f $0`)"
5
+RPM_REPO="${ROOT}"/repositories/centos
6
+DEB_REPO="${ROOT}"/repositories/ubuntu
7
+MODULES="${ROOT}"/deployment_scripts/puppet/modules
8
+SNMP_TARBALL_URL="https://forgeapi.puppetlabs.com/v3/files/razorsedge-snmp-3.3.1.tar.gz"
9
+mkdir -p $RPM_REPO
10
+mkdir -p $DEB_REPO
11
+mkdir -p $MODULES
12
+
13
+# Downloads needed RPM or DEB packages
14
+function download {
15
+    case "$1" in
16
+        deb) REPO=$DEB_REPO;;
17
+        rpm) REPO=$RPM_REPO;;
18
+    esac
19
+    shift
20
+
21
+    while [ $# -gt 0 ]; do
22
+        FILE=$(basename "$1")
23
+        wget -qO - $1 > "$REPO/$FILE"
24
+        shift
25
+    done
26
+}
27
+
28
+download rpm http://mirror.centos.org/centos/6/updates/x86_64/Packages/net-snmp-5.5-50.el6_6.1.x86_64.rpm \
29
+             http://mirror.centos.org/centos/6/updates/x86_64/Packages/net-snmp-libs-5.5-50.el6_6.1.x86_64.rpm \
30
+             http://mirror.centos.org/centos/6/updates/x86_64/Packages/net-snmp-perl-5.5-50.el6_6.1.x86_64.rpm \
31
+             http://mirror.centos.org/centos/6/os/x86_64/Packages/perl-Digest-HMAC-1.01-22.el6.noarch.rpm \
32
+             http://mirror.centos.org/centos/6/os/x86_64/Packages/perl-Digest-SHA1-2.12-2.el6.x86_64.rpm \
33
+             http://mirror.centos.org/centos/6/os/x86_64/Packages/perl-IO-stringy-2.110-10.1.el6.noarch.rpm \
34
+             http://mirror.centos.org/centos/6/os/x86_64/Packages/perl-List-MoreUtils-0.22-10.el6.x86_64.rpm \
35
+             http://dl.fedoraproject.org/pub/epel/6/x86_64/snmptt-1.4-0.9.beta2.el6.noarch.rpm \
36
+             http://dl.fedoraproject.org/pub/epel/6/x86_64/perl-Crypt-DES-2.05-9.el6.x86_64.rpm \
37
+             http://dl.fedoraproject.org/pub/epel/6/x86_64/perl-Config-IniFiles-2.72-2.el6.noarch.rpm \
38
+             http://dl.fedoraproject.org/pub/epel/6/x86_64/perl-Net-SNMP-5.2.0-4.el6.noarch.rpm
39
+
40
+#download snmp module
41
+mkdir -p "${MODULES}/snmp"
42
+wget -qO- "${SNMP_TARBALL_URL}" | tar -C "${MODULES}/snmp" --strip-components=1 -xz
43
+

+ 0
- 0
repositories/centos/.gitkeep View File


+ 0
- 0
repositories/ubuntu/.gitkeep View File


+ 7
- 0
tasks.yaml View File

@@ -0,0 +1,7 @@
1
+- role: ['primary-controller', 'controller']
2
+  stage: post_deployment/8110
3
+  type: puppet
4
+  parameters:
5
+    puppet_manifest: puppet/manifests/controller.pp
6
+    puppet_modules: puppet/modules:/etc/puppet/modules
7
+    timeout: 1200

Loading…
Cancel
Save