Esempio n. 1
0
    for line in vospart.stdout:
        match = fmt.match(line)
        if match:
            free = int(match.group('free')) * 1024
            tot = int(match.group('tot')) * 1024
            used = tot - free
            tfree += free
            ttot += tot

            # TODO Make a first pass to find actual largest.
            largest = max(2*1024**4, tot)
            p = float(used)/tot
            w_u = float(used)/largest
            w_f = float(free)/largest
            print '    ' + tr('td', hostlink, match.group('part'),
                              size_fmt(used),
                              '<span class="{3} bar" style="width: {1:.1%};">{0:.0%}</span><span class="free bar" style="width:{2:.1%};">&#160;</span>' \
                                  .format(p, w_u, w_f,
                                          'used full' if p > 0.9 else 'used'),
                              size_fmt(free), size_fmt(tot))
        else:
            print 'got light? no match.'
            exit(1)
    if vospart.wait(): # (return 0 on successfull completition)
        print '    <tr>'
        print '      <td>%s</td>' % hostlink
        print '      <td colspan="5">vos partinfo failed</td>'
        print '    </tr>'

print '  <tr class="footer">'
print '    <th role="row">Totalt</th>'
Esempio n. 2
0
for server in serverlist:
    print 
    vosvols = Popen(['vos', 'listvol', server, '-c', cell, '-noauth'],
                    stdout=PIPE)

    for line in vosvols.stdout:
        match = rwvol.match(line)
        if match:
            name = match.group('vol')
            size = int(match.group('size')) * 1024
            volumes[name] = size
            volnameparts = name.split('.')
            if len(volnameparts) == 2 and volnameparts[0] == 'home':
                users.add(volnameparts[1])

    vosvols.wait()

userspace = defaultdict(int)

for vol, size in volumes.items():
    for vp in vol.split('.'):
        if vp in users:
            userspace[vp] += size

print '<ol class="listing" id="spacewasters">'
for user in sorted(userspace, key=userspace.__getitem__, reverse=True)[:40]:
    size = userspace[user]
    print '  <li><span class="user">{0}</span> <span class="size">{1}</span></li>' \
        .format(user, size_fmt(size))
print '</ol>'
Esempio n. 3
0
        if m:
            name = m.group('vol')
            volumes[name]['name'] = name
            volumes[name]['server'] = shortname
            volumes[name]['size'] = 1024 * int(m.group('size'))
            volumes[name]['type'] = m.group('type')
        m = location.match(line)
        if m:
            # volumes[name]['server'] = m.group('server')
            volumes[name]['part'] = m.group('part')
        m = quota.match(line)
        if m:
            volumes[name]['quota'] = 1024 * int(m.group('quota'))
    vospart.wait()

for vol in volumes.values():
    if vol['quota'] > 0 and vol['type'] == 'RW' and \
            not (vol['name'].startswith('home.') or
                 vol['name'].startswith('H.')):
        vol['fill'] = float(vol['size']) / vol['quota']
        if vol['fill'] > 0.95:
            print '    <tr>'
            print '      <td>', vol['name'], '</td>'
            print '      <td>', vol['server'], '</td>'
            print '      <td>', vol['part'], '</td>'
            print '      <td>{0:.0%}</td>'.format(vol['fill'])
            print '      <td>', size_fmt(vol['quota']), '</td>'
            print '    </tr>'
print '  </tbody>'
print '</table>'