summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/Makefile.am8
-rw-r--r--config/NAGIOS-NOTIFY-MIB620
-rw-r--r--config/NAGIOS-ROOT-MIB87
-rw-r--r--config/gluster-commands.cfg10
-rw-r--r--config/gluster-contacts.cfg12
-rw-r--r--config/gluster-templates.cfg26
-rw-r--r--config/snmpmanagers.cfg5
-rw-r--r--configure.ac3
-rw-r--r--nagios-server-addons.spec.in2
-rw-r--r--plugins/Makefile.am2
-rwxr-xr-xplugins/hostsnmptrapgenerator.py.in109
-rwxr-xr-xplugins/servicesnmptrapgenerator.py.in108
-rw-r--r--tests/test_gluster_host_service_handler.py4
13 files changed, 985 insertions, 11 deletions
diff --git a/config/Makefile.am b/config/Makefile.am
index 0f7f73a..4435879 100644
--- a/config/Makefile.am
+++ b/config/Makefile.am
@@ -6,6 +6,7 @@ glusternagiosconf_DATA = \
gluster-templates.cfg \
gluster-contacts.cfg \
host-monitoring-services.in \
+ snmpmanagers.cfg \
$(NULL)
glusternagiosdefaultconfdir = $(sysconfdir)/nagios/gluster/default
@@ -15,7 +16,14 @@ glusternagiosdefaultconf_DATA = \
node1.cfg \
$(NULL)
+glusternagiosmibsdir = /usr/share/snmp/mibs
+glusternagiosmibs_DATA = \
+ NAGIOS-NOTIFY-MIB \
+ NAGIOS-ROOT-MIB \
+ $(NULL)
+
EXTRA_DIST = \
$(glusternagiosconf_DATA) \
$(glusternagiosdefaultconf_DATA) \
+ $(glusternagiosmibs_DATA) \
$(NULL)
diff --git a/config/NAGIOS-NOTIFY-MIB b/config/NAGIOS-NOTIFY-MIB
new file mode 100644
index 0000000..03b4c07
--- /dev/null
+++ b/config/NAGIOS-NOTIFY-MIB
@@ -0,0 +1,620 @@
+NAGIOS-NOTIFY-MIB DEFINITIONS ::= BEGIN
+ IMPORTS
+ MODULE-IDENTITY, OBJECT-TYPE, NOTIFICATION-TYPE,
+ Integer32, Gauge32
+ FROM SNMPv2-SMI
+ nagios,NotifyType,HostStateID,HostStateType,ServiceStateID
+ FROM NAGIOS-ROOT-MIB;
+
+nagiosNotify MODULE-IDENTITY
+ LAST-UPDATED "200503090000Z" -- March 9, 2005
+ ORGANIZATION "Nagios"
+ CONTACT-INFO
+ " Subhendu Ghosh
+
+ Telephone: +1 201 232 2851
+ Email: sghosh@users.sourceforge.net
+
+ Nagios Information:
+ http://www.nagios.org
+ "
+ DESCRIPTION
+ "Objects for Nagios(tm) events. There are 2 primary tables
+ reflecting the division in Nagios for Host events and
+ Service events.
+
+ The event tables are extended by the HostNotifyTable and the
+ ServiceNotifyTable to keep track of the notifications based on events.
+
+ The tables entries themselves are not accessible but are used for OID
+ entries for TRAP/INFORM notifications.
+
+ These objects are based on the macros defined in Nagios v2.0
+ "
+ REVISION "200503090000Z" -- March 9, 2005
+ DESCRIPTION
+ "Spell check"
+ REVISION "200501200000Z" --January 20, 2005
+ DESCRIPTION
+ "Initial Version"
+ ::= { nagios 1 }
+
+
+nagiosHostEventTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF HostEventEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of Nagios host events"
+ ::= { nagiosNotify 1 }
+
+HostEventEntry ::= SEQUENCE {
+ nHostEventIndex Integer32,
+ nHostname OCTET STRING,
+ nHostAlias OCTET STRING,
+ nHostStateID HostStateID,
+ nHostStateType HostStateType,
+ nHostAttempt Integer32,
+ nHostDurationSec Integer32,
+ nHostGroupName OCTET STRING,
+ nHostLastCheck INTEGER,
+ nHostLastChange INTEGER,
+ nHostLastUp INTEGER,
+ nHostLastDown INTEGER,
+ nHostLastUnreachable INTEGER,
+ nHostOutput OCTET STRING,
+ nHostPerfData OCTET STRING
+ }
+
+nagiosHostEventEntry OBJECT-TYPE
+ SYNTAX HostEventEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Each notification event"
+ INDEX { nHostEventIndex }
+ ::= { nagiosHostEventTable 1 }
+
+nHostEventIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..65535)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "This object uniquely identifies this host event entry. It is generated
+ by the SNMP application and is not related to any Nagios data."
+ ::= { nagiosHostEventEntry 1 }
+
+nHostname OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Hostname as specified in the Nagios configuration file."
+ ::= { nagiosHostEventEntry 2 }
+
+nHostAlias OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The host alias as specified in the Nagios configuration file"
+ ::= { nagiosHostEventEntry 3 }
+
+nHostStateID OBJECT-TYPE
+ SYNTAX HostStateID
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The host state as defined by the HOSTSTATEID macro"
+ ::= { nagiosHostEventEntry 4 }
+
+nHostStateType OBJECT-TYPE
+ SYNTAX HostStateType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The host state as defined by the HOSTSTATETYPE macro"
+ ::= { nagiosHostEventEntry 5 }
+
+nHostAttempt OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of the current host check retry. For instance, if this is the
+ second time that the host is being rechecked, this will be the number two.
+ Current attempt number is really only useful when writing host event
+ handlers for soft states that take a specific action based on the host retry
+ number. The host state as defined by the HOSTSTATEID macro"
+ ::= { nagiosHostEventEntry 6 }
+
+nHostDurationSec OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "A number indicating the number of seconds that the host has spent in its
+ current state"
+ ::= { nagiosHostEventEntry 7 }
+
+nHostGroupName OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The short name of the hostgroup that this host belongs to. This value is
+ taken from the hostgroup_name directive in the hostgroup definition. If the
+ host belongs to more than one hostgroup this macro will contain the name of
+ just one of them."
+ ::= { nagiosHostEventEntry 8 }
+
+nHostLastCheck OBJECT-TYPE
+ SYNTAX INTEGER
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This is a timestamp in time_t format (seconds since the UNIX epoch)
+ indicating the time at which a check of the host was last performed."
+ ::= { nagiosHostEventEntry 9 }
+
+nHostLastChange OBJECT-TYPE
+ SYNTAX INTEGER
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This is a timestamp in time_t format (seconds since the UNIX epoch)
+ indicating the time the host last changed state."
+ ::= { nagiosHostEventEntry 10 }
+
+nHostLastUp OBJECT-TYPE
+ SYNTAX INTEGER
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This is a timestamp in time_t format (seconds since the UNIX epoch)
+ indicating the time at which the host was last detected as being in an UP
+ state."
+ ::= { nagiosHostEventEntry 11 }
+
+nHostLastDown OBJECT-TYPE
+ SYNTAX INTEGER
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This is a timestamp in time_t format (seconds since the UNIX epoch)
+ indicating the time at which the host was last detected as being in an
+ DOWN state."
+ ::= { nagiosHostEventEntry 12 }
+
+nHostLastUnreachable OBJECT-TYPE
+ SYNTAX INTEGER
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This is a timestamp in time_t format (seconds since the UNIX epoch)
+ indicating the time at which the host was last detected as being in an
+ UNREACHABLE state."
+ ::= { nagiosHostEventEntry 13 }
+
+nHostOutput OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The text output from the last host check (i.e. Ping OK)."
+ ::= { nagiosHostEventEntry 14 }
+
+nHostPerfData OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This object contains any performance data that may have been returned
+ by the last host check."
+ ::= { nagiosHostEventEntry 15 }
+
+
+
+--
+-- Host Notifications
+
+nagiosHostNotifyTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF HostNotifyEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of Nagios host notifications"
+ ::= {nagiosNotify 2}
+
+HostNotifyEntry ::= SEQUENCE {
+ nHostNotifyType NotifyType,
+ nHostNotifyNum Gauge32, -- was Integer32,
+ nHostAckAuthor OCTET STRING,
+ nHostAckComment OCTET STRING
+ }
+
+nagiosHostNotifyEntry OBJECT-TYPE
+ SYNTAX HostNotifyEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Nagios host notifications extends the nagiosHostEventTable when a
+ notification is generated for an event."
+ INDEX { nHostEventIndex }
+ ::= { nagiosHostNotifyTable 1 }
+
+nHostNotifyType OBJECT-TYPE
+ SYNTAX NotifyType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This identifies the type of notification that is being sent
+ (PROBLEM, RECOVERY, ACKNOWLEDGEMENT, FLAPPINGSTART or FLAPPINGSTOP)"
+ ::= { nagiosHostNotifyEntry 1 }
+
+nHostNotifyNum OBJECT-TYPE
+ SYNTAX Gauge32 -- was NotifyType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This identifies the current notification number for the service or host.
+ The notification number increases by one (1) each time a new notification
+ is sent out for a host or service (except for acknowledgements). The
+ notification number is reset to 0 when the host or service recovers
+ (after the recovery notification has gone out). Acknowledgements do not
+ cause the notification number to increase."
+ ::= { nagiosHostNotifyEntry 2 }
+
+nHostAckAuthor OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "A string containing the name of the user who acknowledged the host
+ problem. This macro is only valid in notifications where the
+ $NOTIFICATIONTYPE$ macro is set to ACKNOWLEDGEMENT."
+ ::= { nagiosHostNotifyEntry 3 }
+
+nHostAckComment OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "A string containing the acknowledgement comment that was entered by
+ the user who acknowledged the host problem. This macro is only valid
+ in notifications where the $NOTIFICATIONTYPE$ macro is set to ACKNOWLEDGEMENT"
+ ::= { nagiosHostNotifyEntry 4 }
+
+
+--
+-- Service Events
+--
+
+
+nagiosSvcEventTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF SvcEventEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of Nagios service notifications"
+ ::= { nagiosNotify 3 }
+
+SvcEventEntry ::= SEQUENCE {
+ nSvcEventIndex Integer32,
+ nSvcHostname OCTET STRING,
+ nSvcHostAlias OCTET STRING,
+ nSvcHostStateID HostStateID,
+ nSvcHostStateType HostStateType,
+ nSvcDesc OCTET STRING,
+ nSvcStateID ServiceStateID,
+ nSvcAttempt Integer32,
+ nSvcDurationSec Integer32,
+ nSvcGroupName OCTET STRING,
+ nSvcLastCheck INTEGER,
+ nSvcLastChange INTEGER,
+ nSvcLastOK INTEGER,
+ nSvcLastWarn INTEGER,
+ nSvcLastCrit INTEGER,
+ nSvcLastUnkn INTEGER,
+ nSvcOutput OCTET STRING,
+ nSvcPerfData OCTET STRING
+ }
+
+nagiosSvcEventEntry OBJECT-TYPE
+ SYNTAX SvcEventEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of Nagios service events."
+ INDEX { nSvcEventIndex }
+ ::= { nagiosSvcEventTable 1 }
+
+nSvcEventIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..65535)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "This object uniquely identifies this service event entry"
+ ::= { nagiosSvcEventEntry 1 }
+
+nSvcHostname OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Hostname as specified in the Nagios configuration file."
+ ::= { nagiosSvcEventEntry 2 }
+
+nSvcHostAlias OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The host alias as specified in the Nagios configuration file"
+ ::= { nagiosSvcEventEntry 3 }
+
+nSvcHostStateID OBJECT-TYPE
+ SYNTAX HostStateID
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "A number that corresponds to the current state of the service: 0=OK,
+ 1=WARNING, 2=CRITICAL, 3=UNKNOWN."
+ ::= { nagiosSvcEventEntry 4 }
+
+nSvcHostStateType OBJECT-TYPE
+ SYNTAX HostStateType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Whether the host is in a hard or soft state."
+ ::= { nagiosSvcEventEntry 5 }
+
+nSvcDesc OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This value is taken from the description directive of the service
+ definition."
+ ::= { nagiosSvcEventEntry 6 }
+
+nSvcStateID OBJECT-TYPE
+ SYNTAX ServiceStateID
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " A number that corresponds to the current state of the service: 0=OK,
+ 1=WARNING, 2=CRITICAL, 3=UNKNOWN"
+ ::= { nagiosSvcEventEntry 7 }
+
+nSvcAttempt OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of the current service check retry. For instance, if this is
+ the second time that the service is being rechecked, this will be the
+ number two. Current attempt number is really only useful when writing
+ service event handlers for soft states that take a specific action based
+ on the service retry number."
+ ::= { nagiosSvcEventEntry 8 }
+
+nSvcDurationSec OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "A number indicating the number of seconds that the service has spent in
+ its current state."
+ ::= { nagiosSvcEventEntry 9 }
+
+nSvcGroupName OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The short name of the servicegroup that this service belongs to. This
+ value is taken from the servicegroup_name directive in the servicegroup
+ definition. If the service belongs to more than one servicegroup this
+ object will contain the name of just one of them."
+ ::= { nagiosSvcEventEntry 10 }
+
+nSvcLastCheck OBJECT-TYPE
+ SYNTAX INTEGER
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This is a timestamp in time_t format (seconds since the UNIX epoch)
+ indicating the time at which a check of the service was last performed."
+ ::= { nagiosSvcEventEntry 11 }
+
+nSvcLastChange OBJECT-TYPE
+ SYNTAX INTEGER
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This is a timestamp in time_t format (seconds since the UNIX epoch)
+ indicating the time the service last changed state."
+ ::= { nagiosSvcEventEntry 12 }
+
+nSvcLastOK OBJECT-TYPE
+ SYNTAX INTEGER
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This is a timestamp in time_t format (seconds since the UNIX epoch)
+ indicating the time at which the service was last detected as being in an
+ OK state."
+ ::= { nagiosSvcEventEntry 13 }
+
+nSvcLastWarn OBJECT-TYPE
+ SYNTAX INTEGER
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This is a timestamp in time_t format (seconds since the UNIX epoch)
+ indicating the time at which the service was last detected as being in a
+ WARNING state."
+ ::= { nagiosSvcEventEntry 14 }
+
+nSvcLastCrit OBJECT-TYPE
+ SYNTAX INTEGER
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This is a timestamp in time_t format (seconds since the UNIX epoch)
+ indicating the time at which the service was last detected as being in a
+ CRITICAL state."
+ ::= { nagiosSvcEventEntry 15 }
+
+nSvcLastUnkn OBJECT-TYPE
+ SYNTAX INTEGER
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This is a timestamp in time_t format (seconds since the UNIX epoch)
+ indicating the time at which the service was last detected as being in an
+ UNKNOWN state."
+ ::= { nagiosSvcEventEntry 16 }
+
+nSvcOutput OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The text output from the last service check (i.e. Ping OK)."
+ ::= { nagiosSvcEventEntry 17 }
+
+nSvcPerfData OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "This object contains any performance data that may have been returned by
+ the last service check."
+ ::= { nagiosSvcEventEntry 18 }
+
+
+--
+-- Service Notifications
+--
+
+nagiosSvcNotifyTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF SvcNotifyEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of Nagios service notifications."
+ ::= { nagiosNotify 4 }
+
+SvcNotifyEntry ::= SEQUENCE {
+ nSvcNotifyType NotifyType,
+ nSvcNotifyNum Gauge32, -- Integer32,
+ nSvcAckAuthor OCTET STRING,
+ nSvcAckComment OCTET STRING
+ }
+
+nagiosSvcNotifyEntry OBJECT-TYPE
+ SYNTAX SvcNotifyEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Nagios service notifications extends the nagiosSvcEnevtsTable when
+ a notification is generated for an event."
+ INDEX { nSvcEventIndex }
+ ::= { nagiosSvcNotifyTable 1}
+
+
+nSvcNotifyType OBJECT-TYPE
+ SYNTAX NotifyType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "A string identifying the type of notification that is being sent
+ (PROBLEM, RECOVERY, ACKNOWLEDGEMENT, FLAPPINGSTART or FLAPPINGSTOP)."
+ ::= { nagiosSvcNotifyEntry 1 }
+
+nSvcNotifyNum OBJECT-TYPE
+ SYNTAX Gauge32 -- Integer32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The current notification number for the service or host. The notification
+ number increases by one (1) each time a new notification is sent out for a
+ host or service (except for acknowledgements). The notification number is
+ reset to 0 when the host or service recovers (after the recovery
+ notification has gone out). Acknowledgements do not cause the notification
+ number to increase."
+ ::= { nagiosSvcNotifyEntry 2 }
+
+nSvcAckAuthor OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "A string containing the name of the user who acknowledged the service
+ problem. This object is only valid in notifications where the
+ nSvcNotifyType object is set to ACKNOWLEDGEMENT."
+ ::= { nagiosSvcNotifyEntry 3 }
+
+nSvcAckComment OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "A string containing the acknowledgement comment that was entered by the
+ user who acknowledged the service problem. This object is only valid in
+ notifications where the nSvcNotifyType object is set to ACKNOWLEDGEMENT."
+ ::= { nagiosSvcNotifyEntry 4 }
+
+
+--
+-- Events and Notifications
+--
+
+nHostEvent NOTIFICATION-TYPE
+ OBJECTS { nHostname, nHostStateID, nHostStateType, nHostAttempt,
+ nHostDurationSec, nHostGroupName, nHostLastCheck, nHostLastChange,
+ nHostOutput }
+ STATUS current
+ DESCRIPTION
+ "The SNMP trap that is generated as a result of an event with the host
+ in Nagios."
+
+ ::= { nagiosNotify 5 }
+
+nHostNotify NOTIFICATION-TYPE
+ OBJECTS { nHostNotifyType, nHostNotifyNum, nHostAckAuthor, nHostAckComment,
+ nHostname, nHostStateID, nHostStateType, nHostAttempt,
+ nHostDurationSec, nHostGroupName, nHostLastCheck, nHostLastChange,
+ nHostOutput }
+ STATUS current
+ DESCRIPTION
+ "The SNMP trap that is generated as a result of an event requiring
+ notification for a host in Nagios."
+ ::= { nagiosNotify 6 }
+
+nSvcEvent NOTIFICATION-TYPE
+ OBJECTS { nHostname, nHostStateID, nSvcDesc, nSvcStateID, nSvcAttempt,
+ nSvcDurationSec, nSvcGroupName, nSvcLastCheck, nSvcLastChange,
+ nSvcOutput }
+ STATUS current
+ DESCRIPTION
+ "The SNMP trap that is generated as a result of an event with the service
+ in Nagios."
+ ::= { nagiosNotify 7 }
+
+nSvcNotify NOTIFICATION-TYPE
+ OBJECTS { nSvcNotifyType, nSvcNotifyNum, nSvcAckAuthor, nSvcAckComment,
+ nHostname, nHostStateID, nSvcDesc, nSvcStateID, nSvcAttempt,
+ nSvcDurationSec, nSvcGroupName, nSvcLastCheck, nSvcLastChange,
+ nSvcOutput }
+ STATUS current
+ DESCRIPTION
+ "The SNMP trap that is generated as a result of an event requiring
+ notification for a service in Nagios."
+ ::= { nagiosNotify 8 }
+
+
+END
diff --git a/config/NAGIOS-ROOT-MIB b/config/NAGIOS-ROOT-MIB
new file mode 100644
index 0000000..5fe0771
--- /dev/null
+++ b/config/NAGIOS-ROOT-MIB
@@ -0,0 +1,87 @@
+NAGIOS-ROOT-MIB DEFINITIONS ::= BEGIN
+IMPORTS
+ MODULE-IDENTITY, enterprises
+ FROM SNMPv2-SMI
+ TEXTUAL-CONVENTION
+ FROM SNMPv2-TC;
+
+
+nagios MODULE-IDENTITY
+ LAST-UPDATED "200503090000Z" -- March 9, 2005
+ ORGANIZATION "Nagios"
+ CONTACT-INFO
+ " Subhendu Ghosh
+
+ Telephone: +1 201 232 2851
+ Email: sghosh@users.sourceforge.net
+
+ Nagios Information:
+ http://www.nagios.org
+ "
+ DESCRIPTION
+ "Objects for Nagios(tm) NMS"
+ REVISION "200503090000Z" -- March 9, 2005
+ DESCRIPTION
+ "Spell check"
+ REVISION "200501200000Z" --January 20, 2005
+ DESCRIPTION
+ "Initial Version"
+ ::= {enterprises 20006}
+
+--
+-- Textual Conventions
+--
+
+NotifyType ::= TEXTUAL-CONVENTION
+ STATUS current
+ DESCRIPTION
+ "A string identifying the type of notification that is being sent
+ (PROBLEM, RECOVERY, ACKNOWLEDGEMENT, FLAPPINGSTART or FLAPPINGSTOP).
+ "
+ SYNTAX INTEGER {
+ problem(0),
+ recovery(1),
+ acknowledgement(2),
+ flappingstart(3),
+ flappingstop(4)
+ }
+
+HostStateID ::= TEXTUAL-CONVENTION
+ STATUS current
+ DESCRIPTION
+ "A number that corresponds to the current state of the host: 0=UP, 1=DOWN,
+ 2=UNREACHABLE."
+ SYNTAX INTEGER {
+ up(0),
+ down(1),
+ unreachable(3)
+ }
+
+HostStateType ::= TEXTUAL-CONVENTION
+ STATUS current
+ DESCRIPTION
+ "A string indicating the state type for the current host check (HARD or
+ SOFT). Soft states occur when host checks return a non-OK (non-UP) state
+ and are in the process of being retried. Hard states result when host
+ checks have been checked a specified maximum number of times."
+ SYNTAX INTEGER {
+ hard(0),
+ soft(1)
+ }
+
+ServiceStateID ::= TEXTUAL-CONVENTION
+ STATUS current
+ DESCRIPTION
+ "A number that corresponds to the current state of the service: 0=OK,
+ 1=WARNING, 2=CRITICAL, 3=UNKNOWN.
+ "
+ SYNTAX INTEGER{
+ ok(0),
+ warning(1),
+ critical(2),
+ unknown(3)
+ }
+
+
+END
+
diff --git a/config/gluster-commands.cfg b/config/gluster-commands.cfg
index 73b9e7a..f1b94a4 100644
--- a/config/gluster-commands.cfg
+++ b/config/gluster-commands.cfg
@@ -46,6 +46,16 @@ define command {
}
define command {
+ command_name gluster-notify-host-by-snmp
+ command_line $USER1$/gluster/hostsnmptrapgenerator.py $NOTIFICATIONTYPE$ $HOSTNOTIFICATIONNUMBER$ "$HOSTNAME$" $HOSTSTATEID$ $HOSTSTATETYPE$ $HOSTATTEMPT$ $HOSTDURATIONSEC$ "$HOSTGROUPNAMES$" $LASTHOSTCHECK$ $LASTHOSTSTATECHANGE$ "$HOSTOUTPUT$"
+}
+
+define command {
+ command_name gluster-notify-service-by-snmp
+ command_line $USER1$/gluster/servicesnmptrapgenerator.py $NOTIFICATIONTYPE$ $SERVICENOTIFICATIONNUMBER$ "$HOSTNAME$" $HOSTSTATEID$ "$SERVICEDESC$" $SERVICESTATEID$ $SERVICEATTEMPT$ "$SERVICEDURATION$" "$SERVICEGROUPNAMES$" $LASTSERVICECHECK$ $LASTSERVICESTATECHANGE$ "$SERVICEOUTPUT$"
+}
+
+define command {
command_name check_brick_usage
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_brick_usage -a $_SERVICEBRICK_DIR$
}
diff --git a/config/gluster-contacts.cfg b/config/gluster-contacts.cfg
index 758a102..47bce44 100644
--- a/config/gluster-contacts.cfg
+++ b/config/gluster-contacts.cfg
@@ -13,3 +13,15 @@ define contact {
_ovirt_user admin@internal
}
+define contact {
+ contact_name snmp
+ alias Snmp Traps
+ email admin@ovirt.com
+ service_notification_period 24x7
+ service_notification_options w,u,c,r,f,s
+ service_notification_commands gluster-notify-service-by-snmp
+ host_notification_period 24x7
+ host_notification_options d,u,r,f,s
+ host_notification_commands gluster-notify-host-by-snmp
+}
+
diff --git a/config/gluster-templates.cfg b/config/gluster-templates.cfg
index a1da860..d9bebf9 100644
--- a/config/gluster-templates.cfg
+++ b/config/gluster-templates.cfg
@@ -1,8 +1,12 @@
define host{
- name gluster-generic-host
- use linux-server
- register 0
- contacts +ovirt
+ name gluster-generic-host
+ use linux-server
+ notifications_enabled 1
+ notification_period 24x7
+ notification_interval 120
+ notification_options d,u,r,f,s
+ register 0
+ contacts +ovirt,snmp
}
define host {
@@ -29,11 +33,15 @@ define host{
}
define service {
- name gluster-service
- use generic-service
- register 0
- contacts +ovirt
- _gluster_entity Service
+ name gluster-service
+ use generic-service
+ notifications_enabled 1
+ notification_period 24x7
+ notification_options w,u,c,r,f,s
+ notification_interval 120
+ register 0
+ contacts +ovirt,snmp
+ _gluster_entity Service
}
define service {
diff --git a/config/snmpmanagers.cfg b/config/snmpmanagers.cfg
new file mode 100644
index 0000000..1e595f4
--- /dev/null
+++ b/config/snmpmanagers.cfg
@@ -0,0 +1,5 @@
+#Configure the trap destinations
+#Provide the ipaddress and community names of SNMP manangers
+#
+#localhost public
+#10.70.1.219 public \ No newline at end of file
diff --git a/configure.ac b/configure.ac
index 93254a4..7b53aba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,6 +59,7 @@ AC_SUBST([hostmonitoringserviceslist], ['/etc/nagios/gluster/host-monitoring-ser
AC_SUBST([nrpepath], ['/usr/lib64/nagios/plugins/check_nrpe'])
AC_SUBST([glusterautoconfdir], ['/etc/nagios/gluster'])
AC_SUBST([glusterhostconfigtemplatedir], ['/etc/nagios/gluster/default'])
+AC_SUBST([snmpmanagerlist], ['/etc/nagios/gluster/snmpmanagers.cfg'])
# Checking for pyflakes
AC_PATH_PROG([PYFLAKES], [pyflakes])
@@ -103,6 +104,8 @@ AC_CONFIG_FILES([
plugins/constants.py
plugins/gluster_host_service_handler.py
plugins/Makefile
+ plugins/hostsnmptrapgenerator.py
+ plugins/servicesnmptrapgenerator.py
templates/Makefile
tests/Makefile
tests/run_tests_local.sh
diff --git a/nagios-server-addons.spec.in b/nagios-server-addons.spec.in
index 1fb8f11..7d1e934 100644
--- a/nagios-server-addons.spec.in
+++ b/nagios-server-addons.spec.in
@@ -76,6 +76,7 @@ Requires: python-inotify
Requires: libselinux-python
Requires: rrdtool-perl
Requires: python-jinja2
+Requires: net-snmp-utils
%description
Nagios plugin, scripts, configuration files etc for gluster nodes.
@@ -195,6 +196,7 @@ fi
%attr(0755, -, -) %{_libdir}/nagios/plugins/gluster/*
%attr(0775, root, nagios) %dir %{_sysconfdir}/nagios/gluster
%{_sysconfdir}/nagios/gluster/*
+/usr/share/snmp/mibs/*
%files tests
%defattr(-,root,root,-)
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 9779c2d..39893e3 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -5,10 +5,12 @@ dist_glusternagiosplugins_PYTHON = \
check_remote_host.py \
check_vol_server.py \
gluster_host_service_handler.py \
+ hostsnmptrapgenerator.py \
livestatus.py \
notify_ovirt_engine_handler.py \
discovery.py \
config_generator.py \
+ servicesnmptrapgenerator.py \
$(NULL)
EXTRA_DIST = \
diff --git a/plugins/hostsnmptrapgenerator.py.in b/plugins/hostsnmptrapgenerator.py.in
new file mode 100755
index 0000000..b884974
--- /dev/null
+++ b/plugins/hostsnmptrapgenerator.py.in
@@ -0,0 +1,109 @@
+#!/usr/bin/python
+# hostsnmptrapgenerator.py.in -- nagios plugin for generating the
+#SNMP traps on host status change
+# Copyright (C) 2014 Red Hat Inc
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
+
+import argparse
+import commands
+
+from glusternagios import utils
+
+
+varbindlist = {'nHostNotifyType': ' nHostNotifyType i ',
+ 'nHostAckAuthor': ' nHostAckAuthor s ',
+ 'nHostAckComment': ' nHostAckComment s ',
+ 'nHostname': ' nHostname s ',
+ 'nHostStateID': ' nHostStateID i ',
+ 'nHostStateType': ' nHostStateType i ',
+ 'nHostAttempt': ' nHostAttempt i ',
+ 'nHostDurationSec': ' nHostDurationSec i ',
+ 'nHostGroupName': ' nHostGroupName s ',
+ 'nHostLastCheck': ' nHostLastCheck i ',
+ 'nHostLastChange': ' nHostLastChange i ',
+ 'nHostOutput': ' nHostOutput s '}
+
+
+def buildandsendsnmptrap(args):
+ command = ""
+ path = "@snmpmanagerlist@"
+ listofmanagers = utils.getsnmpmanagers(path)
+ for manager in listofmanagers:
+ command = utils.sudoCmdPath.cmd + " " \
+ + utils.trapCmdPath.cmd + " -v 2c -c "
+ command += manager['community'] + " " + manager['host'] + ''' '' ''' +\
+ "NAGIOS-NOTIFY-MIB::nHostNotify" +\
+ varbindlist['nHostNotifyType'] + args.nHostNotifyType + \
+ varbindlist['nHostname'] + args.nHostname +\
+ varbindlist['nHostStateID'] + args.nHostStateID +\
+ varbindlist['nHostStateType'] + args.nHostStateType +\
+ varbindlist['nHostAttempt'] + args.nHostAttempt +\
+ varbindlist['nHostDurationSec'] + args.nHostDurationSec +\
+ varbindlist['nHostGroupName'] + args.nHostGroupName +\
+ varbindlist['nHostLastCheck'] + args.nHostLastCheck +\
+ varbindlist['nHostLastChange'] + args.nHostLastChange +\
+ varbindlist['nHostOutput'] + args.nHostOutput
+ commands.getoutput(command)
+
+
+def parse_input():
+ parser = argparse.ArgumentParser(
+ usage='%(prog)s [-h] <nHostNotifyType> < nHostNotifyNum> '
+ '<nHostname> '
+ '<nHostStateID> <nHostStateType> <nHostAttempt> '
+ '< nHostDurationSec> <nHostGroupName> <nHostLastCheck> '
+ '<nHostLastChange> <nHostOutput>')
+ parser.add_argument("nHostNotifyType")
+ parser.add_argument("nHostNotifyNum")
+ parser.add_argument("nHostname")
+ parser.add_argument("nHostStateID")
+ parser.add_argument("nHostStateType")
+ parser.add_argument("nHostAttempt")
+ parser.add_argument("nHostDurationSec")
+ parser.add_argument("nHostGroupName")
+ parser.add_argument("nHostLastCheck")
+ parser.add_argument("nHostLastChange")
+ parser.add_argument("nHostOutput")
+
+ args = parser.parse_args()
+
+ return args
+
+
+def formatargs(args):
+ #convert nHostNotifyType to enum value
+ hostnotifytype = {'problem': '0',
+ 'recovery': '1',
+ 'acknowledgement': '2',
+ 'flappingstart': '3',
+ 'flappingstop': '4'}
+ args.nHostNotifyType = hostnotifytype[args.nHostNotifyType.lower()]
+ #convert nHostStateType to enum value
+ hoststatetype = {'hard': '0', 'soft': '1'}
+ args.nHostStateType = hoststatetype[args.nHostStateType.lower()]
+ #Add quotes to string parameters to handle
+ #parameters with multiple words separated with
+ #spaces
+ args.nHostname = '''"'''+args.nHostname+'''"'''
+ args.nHostGroupName = '''"'''+args.nHostGroupName+'''"'''
+ args.nHostOutput = '''"'''+args.nHostOutput+'''"'''
+
+
+if __name__ == '__main__':
+ args = parse_input()
+ formatargs(args)
+ buildandsendsnmptrap(args)
diff --git a/plugins/servicesnmptrapgenerator.py.in b/plugins/servicesnmptrapgenerator.py.in
new file mode 100755
index 0000000..1a4661f
--- /dev/null
+++ b/plugins/servicesnmptrapgenerator.py.in
@@ -0,0 +1,108 @@
+#!/usr/bin/python
+# servicesnmptrapgenerator.py.in -- nagios plugin for generating the
+#SNMP traps on service status change
+# Copyright (C) 2014 Red Hat Inc
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
+
+import argparse
+import commands
+
+from glusternagios import utils
+
+
+varbindlist = {'nSvcNotifyType': ' nSvcNotifyType i ',
+ 'nSvcNotifyNum': ' nSvcNotifyNum i ',
+ 'nHostname': ' nHostname s ',
+ 'nHostStateID': ' nHostStateID i ',
+ 'nSvcDesc': ' nSvcDesc s ',
+ 'nSvcStateID': ' nSvcStateID i ',
+ 'nSvcAttempt': ' nSvcAttempt i ',
+ 'nSvcDurationSec': ' nSvcDurationSec i ',
+ 'nSvcGroupName': ' nSvcGroupName s ',
+ 'nSvcLastCheck': ' nSvcLastCheck i ',
+ 'nSvcLastChange': ' nSvcLastChange i ',
+ 'nSvcOutput': ' nSvcOutput s '}
+
+
+def parse_input():
+ parser = argparse.ArgumentParser(
+ usage='%(prog)s [-h] <nSvcNotifyType> < nSvcNotifyNum> '
+ '<nHostname> '
+ '<nHostStateID> <nSvcDesc> <nSvcStateID> '
+ '<nSvcAttempt> <nSvcDurationSec> <nSvcGroupName> '
+ '<nSvcLastCheck> <nSvcLastChange> <nSvcOutput>')
+ parser.add_argument("nSvcNotifyType")
+ parser.add_argument("nSvcNotifyNum")
+ parser.add_argument("nHostname")
+ parser.add_argument("nHostStateID")
+ parser.add_argument("nSvcDesc")
+ parser.add_argument("nSvcStateID")
+ parser.add_argument("nSvcAttempt")
+ parser.add_argument("nSvcDurationSec")
+ parser.add_argument("nSvcGroupName")
+ parser.add_argument("nSvcLastCheck")
+ parser.add_argument("nSvcLastChange")
+ parser.add_argument("nSvcOutput")
+
+ args = parser.parse_args()
+
+ return args
+
+
+def buildandsendsnmptrap(args):
+ command = ""
+ path = "@snmpmanagerlist@"
+ listofmanagers = utils.getsnmpmanagers(path)
+ for manager in listofmanagers:
+ command = utils.sudoCmdPath.cmd + " " \
+ + utils.trapCmdPath.cmd + " -v 2c -c "
+ command += manager['community'] + " " + manager['host'] + ''' '' ''' +\
+ "NAGIOS-NOTIFY-MIB::nSvcNotify" +\
+ varbindlist['nSvcNotifyType'] + args.nSvcNotifyType + \
+ varbindlist['nHostname'] + args.nHostname +\
+ varbindlist['nHostStateID'] + args.nHostStateID +\
+ varbindlist['nSvcDesc'] + args.nSvcDesc +\
+ varbindlist['nSvcStateID'] + args.nSvcStateID +\
+ varbindlist['nSvcAttempt'] + args.nSvcAttempt +\
+ varbindlist['nSvcGroupName'] + args.nSvcGroupName +\
+ varbindlist['nSvcLastCheck'] + args.nSvcLastCheck +\
+ varbindlist['nSvcLastChange'] + args.nSvcLastChange +\
+ varbindlist['nSvcOutput'] + args.nSvcOutput
+ commands.getoutput(command)
+
+
+def formatargs(args):
+ #convert nSvcNotifyType to enum value
+ svcnotifytype = {'problem': '0',
+ 'recovery': '1',
+ 'acknowledgement': '2',
+ 'flappingstart': '3',
+ 'flappingstop': '4'}
+ args.nSvcNotifyType = svcnotifytype[args.nSvcNotifyType.lower()]
+ #Add quotes to string parameters to handle
+ #parameters with multiple words separated with
+ #spaces
+ args.nHostname = '''"'''+args.nHostname+'''"'''
+ args.nSvcDesc = '''"'''+args.nSvcDesc+'''"'''
+ args.nSvcGroupName = '''"'''+args.nSvcGroupName+'''"'''
+ args.nSvcOutput = '''"'''+args.nSvcOutput+'''"'''
+
+
+if __name__ == '__main__':
+ args = parse_input()
+ formatargs(args)
+ buildandsendsnmptrap(args)
diff --git a/tests/test_gluster_host_service_handler.py b/tests/test_gluster_host_service_handler.py
index 9c36f19..5bbdff6 100644
--- a/tests/test_gluster_host_service_handler.py
+++ b/tests/test_gluster_host_service_handler.py
@@ -70,8 +70,8 @@ class TestGlusterHostServiceHandler(TestCaseBase):
"Service(s) [\'dummy srvc\']"
" in CRITICAL state\n")
- @mock.patch('plugins.gluster_host_service_handler.' \
- '_getHostMonitoringSrvcList')
+ @mock.patch(
+ 'plugins.gluster_host_service_handler._getHostMonitoringSrvcList')
@mock.patch('plugins.gluster_host_service_handler.checkLiveStatus')
@mock.patch('plugins.gluster_host_service_handler.update_host_state')
def testCheckAndUpdateHostStateToUp(self,