This file is indexed.

/usr/share/munin-openstack/plugins/nova_services is in munin-plugins-openstack 1.20120627-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
#!/usr/bin/env python
#
# Copyright (C) 2012 eNovance <licensing@enovance>
# 
# Authors: Mehdi Abaakouk <sileht@sileht.net>
#          Gael Lambert <gael.lambert@enovance.com>
#          Jesse Andrews <anotherjesse@rackspace.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#
# Plugin to report service status
#
# Needs following minimal configuration in plugin-conf.d/nova:
#   [nova_*]
#   user nova
#
# Magic markers
#%# capabilities=autoconf
#%# family=auto

import sys

try:
    from nova import context
    from nova import db
    from nova import flags
    from nova import utils
except ImportError:
    succesful_import = False
else:
    succesful_import = True

services = ['nova-compute', 'nova-volume', 'nova-scheduler', 'nova-vncproxy', 'nova-network', 'nova-cert', 'nova-console', 'nova-consoleauth']


def print_config():
    global services
    print 'graph_title Nova Services'
    print 'graph_vlabel qty'
    print 'graph_args --base 1000 --lower-limit 0'
    print 'graph_category nova'
    print 'graph_scale no'
    print 'graph_info Nova services - alive and active'
    for service in services:
        print '%s_alive.label %s alive' % (service, service)
        print '%s_alive.draw LINE2' % service
        print '%s_alive.info seen in last 30 seconds' % service
        print '%s_active.label %s active' % (service, service)
        print '%s_active.draw LINE2' % service
        print '%s_active.info alive and enabled' % service


def get_status():
    global services
    alive = {}
    active = {}
    for k in services:
        alive[k] = 0
        active[k] = 0

    ctxt = context.get_admin_context()
    now = utils.utcnow()
    services = db.service_get_all(ctxt)
    for svc in services:
        delta = now - (svc['updated_at'] or svc['created_at'])
        if (delta.seconds <= 30):
            alive[svc['binary']] += 1
            if not svc['disabled']:
                active[svc['binary']] += 1

    return {'alive': alive, 'active': active}


def print_values():
    status = get_status()
    for (state, value) in status['alive'].iteritems():
        print "%s_alive.value %s" % (state, value)
    for (state, value) in status['active'].iteritems():
        print "%s_active.value %s" % (state, value)


if __name__ == '__main__':
    if len(sys.argv) > 1:
        if sys.argv[1] == "config":
            print_config()
        elif sys.argv[1] == "autoconf":
            if not succesful_import:  
                print 'no (failed import nova module]'
            else:
                print 'yes'
    elif succesful_import:
        utils.default_flagfile()
        flags.FLAGS(sys.argv)
        print_values()