3 szs/memory - a RAM and swap usage module for SZS a statusbar script for WMI
11 * added linux 2.4 support
14 * implemented swap usage
15 * implemented RAM usage
16 * implemented configurable labels
28 Copyright 2004 Christoph Wegscheider <cw@wegi.net>
33 This program is free software; you can redistribute it and/or modify
34 it under the terms of the GNU General Public License as published by
35 the Free Software Foundation; either version 2 of the License, or
36 (at your option) any later version.
38 This program is distributed in the hope that it will be useful,
39 but WITHOUT ANY WARRANTY; without even the implied warranty of
40 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 GNU General Public License for more details.
43 You should have received a copy of the GNU General Public License
44 along with this program; if not, write to the Free Software
45 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
53 cfg = szstoolbox.CFG('memory')
54 label = cfg.read('label')
55 showram = int(cfg.read('showram'))
56 showswap = int(cfg.read('showswap'))
62 file = open('/proc/meminfo')
63 values = [it.split()[1] for it in file.readlines()]
68 if szstoolbox.kernel_version[:3] == '2.6':
69 bars.append('' + str((int(values[0]) - int(values[1]) - int(values[2]) - int(values[3])) * 100 / int(values[0])) + '%')
71 bars.append('' + str((int(values[3]) - int(values[4]) - int(values[6]) - int(values[7])) * 100 / int(values[3])) + '%')
74 if showswap and int(values[11])>0:
75 if szstoolbox.kernel_version[:3] == '2.6':
76 bars.append(str((int(values[11]) - int(values[12])) * 100 / int(values[11])) + '%')
78 bars.append(str((int(values[15]) - int(values[16])) * 100 / int(values[15])) + '%')
81 if showram or (showswap and int(values[11])>0):
90 if __name__ == '__main__':
95 time.sleep(szstoolbox.interval)