[zenoss-zenpacks] Re: Questions re PostgresqlMonitor

dsudell dsudell at invitemedia.com
Wed Oct 8 12:50:44 EDT 2008


mray wrote:
> If you could package up your patch in a new version of the ZenPack,  
> test it and send it to me I'll fork the page and list both versions  
> there.
> 
> Thanks,
> Matt Ray
> Zenoss Community Manager
> community.zenoss.com
> mray at zenoss.com
> 
> 
> 


I didn't build a new ZenPack.  Is there an easy way to create an editable Zenpack from an uploaded installed Zenpack?  But the change is rather small and limited to libexec/check_postgresql_stats.py.  Basically I'm leaving off the tup_xxx stats from pg_stat_database that don't.  I;ve tested it aginst 8.2 and 8.3.  Not having any other versions around, I didn't attemp to think about say 8.1 or 8.4.

$ diff -u check_postgresql_stats.py  ncheck_postgresql_stats.py
--- check_postgresql_stats.py   2008-10-08 14:58:40.000000000 +0000
+++ ncheck_postgresql_stats.py  2008-10-08 16:11:34.000000000 +0000
@@ -61,15 +61,21 @@
             sys.exit(1)
     
 
+        sVersion = ""
+        query = "SELECT setting AS version from pg_settings WHERE name = 'server_version'"
+        sVersion = self.run_query(cursor, sVersion, query)
+        version = sVersion.split('=')[1]
+        
        stats = ""
         
        query = "SELECT pg_database_size(pg_database.datname) AS db_size FROM pg_database WHERE pg_database.datname='%s'" % self.database
     
        stats = self.run_query(cursor,stats,query)
 
-       query = "select numbackends, xact_commit, xact_rollback, blks_read, blks_hit, tup_returned, " \
-                "tup_fetched, tup_inserted, tup_updated, tup_deleted from pg_stat_database where datname='%s'" % self.database
-        
+       query = "select numbackends, xact_commit, xact_rollback, blks_read, blks_hit"
+        if version.startswith('8.3'):
+            query +=  ", tup_returned, tup_fetched, tup_inserted, tup_updated, tup_deleted"
+        query +=  " from pg_stat_database where datname='%s'" % self.database
 
         stats = self.run_query(cursor,stats,query)




-------------------- m2f --------------------

Read this topic online here:
http://forums.zenoss.com/viewtopic.php?p=26096#26096

-------------------- m2f --------------------





More information about the zenoss-zenpacks mailing list