sensu-plugins-netscaler 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 417b5f1d25562554dea34e86753001bee2df66bb
4
- data.tar.gz: 9056b3c033a6f296208a44a6e1d5abda3a504317
3
+ metadata.gz: 144a8f8b312273a6a9bafc38f172f68e6e5881fa
4
+ data.tar.gz: 25a837bf4becd193a2e4bf1edf1360f6140eb605
5
5
  SHA512:
6
- metadata.gz: 9ceee66280827a85d58bd99300ef8aa3192c0da05a3086843705b3124a34c52523aa9414bdc684323d3da8352945f155acb39da02ebfd719159bd769f88cf694
7
- data.tar.gz: 865c09ca32670484573df907ada1a2ece9d046e67830ebc3cf4da895af01f010449cb3f7463de00fcebc2f50af79c09a6933bd4e1c5d1c9c1ed3eebd8ed500df
6
+ metadata.gz: 3097ff1c25523d595dbf8a3fd8a20d740f28d10e73eb5fa40630f5938bb780eb5fbb2ea3e9ee2bd1fbc89c8fee5dd697158fc156962df1982487cac061ac00a2
7
+ data.tar.gz: df0f79930414ad35715c3ac9bc49ac348e186bdd9e3d15a7949c8374b3a2f6eb27ca3232fd4796720698a165e2f817a49f2cfcf0925a7135068011bc05340fd9
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -3,12 +3,23 @@ This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
- ## Unreleased][unreleased]
6
+ ## [Unreleased][unreleased]
7
+
8
+ ## [0.1.0] - 2015-08-11
9
+ ### Added
10
+ - Add metrics-netscaler.py plugin
11
+
12
+ ### Changed
13
+ - bump rubocop
7
14
 
8
15
  ## [0.0.2] - 2015-07-14
9
16
  ### Changed
10
17
  - updated sensu-plugin gem to 1.2.0
11
18
 
12
- ## [0.0.1] - 2015-06-04
19
+ ## 0.0.1 - 2015-06-04
13
20
  ### Added
14
21
  - initial release
22
+
23
+ [unreleased]: https://github.com/sensu-plugins/sensu-plugins-netscaler/compare/0.1.0...HEAD
24
+ [0.0.3]: https://github.com/sensu-plugins/sensu-plugins-netscaler/compare/0.0.2...0.1.0
25
+ [0.0.2]: https://github.com/sensu-plugins/sensu-plugins-netscaler/compare/0.0.1...0.0.2
data/README.md CHANGED
@@ -10,11 +10,12 @@
10
10
  ## Functionality
11
11
 
12
12
  ## Files
13
+ - metrics-netscaler.py
13
14
 
14
15
  ## Usage
15
16
 
16
17
  ## Installation
17
18
 
18
- [Installation and Setup](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
19
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
19
20
 
20
21
  ## Notes
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # DESCRIPTION:
4
+ # Grabs stats from a netscaler appliance via the Nitro REST API.
5
+ # Prints to STDOUT in graphite format thus meant for a TCP handler
6
+ # To find out what each stat means download the Nitro SDK
7
+ # http://support.citrix.com/proddocs/topic/netscaler-main-api-10-map/ns-nitro-rest-feat-stat-api-ref.html
8
+ # You should also be able to get the stats docs in a PDF that can be downloaded
9
+ # from your netscaler web UI.
10
+ #
11
+ # OUTPUT:
12
+ # Graphite plain-text format (name value timestamp\n)
13
+ #
14
+ # DEPENDENCIES:
15
+ # Python 2.7 (untested on python 3 but should work fine)
16
+ # Python Requests (http://docs.python-requests.org)
17
+ #
18
+ # LICENSE:
19
+ # Jaime Gago contact@jaimegago.com
20
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
21
+ # for details.
22
+ import logging
23
+ import logging.handlers
24
+ import optparse
25
+ import requests
26
+ import sys
27
+ import time
28
+
29
+ FLAT_STATS_ENDPOINTS = [
30
+ 'ns',
31
+ 'cmp',
32
+ 'ssl',
33
+ 'system'
34
+ ]
35
+
36
+ STATS_WITH_IDS = [
37
+ {
38
+ 'endpoint' : 'lbvserver',
39
+ 'identifier' : 'name'
40
+ },
41
+ {
42
+ 'endpoint' : 'Interface',
43
+ 'identifier' : 'id'
44
+ }
45
+ ]
46
+
47
+
48
+ FAILURE_CONSTANT = 1
49
+
50
+ def set_syslog():
51
+ '''Set a syslog logger'''
52
+ try:
53
+ logger = logging.getLogger(__name__)
54
+ logger.setLevel(logging.DEBUG)
55
+
56
+ formatter = logging.Formatter("%(pathname)s: %(message)s")
57
+
58
+ handler = logging.handlers.SysLogHandler(address = '/dev/log')
59
+ handler.setFormatter(formatter)
60
+ logger.addHandler(handler)
61
+ except Exception:
62
+ logging.critical("Failed to configure syslog handler")
63
+ sys.exit(1)
64
+ return logger
65
+
66
+ def isfloat(value):
67
+ try:
68
+ float(value)
69
+ return True
70
+ except ValueError:
71
+ return False
72
+
73
+ def graphite_printer(stats, graphite_scheme):
74
+ now = time.time()
75
+ for stat in stats:
76
+ print "%s.%s %s %d" % (graphite_scheme, stat, stats[stat], now)
77
+
78
+ def get_flat_stats(flat_stats_end_points, nitro_version, netscaler, user,
79
+ password, logger):
80
+ nitro_rest_api = 'http://%s/nitro/%s/stat/' % (netscaler, nitro_version)
81
+ flat_stats = {}
82
+ for flat_stat_end_point in flat_stats_end_points:
83
+ url = nitro_rest_api + flat_stat_end_point
84
+ try:
85
+ response = requests.get(url, auth=(user, password))
86
+ except Exception as e:
87
+ logger.critical('Could not get JSON from %s' % url)
88
+ logger.critical(e)
89
+ sys.exit(FAILURE_CONSTANT)
90
+ data = response.json()
91
+ for flat_stat in data[flat_stat_end_point]:
92
+ value = data[flat_stat_end_point][flat_stat]
93
+ if isfloat(value):
94
+ flat_stats[flat_stat_end_point+ '.' + flat_stat] = value
95
+ return flat_stats
96
+
97
+ def get_stats_with_ids(stat_with_ids_end_point, stat_identifier, nitro_version,
98
+ netscaler, user, password, logger):
99
+ nitro_rest_api = 'http://%s/nitro/%s/stat/' % (netscaler, nitro_version)
100
+ url = nitro_rest_api + stat_with_ids_end_point
101
+ stats_with_ids = {}
102
+ try:
103
+ response = requests.get(url, auth=(user, password))
104
+ except Exception as e:
105
+ logger.critical('Could not get JSON from %s' % url)
106
+ logger.critical(e)
107
+ sys.exit(FAILURE_CONSTANT)
108
+ data = response.json()
109
+ for stats in data[stat_with_ids_end_point]:
110
+ stat_id = stats[stat_identifier]
111
+ stat_id_alnum = ''.join(e for e in stat_id if e.isalnum())
112
+ for stat in stats:
113
+ value = stats[stat]
114
+ if isfloat(value):
115
+ stat_name = stat_with_ids_end_point + '.' + stat_id_alnum + '.' + stat
116
+ stats_with_ids[stat_name] = value
117
+ return stats_with_ids
118
+
119
+
120
+ def main():
121
+ parser = optparse.OptionParser()
122
+
123
+ parser.add_option('-n', '--netscaler',
124
+ help = 'netscaler (IP or FQDN) to collect stats from',
125
+ dest = 'netscaler',
126
+ metavar = 'netscaler')
127
+
128
+ parser.add_option('-u', '--user',
129
+ help = 'netscaler user with access to nitro rest',
130
+ dest = 'user',
131
+ metavar = 'USER')
132
+
133
+ parser.add_option('-p', '--password',
134
+ help = 'netscaler user password',
135
+ dest = 'password',
136
+ metavar = 'PASSWORD')
137
+
138
+ parser.add_option('-s', '--graphite_scheme',
139
+ help = 'graphite scheme to prepend, default to <netscaler>',
140
+ default = 'netscaler',
141
+ dest = 'graphite_scheme',
142
+ metavar = 'GRAPHITE_SCHEME')
143
+
144
+ parser.add_option('-v', '--nitro-version',
145
+ help = 'nitro REST API version, defaults to v1',
146
+ default = 'v1',
147
+ dest = 'nitro_version',
148
+ metavar = 'NITRO_VERSION')
149
+
150
+ (options, args) = parser.parse_args()
151
+
152
+ if not options.netscaler or not options.user or not options.password:
153
+ print 'A netscaler, user and password are required'
154
+ sys.exit(FAILURE_CONSTANT)
155
+
156
+ nitro_version = options.nitro_version
157
+ netscaler = options.netscaler
158
+ user = options.user
159
+ password = options.password
160
+
161
+ logger = set_syslog()
162
+
163
+ flat_stats = get_flat_stats(FLAT_STATS_ENDPOINTS, nitro_version, netscaler, user,
164
+ password, logger)
165
+ graphite_printer(flat_stats, options.graphite_scheme)
166
+
167
+ for stat_with_ids in STATS_WITH_IDS:
168
+ stats_with_ids = get_stats_with_ids(stat_with_ids['endpoint'],
169
+ stat_with_ids['identifier'], nitro_version, netscaler, user, password,
170
+ logger)
171
+ graphite_printer(stats_with_ids, options.graphite_scheme)
172
+
173
+
174
+ if __name__ == '__main__':
175
+ main()
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsNetscaler
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 0
5
- PATCH = 2
4
+ MINOR = 1
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-netscaler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
@@ -30,7 +30,7 @@ cert_chain:
30
30
  8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
31
  HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
32
  -----END CERTIFICATE-----
33
- date: 2015-07-14 00:00:00.000000000 Z
33
+ date: 2015-08-12 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: sensu-plugin
@@ -108,14 +108,14 @@ dependencies:
108
108
  requirements:
109
109
  - - '='
110
110
  - !ruby/object:Gem::Version
111
- version: '0.30'
111
+ version: 0.32.1
112
112
  type: :development
113
113
  prerelease: false
114
114
  version_requirements: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - '='
117
117
  - !ruby/object:Gem::Version
118
- version: '0.30'
118
+ version: 0.32.1
119
119
  - !ruby/object:Gem::Dependency
120
120
  name: rspec
121
121
  requirement: !ruby/object:Gem::Requirement
@@ -181,6 +181,7 @@ files:
181
181
  - CHANGELOG.md
182
182
  - LICENSE
183
183
  - README.md
184
+ - bin/metrics-netscaler.py
184
185
  - lib/sensu-plugins-netscaler.rb
185
186
  - lib/sensu-plugins-netscaler/version.rb
186
187
  homepage: https://github.com/sensu-plugins/sensu-plugins-netscaler
@@ -209,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
210
  version: '0'
210
211
  requirements: []
211
212
  rubyforge_project:
212
- rubygems_version: 2.4.6
213
+ rubygems_version: 2.4.8
213
214
  signing_key:
214
215
  specification_version: 4
215
216
  summary: Sensu plugins for netscaler
metadata.gz.sig CHANGED
Binary file