I'm curious to see if there is any interest in a python module which  
provides kstat access in the same vein as the current perl support?  I  
have a prototype written and if there is sufficient interest I'm  
willing to share it around.  I would like to see it mature somewhat in  
the hands of users and then submit it to PSARC for inclusion with  
Solaris/OpenSolaris.

As a tease, a cheap knock off of kstat(1m):

#!/usr/bin/env python

import cKstats
import time

def pprint(k):
     fmt = '%-7s %-31s %-9s %s'
     print fmt % ( 'module:',k.module,'instance:',k.instance )
     print fmt % ( 'name:',k.name,'class:',k.classname )

     items = k.items()
     items.append( ('crtime',k.crtime) )
     items.append( ('snaptime',k.snaptime) )
     items.sort()
     fmt = '        %-31s %s'
     for item in items:
         print fmt % item
     print

kstats = cKstats.lookup()

kstats.sort()

for k in kstats:
     pprint(k)


# kstat.py
module: arp                                        instance: 0
name:   NIC_EVENTS                      class:    hook_event
         crtime                          151499700171280
         events                           1
         hooksAdded                0
         hooksRemoved          0
         snaptime                      2657861308829920
...


Reply via email to