On Tue, 2011-02-22 at 17:35 +0100, Lukas Zapletal wrote: > Hello > > here comes my solution. It pings the database, increments the counter, > measures the lag and also shows the version number. > > Example output: > > # curl -k -u admin:admin https://xxx/pulp/api/services/ping/ > { > "db_version": 2, > "ping_duration_ms": "1.68", > "ping_count": 35 > } > > The code: > > class PingAction(JSONController): > > @JSONController.error_handler > def GET(self): > """ > Dummy call that just prints time. > @return: db_version - current DB version number > """ > _props_db = get_object_db('properties', ['key']) > > # insert the first entry if there is no such document > if _props_db.find_one({"key": "ping_service_count"}) == None: > _props_db.insert({"key": "ping_service_count", "value": 0}) > > # increment the counter and return > _start_time = time.time() > _props_db.update({"key": "ping_service_count"}, > {"$inc": {"value": 1}}) > count = _props_db.find_one( > {"key": "ping_service_count"})['value'] > > # return the response > return self.ok({ > "db_version": VERSION, > "ping_count": count, > "ping_duration_ms": str(round((time.time() - > _start_time) * 1000, 2)), > }) > > Attaching the patch. > > Comments? >
Hi Lukas, Sorry about our lack of responsiveness as of late. We've been pretty busy dousing fires in the code base. I'll be happy to look at this today and give you some feedback. -- Jason L Connor linear on freenode #pulp http://pulpproject.org/ RHCE: 805010912355231 GPG Fingerprint: 2048R/CC4ED7C1
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Pulp-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/pulp-list
