Index: trunk/udpprofile/profile-stats-logger.py |
— | — | @@ -0,0 +1,44 @@ |
| 2 | +#!/usr/bin/python |
| 3 | + |
| 4 | +import sys, time, os, os.path, math, pprint |
| 5 | + |
| 6 | +sys.path.append( '/usr/lib/cgi-bin/ng' ) |
| 7 | +import config |
| 8 | +from extractprofile import SocketProfile |
| 9 | +import rrdtool |
| 10 | + |
| 11 | +profId = 'stats/1.17-phase1' |
| 12 | +rrdFileName = '/var/lib/profile-stats-logger/stats.rrd' |
| 13 | + |
| 14 | +if not os.path.exists( rrdFileName ): |
| 15 | + rrdtool.create( |
| 16 | + rrdFileName, |
| 17 | + '--step', '10', |
| 18 | + 'DS:pcache_hit:DERIVE:60:0:U', |
| 19 | + 'DS:pcache_miss_absent:DERIVE:60:0:U', |
| 20 | + 'DS:pcache_miss_expired:DERIVE:60:0:U', |
| 21 | + 'DS:pcache_miss_invalid:DERIVE:60:0:U', |
| 22 | + 'RRA:AVERAGE:0.1:1:8640', # 10s intervals for 24 hours |
| 23 | + 'RRA:AVERAGE:0.1:30:8640', # 5 min intervals for 1 month |
| 24 | + 'RRA:AVERAGE:0.1:360:8640' # 1 hour intervals for 1 year |
| 25 | + ) |
| 26 | + |
| 27 | +nextTime = math.floor(time.time() / 10) * 10 + 10 |
| 28 | + |
| 29 | +while True: |
| 30 | + while time.time() < nextTime: |
| 31 | + time.sleep(nextTime - time.time()) |
| 32 | + nextTime += 10 |
| 33 | + |
| 34 | + fullProfile = SocketProfile(config.host,config.port).extract() |
| 35 | + if not ( profId in fullProfile ): |
| 36 | + continue |
| 37 | + profile = fullProfile[profId]['-'] |
| 38 | + |
| 39 | + rrdtool.update( |
| 40 | + rrdFileName, |
| 41 | + 'N:' + str(profile['pcache_hit']['count']) + |
| 42 | + ':' + str(profile['pcache_miss_absent']['count']) + |
| 43 | + ':' + str(profile['pcache_miss_expired']['count']) + |
| 44 | + ':' + str(profile['pcache_miss_invalid']['count'] ) ) |
| 45 | + |
Property changes on: trunk/udpprofile/profile-stats-logger.py |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 46 | + native |
Added: svn:executable |
2 | 47 | + * |
Index: trunk/udpprofile/web/pcache-hit-rate.py |
— | — | @@ -0,0 +1,39 @@ |
| 2 | +#!/usr/bin/python |
| 3 | +import sys, os, rrdtool, cgi, cgitb |
| 4 | + |
| 5 | +cgitb.enable() |
| 6 | + |
| 7 | +form = cgi.SvFormContentDict() |
| 8 | +if 'period' in form: |
| 9 | + period = int( form['period'] ) |
| 10 | +else: |
| 11 | + period = 30 |
| 12 | + |
| 13 | +print 'Content-Type: image/png' |
| 14 | +print |
| 15 | + |
| 16 | +rrdFileName = '/var/lib/profile-stats-logger/stats.rrd' |
| 17 | +rrdtool.graph( |
| 18 | + '-', |
| 19 | + '--start', '-' + str( period ) + 'm', |
| 20 | + '--width', '800', |
| 21 | + '--height', '500', |
| 22 | + '--upper-limit', '100', |
| 23 | + '--rigid', |
| 24 | + 'DEF:pcache_hit=' + rrdFileName + ':pcache_hit:AVERAGE', |
| 25 | + 'DEF:pcache_miss_absent=' + rrdFileName + ':pcache_miss_absent:AVERAGE', |
| 26 | + 'DEF:pcache_miss_expired=' + rrdFileName + ':pcache_miss_expired:AVERAGE', |
| 27 | + 'DEF:pcache_miss_invalid=' + rrdFileName + ':pcache_miss_invalid:AVERAGE', |
| 28 | + 'CDEF:total=pcache_hit,pcache_miss_absent,pcache_miss_expired,pcache_miss_invalid,+,+,+', |
| 29 | + 'CDEF:pcache_hit_percent=100,pcache_hit,total,/,*', |
| 30 | + 'CDEF:pcache_miss_absent_percent=100,pcache_miss_absent,total,/,*', |
| 31 | + 'CDEF:pcache_miss_expired_percent=100,pcache_miss_expired,total,/,*', |
| 32 | + 'CDEF:pcache_miss_invalid_percent=100,pcache_miss_invalid,total,/,*', |
| 33 | + 'CDEF:pcache_hit_avg=pcache_hit_percent,120,TREND', |
| 34 | + 'AREA:pcache_hit_percent#00ff00:Hit %:STACK', |
| 35 | + 'AREA:pcache_miss_absent_percent#ffff00:Miss (absent) %:STACK', |
| 36 | + 'AREA:pcache_miss_expired_percent#ff8888:Miss (expired) %:STACK', |
| 37 | + 'AREA:pcache_miss_invalid_percent#ff0000:Miss (invalid) %:STACK', |
| 38 | + 'LINE:pcache_hit_avg#000080:Hit % (2 min. avg)', |
| 39 | +) |
| 40 | + |
Property changes on: trunk/udpprofile/web/pcache-hit-rate.py |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 41 | + native |
Added: svn:executable |
2 | 42 | + * |