Permalink
Browse files

updated netscaler collector / fixed tests to use uname short and not …

…fqdn
  • Loading branch information...
bcakipp committed Oct 22, 2012
1 parent d83d550 commit 41dcb06a96c1e738fba9489fa4ab3fc30355ce80
Showing with 135 additions and 8 deletions.
  1. +134 −8 src/collectors/netscalersnmp/netscalersnmp.py
  2. +1 −0 test.py
@@ -25,6 +25,57 @@ class NetscalerSNMPCollector(parent_SNMPCollector):
"""
SNMPCollector for Netscaler Metrics
"""
+
+ """
+ EntityProtocolType ::=
+ INTEGER{ http(0),
+ ftp(1),
+ tcp(2),
+ udp(3),
+ sslBridge(4),
+ monitor(5),
+ monitorUdp(6),
+ nntp(7),
+ httpserver(8),
+ httpclient(9),
+ rpcserver(10),
+ rpcclient(11),
+ nat(12),
+ any(13),
+ ssl(14),
+ dns(15),
+ adns(16),
+ snmp(17),
+ ha(18),
+ monitorPing(19),
+ sslOtherTcp(20),
+ aaa(21),
+ secureMonitor(23),
+ sslvpnUdp(24),
+ rip(25),
+ dnsClient(26),
+ rpcServer(27),
+ rpcClient(28),
+ dhcrpa(36),
+ sipudp(39),
+ dnstcp(44),
+ adnstcp(45),
+ rtsp(46),
+ push(48),
+ sslPush(49),
+ dhcpClient(50),
+ radius(51),
+ serviceUnknown(62) }
+
+ EntityState ::=
+ INTEGER{ down(1),
+ unknown(2),
+ busy(3),
+ outOfService(4),
+ transitionToOutOfService(5),
+ up(7),
+ transitionToOutOfServiceDown(8) }
+ """
NETSCALER_SYSTEM_GUAGES = {
"cpuUsage": "1.3.6.1.4.1.5951.4.1.1.41.1.0",
@@ -38,6 +89,22 @@ class NetscalerSNMPCollector(parent_SNMPCollector):
"httpTotRequests": "1.3.6.1.4.1.5951.4.1.1.48.67.0"
}
+ NETSCALER_VSERVER_NAMES = "1.3.6.1.4.1.5951.4.1.3.1.1.1"
+
+ NETSCALER_VSERVER_TYPE = "1.3.6.1.4.1.5951.4.1.3.1.1.4"
+
+ NETSCALER_VSERVER_STATE = "1.3.6.1.4.1.5951.4.1.3.1.1.5"
+
+ NETSCALER_VSERVER_GUAGES = {
+ "vsvrRequestRate": "1.3.6.1.4.1.5951.4.1.3.1.1.43",
+ "vsvrRxBytesRate": "1.3.6.1.4.1.5951.4.1.3.1.1.44",
+ "vsvrTxBytesRate": "1.3.6.1.4.1.5951.4.1.3.1.1.45",
+ "vsvrCurServicesUp": "1.3.6.1.4.1.5951.4.1.3.1.1.41",
+ "vsvrCurServicesDown": "1.3.6.1.4.1.5951.4.1.3.1.1.37",
+ "vsvrCurServicesUnknown": "1.3.6.1.4.1.5951.4.1.3.1.1.38",
+ "vsvrCurServicesTransToOutOfSvc": "1.3.6.1.4.1.5951.4.1.3.1.1.40"
+ }
+
NETSCALER_SERVICE_NAMES = "1.3.6.1.4.1.5951.4.1.2.1.1.1"
NETSCALER_SERVICE_TYPE = "1.3.6.1.4.1.5951.4.1.2.1.1.4"
@@ -60,7 +127,9 @@ def get_default_config_help(self):
config_help.update({
'host': 'netscaler dns address',
'port': 'Netscaler port to collect snmp data',
- 'community': 'SNMP community'
+ 'community': 'SNMP community',
+ 'exclude_service_type': "list of service types to exclude (see MIB EntityProtocolType)",
+ 'exclude_vserver_type': "list of vserver types to exclude (see MIB EntityProtocolType)"
})
return config_help
@@ -71,7 +140,11 @@ def get_default_config(self):
config = super(NetscalerSNMPCollector, self).get_default_config()
config.update({
'path': 'netscaler',
- 'timeout': 15,
+ 'timeout': 15,
+ 'exclude_service_type': [],
+ 'exclude_vserver_type': [],
+ 'exclude_service_state': [],
+ 'exclude_vserver_state': []
})
return config
@@ -135,9 +208,9 @@ def collect_snmp(self, device, host, port, community):
host,
port,
community)[serviceTypeOid].strip("\'"))
-
- # Filter internal services
- if serviceType in [20, 30]:
+
+ # Filter excluded service types
+ if serviceType in map(lambda v: int(v), self.config.get('exclude_service_type')):
continue
# Get Service State
@@ -147,9 +220,9 @@ def collect_snmp(self, device, host, port, community):
host,
port,
community)[serviceStateOid].strip("\'"))
-
- # Filter down services
- if serviceState not in [7]:
+
+ # Filter excluded service states
+ if serviceState in map(lambda v: int(v), self.config.get('exclude_service_state')):
continue
for k, v in self.NETSCALER_SERVICE_GUAGES.items():
@@ -172,3 +245,56 @@ def collect_snmp(self, device, host, port, community):
metric = Metric(metricPath, metricValue, timestamp, 0)
# Publish Metric
self.publish_metric(metric)
+
+ # Collect Netscaler Vservers
+ vserverNames = [v.strip("\'") for v in self.walk(
+ self.NETSCALER_VSERVER_NAMES, host, port, community).values()]
+
+ for vserverName in vserverNames:
+ # Get Vserver Name in OID form
+ vserverNameOid = self.get_string_index_oid(vserverName)
+
+ # Get Vserver Type
+ vserverTypeOid = ".".join([self.NETSCALER_VSERVER_TYPE,
+ self._convert_from_oid(vserverNameOid)])
+ vserverType = int(self.get(vserverTypeOid,
+ host,
+ port,
+ community)[vserverTypeOid].strip("\'"))
+
+ # filter excluded vserver types
+ if vserverType in map(lambda v: int(v), self.config.get('exclude_vserver_type')):
+ continue
+
+ # Get Service State
+ vserverStateOid = ".".join([self.NETSCALER_VSERVER_STATE,
+ self._convert_from_oid(vserverNameOid)])
+ vserverState = int(self.get(vserverStateOid,
+ host,
+ port,
+ community)[vserverStateOid].strip("\'"))
+
+ # Filter excluded vserver state
+ if vserverState in map(lambda v: int(v), self.config.get('exclude_vserver_state')):
+ continue
+
+ for k, v in self.NETSCALER_VSERVER_GUAGES.items():
+ vserverGuageOid = ".".join(
+ [v, self._convert_from_oid(vserverNameOid)])
+ # Get Metric Name
+ metricName = '.'.join([re.sub(r'\.|\\', '_', vserverName), k])
+ # Get Metric Value
+ metricValue = int(self.get(vserverGuageOid,
+ host,
+ port,
+ community
+ )[vserverGuageOid].strip("\'"))
+ # Get Metric Path
+ metricPath = '.'.join(['devices',
+ device,
+ 'vserver',
+ metricName])
+ # Create Metric
+ metric = Metric(metricPath, metricValue, timestamp, 0)
+ # Publish Metric
+ self.publish_metric(metric)
View
@@ -34,6 +34,7 @@ def get_collector_config(key, value):
config['server']['collectors_config_path'] = ''
config['collectors'] = {}
config['collectors']['default'] = {}
+ config['collectors']['default']['hostname_method'] = "uname_short"
config['collectors'][key] = value
return config

0 comments on commit 41dcb06

Please sign in to comment.