The root of the problem was in my python, once I moved the connection
creation statement into the metric handler method the graphs updated as
expected.

On Wed, Dec 7, 2011 at 11:32 AM, Mike Broers <mbro...@gmail.com> wrote:

> I created a python module to graph the results of a postgres query.  When
> I evoke the python program manually by calling python postgres.py I get the
> results I expect (they change).  When I put the module and pyconf into the
> ganglia folders and restart gmond I get a graph that stays constant until I
> restart gmond again.  Whenever I restart gmond, the values get updated and
> the graphs change, but then remain constant until I restart gmond again.
>
> Here are the .py and .pyconf files, I'm unclear if there is a conf or
> update that needs to take place elsewhere to get these new python module
> metrics to start collecting based on the interval, perhaps on the gmetad
> side? I have the collect_every = 10 so I would assume it knows to collect
> more than once..
>
> #========
> #postgres.py
> #========
>
> import psycopg2
>
> #set up postgres connection
> pgdsn= "dbname=qa host=localhost user=postgres port=6543 password=****"
> db_conn = psycopg2.connect(pgdsn)
>
>
> def pg_active(name):
>     pg_active_sql = "select count(*)::integer as count from
> pg_stat_activity where current_query <> '<IDLE>' and current_query <>
> '<IDLE> in transaction'"
>
>     db_curs = db_conn.cursor()
>     db_curs.execute(pg_active_sql)
>     pg_active_sql_results = db_curs.fetchall()
>
>     (,count_active) = pg_active_sql_results[0]
>     pg_active_count= int(count_active) - 1
>     return pg_active_count
>
>     db_curs.close()
>     db_conn.close()
>
> def metric_init(params):
>     global descriptors
>
>     d3 = {'name': 'Pypg_active_sessions',
>         'call_back': pg_active,
>         'time_max': 90,
>         'value_type': 'uint',
>         'units': 'Sessions',
>         'slope': 'both',
>         'format': '%u',
>         'description': 'PG Active Sessions',
>  'groups': 'Postgres'}
>
>     descriptors = [d3]
>     return descriptors
>
> def metric_cleanup():
>     '''Clean up the metric module.'''
>     pass
>
> #This code is for debugging and unit testing
> if __name__ == '__main__':
>     metric_init({})
>     for d in descriptors:
>         v = d['call_back'](d['name'])
>         print 'value for %s is %u' % (d['name'],  v)
>
> #============
> #postgres.pyconf
> #============
> modules {
>    module {
>      name = "postgres"
>      language = "python"
>    }
> }
>
> collection_group {
>    collect_every = 10
>    time_threshold = 50
>    metric {
>      name = "Pypg_active_sessions"
>      title = "Postgres Active Sessions"
>      value_threshold = 1
>    }
>
> }
>
>
> Thanks for reviewing!
> Mike
>
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Ganglia-general mailing list
Ganglia-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-general

Reply via email to