sensu-plugins-openstack 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 01e614992e3535617ea3215b04cbf8fb15deea39
4
+ data.tar.gz: 7f61a3f3b0017971f65b458b0deb67f476093861
5
+ SHA512:
6
+ metadata.gz: 5c8023eae53661e8e445422e50392fb4c780f14b585ef91b66d8758594b6bd3fef1097d38e20c758fb2630f5301d5e399a828e30bc98a4c37949daebbdce7e1b
7
+ data.tar.gz: 0f76f71920586f3c975db268bb251441909bc6b96fdfec5473e8fa68a3469dfda5f4b1e7a27dc3cbfe953da3fcff73c15e6f47237b916c7282188cd3f05d3ce4
@@ -0,0 +1,2 @@
1
+ ����K�I5.������k�p3��*UX�+L
2
+ %mn׋gOx�K�t�_{�g1m"��3 �-ί� �C���C�|%F��l�!|`" ��@���c4�}k�c��ȥx*Jd�h�T�����HN��;��|0I6z�Ǹ��2�KF�Sq�i�ߝM���q&˙���L!�����B����Y���VBAt�F0Rye��'�D1t��jszm�h0�"�Y���r�z�Å�ו��A�a��+�5?�^�&5��1�)
Binary file
@@ -0,0 +1,12 @@
1
+ #Change Log
2
+ This project adheres to [Semantic Versioning](http://semver.org/).
3
+
4
+ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
+
6
+ ## Unreleased][unreleased]
7
+
8
+ ## 0.0.1 - 2015-05-21
9
+
10
+ ### Added
11
+ - initial release
12
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Sensu-Plugins
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ ## Sensu-Plugins-openstack
2
+
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-openstack.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-openstack)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-openstack.svg)](http://badge.fury.io/rb/sensu-plugins-openstack)
5
+ [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-openstack/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-openstack)
6
+ [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-openstack/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-openstack)
7
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-openstack.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-openstack)
8
+ [![Codeship Status for sensu-plugins/sensu-plugins-openstack](https://codeship.com/projects/c35bcdc0-db3b-0132-cb23-0eed4ec53b27/status?branch=master)](https://codeship.com/projects/79576)
9
+
10
+ ## Functionality
11
+
12
+ ## Files
13
+
14
+ * bin/check_ceilometer-agent-central.sh
15
+ * bin/check_ceilometer-agent-compute.sh
16
+ * bin/check_ceilometer-api.sh
17
+ * bin/check_ceilometer-collector.sh
18
+ * bin/check_keystone-api.sh
19
+ * bin/keystone-token-metrics.rb
20
+ * bin/check_neutron-api.py
21
+ * bin/neutron-agent-status.py
22
+ * bin/nova-hypervisor-metrics.py
23
+ * bin/nova-server-state-metrics.py
24
+
25
+ ## Usage
26
+
27
+ ## Installation
28
+
29
+ [Installation and Setup](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
30
+
31
+ ## Notes
32
+
@@ -0,0 +1,44 @@
1
+ #!/bin/bash
2
+ #
3
+ # Ceilometer Central Agent monitoring script for Sensu
4
+ #
5
+ # Copyright © 2013 eNovance <licensing@enovance.com>
6
+ #
7
+ # Author: Emilien Macchi <emilien.macchi@enovance.com>
8
+ #
9
+ # This program is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+ # If not running as root, requires this line in /etc/sudoers:
23
+ # sensu ALL=(ALL) NOPASSWD: /bin/netstat -epta
24
+ #
25
+
26
+ # #RED
27
+ set -e
28
+
29
+ STATE_OK=0
30
+ STATE_WARNING=1
31
+ STATE_CRITICAL=2
32
+ STATE_UNKNOWN=3
33
+ STATE_DEPENDENT=4
34
+
35
+
36
+ PID=$(pidof -x ceilometer-agent-central)
37
+
38
+ if ! KEY=$(sudo /bin/netstat -epta 2>/dev/null | grep $PID | grep amqp)
39
+ then
40
+ echo "Ceilometer Central Agent is not connected to AMQP."
41
+ exit $STATE_CRITICAL
42
+ fi
43
+
44
+ echo "Ceilometer Central Agent is working."
@@ -0,0 +1,44 @@
1
+ #!/bin/bash
2
+ #
3
+ # Ceilometer Compute Agent monitoring script for Sensu
4
+ #
5
+ # Copyright © 2013 eNovance <licensing@enovance.com>
6
+ #
7
+ # Author: Emilien Macchi <emilien.macchi@enovance.com>
8
+ #
9
+ # This program is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+ # If not running as root, requires this line in /etc/sudoers:
23
+ # sensu ALL=(ALL) NOPASSWD: /bin/netstat -epta
24
+ #
25
+
26
+ # #RED
27
+ set -e
28
+
29
+ STATE_OK=0
30
+ STATE_WARNING=1
31
+ STATE_CRITICAL=2
32
+ STATE_UNKNOWN=3
33
+ STATE_DEPENDENT=4
34
+
35
+
36
+ PID=$(pidof -x ceilometer-agent-compute)
37
+
38
+ if ! KEY=$(sudo /bin/netstat -epta 2>/dev/null | grep $PID | grep amqp)
39
+ then
40
+ echo "Ceilometer Compute Agent is not connected to AMQP."
41
+ exit $STATE_CRITICAL
42
+ fi
43
+
44
+ echo "Ceilometer Compute Agent is working."
@@ -0,0 +1,88 @@
1
+ #!/bin/bash
2
+ #
3
+ # Ceilometer API monitoring script for Sensu
4
+ #
5
+ # Copyright © 2013 eNovance <licensing@enovance.com>
6
+ #
7
+ # Author: Emilien Macchi <emilien.macchi@enovance.com>
8
+ #
9
+ # This program is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ # #RED
24
+ set -e
25
+
26
+ STATE_OK=0
27
+ STATE_WARNING=1
28
+ STATE_CRITICAL=2
29
+ STATE_UNKNOWN=3
30
+ STATE_DEPENDENT=4
31
+
32
+ usage ()
33
+ {
34
+ echo "Usage: $0 [OPTIONS]"
35
+ echo " -h Get help"
36
+ echo " -H <Auth URL> URL for obtaining an auth token"
37
+ echo " -U <username> Username to use to get an auth token"
38
+ echo " -T <tenant> Tenant to use to get an auth token"
39
+ echo " -P <password> Password to use ro get an auth token"
40
+ echo " -E <Endpoint> URL for Ceilometer endpoint. Optional. If blank, use service catalog"
41
+ }
42
+
43
+ while getopts 'h:H:U:T:P:E:' OPTION
44
+ do
45
+ case $OPTION in
46
+ h)
47
+ usage
48
+ exit 0
49
+ ;;
50
+ H)
51
+ export OS_AUTH_URL=$OPTARG
52
+ ;;
53
+ U)
54
+ export OS_USERNAME=$OPTARG
55
+ ;;
56
+ T)
57
+ export OS_TENANT_NAME=$OPTARG
58
+ ;;
59
+ P)
60
+ export OS_PASSWORD=$OPTARG
61
+ ;;
62
+ E)
63
+ export CEILOMETER_URL=$OPTARG
64
+ ;;
65
+ *)
66
+ usage
67
+ exit 1
68
+ ;;
69
+ esac
70
+ done
71
+
72
+
73
+ if ! which ceilometer >/dev/null 2>&1
74
+ then
75
+ echo "python-ceilometerclient is not installed."
76
+ exit $STATE_UNKNOWN
77
+ fi
78
+
79
+
80
+ if ! KEY=$(ceilometer meter-list 2>/dev/null)
81
+ then
82
+ echo "Unable to list meters"
83
+ exit $STATE_CRITICAL
84
+ fi
85
+
86
+ count=$(($(ceilometer meter-list 2>/dev/null | wc -l)-4))
87
+
88
+ echo "Ceilometer API is working with $count meters."
@@ -0,0 +1,44 @@
1
+ #!/bin/bash
2
+ #
3
+ # Ceilometer Collector monitoring script for Sensu
4
+ #
5
+ # Copyright © 2013 eNovance <licensing@enovance.com>
6
+ #
7
+ # Author: Emilien Macchi <emilien.macchi@enovance.com>
8
+ #
9
+ # This program is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+ # If not running as root, requires this line in /etc/sudoers:
23
+ # sensu ALL=(ALL) NOPASSWD: /bin/netstat -epta
24
+ #
25
+
26
+ # #RED
27
+ set -e
28
+
29
+ STATE_OK=0
30
+ STATE_WARNING=1
31
+ STATE_CRITICAL=2
32
+ STATE_UNKNOWN=3
33
+ STATE_DEPENDENT=4
34
+
35
+
36
+ PID=$(pidof -x ceilometer-collector)
37
+
38
+ if ! KEY=$(sudo /bin/netstat -epta 2>/dev/null | grep $PID | grep amqp)
39
+ then
40
+ echo "Ceilometer Collector is not connected to AMQP."
41
+ exit $STATE_CRITICAL
42
+ fi
43
+
44
+ echo "Ceilometer Collector is working."
@@ -0,0 +1,89 @@
1
+ #!/bin/bash
2
+ #
3
+ # Keystone API monitoring script for Sensu
4
+ #
5
+ # Copyright © 2013 eNovance <licensing@enovance.com>
6
+ #
7
+ # Author: Emilien Macchi <emilien.macchi@enovance.com>
8
+ #
9
+ # This program is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+ # Requirement: curl
23
+ #
24
+
25
+ # #RED
26
+ set -e
27
+
28
+ STATE_OK=0
29
+ STATE_WARNING=1
30
+ STATE_CRITICAL=2
31
+ STATE_UNKNOWN=3
32
+ STATE_DEPENDENT=4
33
+
34
+ usage ()
35
+ {
36
+ echo "Usage: $0 [OPTIONS]"
37
+ echo " -h Get help"
38
+ echo " -H <Auth URL> URL for obtaining an auth token"
39
+ echo " -U <username> Username to use to get an auth token"
40
+ echo " -P <password> Password to use ro get an auth token"
41
+ }
42
+
43
+ while getopts 'h:H:U:T:P:' OPTION
44
+ do
45
+ case $OPTION in
46
+ h)
47
+ usage
48
+ exit 0
49
+ ;;
50
+ H)
51
+ export OS_AUTH_URL=$OPTARG
52
+ ;;
53
+ U)
54
+ export OS_USERNAME=$OPTARG
55
+ ;;
56
+ P)
57
+ export OS_PASSWORD=$OPTARG
58
+ ;;
59
+ *)
60
+ usage
61
+ exit 1
62
+ ;;
63
+ esac
64
+ done
65
+
66
+ if ! which curl >/dev/null 2>&1
67
+ then
68
+ echo "curl is not installed."
69
+ exit $STATE_UNKNOWN
70
+ fi
71
+
72
+ START=`date +%s`
73
+ TOKEN=$(curl -d '{"auth":{"passwordCredentials":{"username": "'$OS_USERNAME'", "password": "'$OS_PASSWORD'"}}}' -H "Content-type: application/json" ${OS_AUTH_URL}:5000/v2.0/tokens/ 2>&1 | grep token|awk '{print $8}'|grep -o '".*"' | sed -n 's/.*"\([^"]*\)".*/\1/p')
74
+ END=`date +%s`
75
+
76
+ TIME=$((END-START))
77
+
78
+ if [ -z "$TOKEN" ]; then
79
+ echo "Unable to get a token"
80
+ exit $STATE_CRITICAL
81
+ else
82
+ if [ $TIME -gt 10 ]; then
83
+ echo "Get a token after 10 seconds, it's too long."
84
+ exit $STATE_WARNING
85
+ else
86
+ echo "Got a token, Keystone API is working."
87
+ exit $STATE_OK
88
+ fi
89
+ fi
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Get OpenStack Keystone token counts from MySQL
4
+ # ===
5
+ #
6
+ # Dependencies:
7
+ # - mysql2 gem
8
+ #
9
+ # Query MySQL for Keystone token counts and output in graphite-friendly
10
+ # format. Shows active, expired, and total token counts. Also has the
11
+ # option to produce counts by individual Keystone username (--by-user)
12
+ # as well as a filtered list of username(s) (--ks-users).
13
+ #
14
+ # Copyright 2013 Brian Clark <brian.clark@cloudapt.com>
15
+ #
16
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
17
+ # for details.
18
+
19
+ require 'sensu-plugin/metric/cli'
20
+ require 'mysql2'
21
+ require 'socket'
22
+
23
+ class KeystoneTokenCounts < Sensu::Plugin::Metric::CLI::Graphite
24
+ option :host,
25
+ short: '-h HOST',
26
+ long: '--host HOST',
27
+ description: 'Mysql Host to connect to',
28
+ default: 'localhost'
29
+
30
+ option :port,
31
+ short: '-P PORT',
32
+ long: '--port PORT',
33
+ description: 'Mysql Port to connect to',
34
+ proc: proc(&:to_i),
35
+ default: 3306
36
+
37
+ option :username,
38
+ short: '-u USERNAME',
39
+ long: '--user USERNAME',
40
+ description: 'Mysql Username',
41
+ required: true
42
+
43
+ option :password,
44
+ short: '-p PASSWORD',
45
+ long: '--pass PASSWORD',
46
+ description: 'Mysql password',
47
+ default: ''
48
+
49
+ option :scheme,
50
+ description: 'Metric naming scheme, text to prepend to metric',
51
+ short: '-s SCHEME',
52
+ long: '--scheme SCHEME',
53
+ default: "#{Socket.gethostname}.keystone.tokens"
54
+
55
+ option :socket,
56
+ short: '-S SOCKET',
57
+ long: '--socket SOCKET'
58
+
59
+ option :by_user,
60
+ description: 'Show token counts by user',
61
+ long: '--by-user',
62
+ boolean: true,
63
+ default: false
64
+
65
+ option :ks_users,
66
+ description: 'Delimited list of users to include',
67
+ long: '--ks-users USER[,USER]'
68
+
69
+ option :database,
70
+ short: '-d DATABASE',
71
+ long: '--database DATABASE',
72
+ description: 'Database name',
73
+ default: 'keystone'
74
+
75
+ def run
76
+ if config[:ks_users]
77
+ config[:by_user] = true
78
+ where = "WHERE user.name IN ('#{config[:ks_users].gsub(/,/, "', '")}')"
79
+ end
80
+ metrics = %w(active expired total)
81
+ sql = <<-eosql
82
+ SELECT #{ 'user.name,' if config[:by_user] }
83
+ SUM(IF(NOW() <= expires,1,0)) AS active,
84
+ SUM(IF(NOW() > expires,1,0)) AS expired,
85
+ COUNT(*) AS total FROM token
86
+ eosql
87
+ sql.concat <<-eosql if config[:by_user]
88
+ LEFT JOIN user ON token.user_id = user.id #{ where }
89
+ GROUP BY user.name
90
+ eosql
91
+ begin
92
+ mysql = Mysql2::Client.new(
93
+ host: config[:host], port: config[:port],
94
+ username: config[:username], password: config[:password],
95
+ socket: config[:socket], database: config[:database]
96
+ )
97
+ mysql.query(sql).each do |row|
98
+ metrics.size.times do |i|
99
+ if config[:by_user]
100
+ output "#{config[:scheme]}.#{row['name']}.#{metrics[i]}",
101
+ row[metrics[i]]
102
+ else
103
+ output "#{config[:scheme]}.#{metrics[i]}", row[metrics[i]]
104
+ end
105
+ end
106
+ end
107
+ rescue => e
108
+ puts e.message
109
+ ensure
110
+ mysql.close if mysql
111
+ end
112
+ ok
113
+ end
114
+ end
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # Check OpenStack Neutron API Status
4
+ # ===
5
+ #
6
+ # Dependencies
7
+ # -----------
8
+ # - python-neutronclient and related libraries
9
+ #
10
+ # Performs API query to determine 'alive' status of the
11
+ # Neutron API.
12
+ #
13
+ # Author: Mike Dorman <mdorman@godaddy.com>
14
+ # Significantly based on neutron-agent-status.py by
15
+ # Brian Clark <brian.clark@cloudapt.com>
16
+ #
17
+ # Released under the same terms as Sensu (the MIT license);
18
+ # see LICENSE for details.
19
+ #
20
+
21
+ # #RED
22
+ import sys
23
+ import argparse
24
+ import logging
25
+ from neutronclient.neutron import client
26
+
27
+ STATE_OK = 0
28
+ STATE_WARNING = 1
29
+ STATE_CRITICAL = 2
30
+ STATE_UNKNOWN = 3
31
+
32
+ logging.basicConfig(level=logging.INFO)
33
+ #logging.basicConfig(level=logging.DEBUG)
34
+
35
+ parser = argparse.ArgumentParser(description='Check OpenStack Neutron API status')
36
+ parser.add_argument('--auth-url', metavar='URL', type=str,
37
+ required=True,
38
+ help='Keystone URL')
39
+ parser.add_argument('--username', metavar='username', type=str,
40
+ required=True,
41
+ help='username for authentication')
42
+ parser.add_argument('--password', metavar='password', type=str,
43
+ required=True,
44
+ help='password for authentication')
45
+ parser.add_argument('--tenant', metavar='tenant', type=str,
46
+ required=True,
47
+ help='tenant name for authentication')
48
+ parser.add_argument('--region_name', metavar='region', type=str,
49
+ help='Region to select for authentication')
50
+ parser.add_argument('--bypass', metavar='bybass', type=str,
51
+ required=False,
52
+ help='bypass the service catalog and use this URL for Nova API')
53
+
54
+ args = parser.parse_args()
55
+
56
+ try:
57
+ c = client.Client('2.0',
58
+ username=args.username,
59
+ tenant_name=args.tenant,
60
+ password=args.password,
61
+ auth_url=args.auth_url,
62
+ region_name=args.region_name,
63
+ insecure=True,
64
+ endpoint_url=args.bypass)
65
+ networks = c.list_networks()
66
+ except Exception as e:
67
+ print str(e)
68
+ sys.exit(STATE_CRITICAL)
69
+
70
+ if len(networks) < 1:
71
+ exit_state = STATE_WARNING
72
+ state_string = "WARNING"
73
+ else:
74
+ exit_state = STATE_OK
75
+ state_string = "OK"
76
+
77
+ print "Neutron API status: {state_str}, {networks} network(s) found.".format(state_str=state_string, networks=len(networks))
78
+ sys.exit(exit_state)
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # Check OpenStack Neutron Agent Status
4
+ # ===
5
+ #
6
+ # Dependencies
7
+ # -----------
8
+ # - python-neutronclient and related libraries
9
+ #
10
+ # Performs API query to determine 'alive' status of all
11
+ # (or filtered list of) Neutron network agents. Also has
12
+ # ability to warn if any agents have been administratively
13
+ # disabled.
14
+ #
15
+ # Copyright 2013 Brian Clark <brian.clark@cloudapt.com>
16
+ #
17
+ # Released under the same terms as Sensu (the MIT license);
18
+ # see LICENSE for details.
19
+ #
20
+
21
+ # #RED
22
+ import sys
23
+ import argparse
24
+ import logging
25
+ from neutronclient.neutron import client
26
+
27
+ STATE_OK = 0
28
+ STATE_WARNING = 1
29
+ STATE_CRITICAL = 2
30
+ STATE_UNKNOWN = 3
31
+
32
+ logging.basicConfig(level=logging.INFO)
33
+ #logging.basicConfig(level=logging.DEBUG)
34
+
35
+ parser = argparse.ArgumentParser(description='Check OpenStack Neutron agent status')
36
+ parser.add_argument('--auth-url', metavar='URL', type=str,
37
+ required=True,
38
+ help='Keystone URL')
39
+ parser.add_argument('--username', metavar='username', type=str,
40
+ required=True,
41
+ help='username for authentication')
42
+ parser.add_argument('--password', metavar='password', type=str,
43
+ required=True,
44
+ help='password for authentication')
45
+ parser.add_argument('--tenant', metavar='tenant', type=str,
46
+ required=True,
47
+ help='tenant name for authentication')
48
+ parser.add_argument('--region_name', metavar='region', type=str,
49
+ help='Region to select for authentication')
50
+ parser.add_argument('--host', metavar='host', type=str,
51
+ help='filter by specific host')
52
+ parser.add_argument('--agent-type', metavar='type', type=str,
53
+ help='filter by specific agent type')
54
+ parser.add_argument('--warn-disabled', action='store_true',
55
+ default=False,
56
+ help='warn if any agents administratively disabled')
57
+ args = parser.parse_args()
58
+
59
+ try:
60
+ c = client.Client('2.0',
61
+ username=args.username,
62
+ tenant_name=args.tenant,
63
+ password=args.password,
64
+ auth_url=args.auth_url,
65
+ region_name=args.region_name)
66
+ params = {}
67
+ if args.host: params['host'] = args.host
68
+ if args.agent_type: params['agent_type'] = args.agent_type
69
+ agents = c.list_agents(**params)
70
+ except Exception as e:
71
+ print str(e)
72
+ sys.exit(STATE_CRITICAL)
73
+
74
+ agents_down = []
75
+ agents_disabled = []
76
+ messages = []
77
+ exit_state = STATE_OK
78
+ for a in agents['agents']:
79
+ if a['admin_state_up'] and not a['alive']:
80
+ agents_down.append(a)
81
+ elif not a['admin_state_up']:
82
+ agents_disabled.append(a)
83
+
84
+ if agents_down:
85
+ for a in agents_down:
86
+ messages.append("{agent_type} on {host} is down".format(agent_type=a['agent_type'], host=a['host']))
87
+ exit_state = STATE_CRITICAL
88
+
89
+ if args.warn_disabled and agents_disabled:
90
+ for a in agents_disabled:
91
+ messages.append("{agent_type} on {host} is {alive} and disabled"
92
+ .format(agent_type=a['agent_type'],
93
+ host=a['host'],
94
+ alive='alive' if a['alive'] else 'down'))
95
+ if exit_state != STATE_CRITICAL: exit_state = STATE_WARNING
96
+
97
+ if len(messages) == 1:
98
+ print "Neutron agent status: {status}".format(status=messages[0])
99
+ else:
100
+ print "Neutron agent status {agents} total / {agents_down} down / {agents_disabled} disabled".format(agents=len(agents['agents']),
101
+ agents_down=len(agents_down),
102
+ agents_disabled=len(agents_disabled))
103
+
104
+ if len(messages) > 1: print "\n".join(messages)
105
+ exit(exit_state)
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env python
2
+
3
+
4
+ # This plugin gives information about the hypervisors. It works as is if using Python2.7 but to get it working with Python2.6 and
5
+ # before (as well as Python 3.0) require that you number the placeholders in the format method().
6
+ # This way wherever the {} is used, number it starting from 0. e.g., {0}.nova.hypervisor
7
+
8
+ # #RED
9
+ from argparse import ArgumentParser
10
+ import socket
11
+ import time
12
+
13
+ from novaclient.v3 import Client
14
+
15
+ DEFAULT_SCHEME = '{}.nova.hypervisors'.format(socket.gethostname())
16
+
17
+ METRIC_KEYS = (
18
+ 'current_workload',
19
+ 'disk_available_least',
20
+ 'local_gb',
21
+ 'local_gb_used',
22
+ 'memory_mb',
23
+ 'memory_mb_used',
24
+ 'running_vms',
25
+ 'vcpus',
26
+ 'vcpus_used',
27
+ )
28
+
29
+ def output_metric(name, value):
30
+ print '{}\t{}\t{}'.format(name, value, int(time.time()))
31
+
32
+ def main():
33
+ parser = ArgumentParser()
34
+ parser.add_argument('-u', '--user', default='admin')
35
+ parser.add_argument('-p', '--password', default='admin')
36
+ parser.add_argument('-t', '--tenant', default='admin')
37
+ parser.add_argument('-a', '--auth-url', default='http://localhost:5000/v2.0')
38
+ parser.add_argument('-S', '--service-type', default='compute')
39
+ parser.add_argument('-H', '--host')
40
+ parser.add_argument('-s', '--scheme', default=DEFAULT_SCHEME)
41
+ args = parser.parse_args()
42
+
43
+ client = Client(args.user, args.password, args.tenant, args.auth_url, service_type=args.service_type)
44
+
45
+ if args.host:
46
+ hypervisors = client.hypervisors.search(args.host)
47
+ else:
48
+ hypervisors = client.hypervisors.list()
49
+
50
+ for hv in hypervisors:
51
+ for key, value in hv.to_dict().iteritems():
52
+ if key in METRIC_KEYS:
53
+ output_metric('{}.{}.{}'.format(args.scheme, hv.hypervisor_hostname, key), value)
54
+
55
+ if __name__ == '__main__':
56
+ main()
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env python
2
+
3
+ # #RED
4
+ from argparse import ArgumentParser
5
+ import socket
6
+ import time
7
+
8
+ from novaclient.v3 import Client
9
+
10
+ DEFAULT_SCHEME = '{}.nova.states'.format(socket.gethostname())
11
+
12
+ def output_metric(name, value):
13
+ print '{}\t{}\t{}'.format(name, value, int(time.time()))
14
+
15
+ def main():
16
+ parser = ArgumentParser()
17
+ parser.add_argument('-u', '--user', default='admin')
18
+ parser.add_argument('-p', '--password', default='admin')
19
+ parser.add_argument('-t', '--tenant', default='admin')
20
+ parser.add_argument('-a', '--auth-url', default='http://localhost:5000/v2.0')
21
+ parser.add_argument('-S', '--service-type', default='compute')
22
+ parser.add_argument('-s', '--scheme', default=DEFAULT_SCHEME)
23
+ args = parser.parse_args()
24
+
25
+ client = Client(args.user, args.password, args.tenant, args.auth_url, service_type=args.service_type)
26
+
27
+ servers = client.servers.list()
28
+
29
+ # http://docs.openstack.org/api/openstack-compute/2/content/List_Servers-d1e2078.html
30
+ states = {
31
+ 'ACTIVE': 0,
32
+ 'BUILD': 0,
33
+ 'DELETED': 0,
34
+ 'ERROR': 0,
35
+ 'HARD_REBOOT': 0,
36
+ 'PASSWORD': 0,
37
+ 'REBOOT': 0,
38
+ 'REBUILD': 0,
39
+ 'RESCUE': 0,
40
+ 'RESIZE': 0,
41
+ 'REVERT_RESIZE': 0,
42
+ 'SHUTOFF': 0,
43
+ 'SUSPENDED': 0,
44
+ 'UNKNOWN': 0,
45
+ 'VERIFY_RESIZE': 0,
46
+ }
47
+
48
+ for server in servers:
49
+ if server.status not in states:
50
+ states[server.status] = 0
51
+
52
+ states[server.status] += 1
53
+
54
+ for state, count in states.iteritems():
55
+ output_metric('{}.{}'.format(args.scheme, state.lower()), count)
56
+
57
+ if __name__ == '__main__':
58
+ main()
@@ -0,0 +1,15 @@
1
+
2
+ require 'sensu-plugins-openstack/version'
3
+
4
+ # Load the defaults
5
+
6
+ #
7
+ # Default class
8
+ #
9
+ module SensuPluginsOpenstack
10
+ class << self
11
+ end
12
+
13
+ class << self
14
+ end
15
+ end
@@ -0,0 +1,28 @@
1
+ require 'json'
2
+
3
+ # encoding: utf-8
4
+ module SensuPluginsOpenstack
5
+ # This defines the version of the gem
6
+ module Version
7
+ MAJOR = 0
8
+ MINOR = 0
9
+ PATCH = 1
10
+
11
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
12
+
13
+ NAME = 'sensu-plugins-openstack'
14
+ BANNER = "#{NAME} v%s"
15
+
16
+ module_function
17
+
18
+ def version
19
+ format(BANNER, VER_STRING)
20
+ end
21
+
22
+ def json_version
23
+ {
24
+ 'version' => VER_STRING
25
+ }.to_json
26
+ end
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,240 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-openstack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sensu-Plugins and contributors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
14
+ am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
15
+ A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
16
+ CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
17
+ LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
18
+ CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
19
+ zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
20
+ qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
21
+ k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
22
+ oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
23
+ 0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
24
+ HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
25
+ QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
26
+ MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
27
+ rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
28
+ UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
29
+ JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
30
+ 8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
+ HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
+ -----END CERTIFICATE-----
33
+ date: 2015-05-22 00:00:00.000000000 Z
34
+ dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: sensu-plugin
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '='
40
+ - !ruby/object:Gem::Version
41
+ version: 1.1.0
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 1.1.0
49
+ - !ruby/object:Gem::Dependency
50
+ name: mysql2
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '='
54
+ - !ruby/object:Gem::Version
55
+ version: 0.3.18
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '='
61
+ - !ruby/object:Gem::Version
62
+ version: 0.3.18
63
+ - !ruby/object:Gem::Dependency
64
+ name: codeclimate-test-reporter
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.4'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.4'
77
+ - !ruby/object:Gem::Dependency
78
+ name: rubocop
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0.30'
84
+ type: :development
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '0.30'
91
+ - !ruby/object:Gem::Dependency
92
+ name: rspec
93
+ requirement: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '3.1'
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '3.1'
105
+ - !ruby/object:Gem::Dependency
106
+ name: bundler
107
+ requirement: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '1.7'
112
+ type: :development
113
+ prerelease: false
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '1.7'
119
+ - !ruby/object:Gem::Dependency
120
+ name: rake
121
+ requirement: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '10.0'
126
+ type: :development
127
+ prerelease: false
128
+ version_requirements: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '10.0'
133
+ - !ruby/object:Gem::Dependency
134
+ name: github-markup
135
+ requirement: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '1.3'
140
+ type: :development
141
+ prerelease: false
142
+ version_requirements: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '1.3'
147
+ - !ruby/object:Gem::Dependency
148
+ name: redcarpet
149
+ requirement: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '3.2'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: '3.2'
161
+ - !ruby/object:Gem::Dependency
162
+ name: yard
163
+ requirement: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '0.8'
168
+ type: :development
169
+ prerelease: false
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - "~>"
173
+ - !ruby/object:Gem::Version
174
+ version: '0.8'
175
+ - !ruby/object:Gem::Dependency
176
+ name: pry
177
+ requirement: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - "~>"
180
+ - !ruby/object:Gem::Version
181
+ version: '0.10'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - "~>"
187
+ - !ruby/object:Gem::Version
188
+ version: '0.10'
189
+ description: Sensu plugins for openstack
190
+ email: "<sensu-users@googlegroups.com>"
191
+ executables: []
192
+ extensions: []
193
+ extra_rdoc_files: []
194
+ files:
195
+ - CHANGELOG.md
196
+ - LICENSE
197
+ - README.md
198
+ - bin/ceilometer/check_ceilometer-agent-central.sh
199
+ - bin/ceilometer/check_ceilometer-agent-compute.sh
200
+ - bin/ceilometer/check_ceilometer-api.sh
201
+ - bin/ceilometer/check_ceilometer-collector.sh
202
+ - bin/keystone/check_keystone-api.sh
203
+ - bin/keystone/keystone-token-metrics.rb
204
+ - bin/neutron/check_neutron-api.py
205
+ - bin/neutron/neutron-agent-status.py
206
+ - bin/nova/nova-hypervisor-metrics.py
207
+ - bin/nova/nova-server-state-metrics.py
208
+ - lib/sensu-plugins-openstack.rb
209
+ - lib/sensu-plugins-openstack/version.rb
210
+ homepage: https://github.com/sensu-plugins/sensu-plugins-openstack
211
+ licenses:
212
+ - MIT
213
+ metadata:
214
+ maintainer: ''
215
+ development_status: active
216
+ production_status: unstable - testing recommended
217
+ release_draft: 'false'
218
+ release_prerelease: 'false'
219
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
220
+ in /etc/default/sensu
221
+ rdoc_options: []
222
+ require_paths:
223
+ - lib
224
+ required_ruby_version: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: 1.9.3
229
+ required_rubygems_version: !ruby/object:Gem::Requirement
230
+ requirements:
231
+ - - ">="
232
+ - !ruby/object:Gem::Version
233
+ version: '0'
234
+ requirements: []
235
+ rubyforge_project:
236
+ rubygems_version: 2.4.6
237
+ signing_key:
238
+ specification_version: 4
239
+ summary: Sensu plugins for openstack
240
+ test_files: []
Binary file