Thanks for the great response! I'll get right on it and send you something in a few days.
Steve -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Roberto De Ioris Sent: Monday, October 29, 2012 11:23 PM To: uWSGI developers and users list Subject: Re: [uWSGI] snmp functions > I was looking at adding the ability to report back statistics in my > web application. I was planning on exporting them via snmp, so I could > graph operations/sec, etc in cacti. I was very happy that uwsgi has > this functionality already! However, I can only set a counter; I can't > get/update or increment. Mostly, I want my application to increment a > counter per operation, and increment a byte count. > > I don't know what the proper way to suggest changes, so please pardon > me if I'm doing it wrong here. > > I was thinking of adding some functions: > > Existing functions: > uwsgi.snmp_set_counter32 > uwsgi.snmp_set_counter64 > uwsgi.snmp_set_gauge > > Proposed new: > uwsgi.snmp_incr_counter32 > uwsgi.snmp_incr_counter64 > > I'm thinking that the _incr functions should take an optional argument > (integer type) that will increment the counter by that amount. The > default would be 1. > Making the increment functions should be straightforward, based on the > existing set functions. Do I need to create a lock like in > py_uwsgi_sharedarea_inclong? > > I'm happy to write the code for this, just let me know how you'd like > me to proceed. > > Steve > It is a bit annoying that for simple increments we need to work with locking, but uWSGI api currently lacks atomic math operations. So, yes you should put the increment/decrement under a (one line) locked section. I suggest you to create the lock in uwsgi_setup_snmp in core/snmp.c uwsgi.snmp_lock = uwsgi_lock_init("snmp"); should be enough (obviously remember to add snmp_lock in uwsgi.h) Regarding sending a patch, just use a github pull request Note: you should put under a locked section even the current setter/getter functions. Remember tu release the python gil before acquiring the snmp lock. Thanks a lot -- Roberto De Ioris http://unbit.it _______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi _______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
