Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
919dc97
commit 47569a6
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Plugin to monitor status of Floating IPs in Nova | ||
# | ||
# To monitor the total number of VMs launched since installing openstack | ||
# E.g. | ||
# ln -s /usr/share/munin/plugins/nova_vms_launched /etc/munin/plugins/nova_floating_ips | ||
# | ||
# Needs following minimal configuration in plugin-conf.d/nova: | ||
# [nova_*] | ||
# user nova | ||
# | ||
# Magic markers | ||
#%# capabilities=autoconf | ||
#%# family=nova | ||
|
||
from nova import context | ||
from nova import db | ||
from nova import flags | ||
from nova import utils | ||
from nova.db.sqlalchemy.session import get_session | ||
import sys | ||
|
||
def print_config(): | ||
global states | ||
print 'graph_title Nova VMs Launched' | ||
print 'graph_vlabel VMs' | ||
print 'graph_args --base 1000 --lower-limit 0' | ||
print 'graph_category nova' | ||
print 'graph_scale no' | ||
print 'graph_info This graph shows the number of VMs launched since the beginning of time' | ||
print 'vms.label servers' | ||
print 'vms.draw LINE2' | ||
|
||
def get_status(): | ||
connection = get_session().connection() | ||
row = connection.execute("select count(*) from instances").fetchall()[0] | ||
return row[0] | ||
|
||
def print_values(): | ||
qty = get_status() | ||
print "vms.value %s" % qty | ||
|
||
if __name__ == '__main__': | ||
if len(sys.argv) > 1: | ||
if sys.argv[1] == "config": | ||
print_config() | ||
elif sys.argv[1]=="autoconf" : | ||
print "yes" | ||
else: | ||
utils.default_flagfile() | ||
flags.FLAGS(sys.argv) | ||
print_values() |