@@ -9,24 +9,13 @@ def get_result(cmd):
99 x .stdout .close ()
1010 return ret
1111
12- def fix_size (size ):
13- if size .endswith ('T' ):
14- size = float (size [:- 1 ]) * 2 ** 40
15- elif size .endswith ('G' ):
16- size = float (size [:- 1 ]) * 2 ** 30
17- elif size .endswith ('M' ):
18- size = float (size [:- 1 ]) * 2 ** 20
19- return int (size )
20-
2112def get_available ():
22- raw = get_result ('/usr/sbin/zfs get available tank' )
23- size = raw .split ()[- 2 ]
24- return fix_size (size )
13+ raw = int (get_result ('/usr/sbin/zfs get -H -o value -p available tank' ).strip ())
14+ return raw
2515
2616def get_used ():
27- raw = get_result ('/usr/sbin/zfs get used tank' )
28- size = raw .split ()[- 2 ]
29- return fix_size (size )
17+ raw = int (get_result ('/usr/sbin/zfs get -H -o value -p used tank' ).strip ())
18+ return raw
3019
3120def get_uptime ():
3221 raw = get_result ('/usr/gnu/bin/uptime' )
@@ -45,23 +34,15 @@ def get_uptime():
4534stats = {}
4635start_time = time .time ()
4736
48- rpool_status = False # assume the worst
37+ rpool_status = 'Not Healthy' # assume the worst
4938if get_result ('/usr/sbin/zpool status -x rpool' ).endswith ('is healthy' ):
50- rpool_status = True
39+ rpool_status = 'Healthy'
5140stats ['rpool_healthy' ] = rpool_status
52- if rpool_status :
53- stats ['rpool_warning' ] = ''
54- else :
55- stats ['rpool_warning' ] = 'warning'
5641
57- tank_status = False # assume the worst
42+ tank_status = 'not Healthy' # assume the worst
5843if get_result ('/usr/sbin/zpool status -x tank' ).endswith ('is healthy' ):
59- tank_status = True
44+ tank_status = 'Healthy'
6045stats ['tank_healthy' ] = tank_status
61- if tank_status :
62- stats ['tank_warning' ] = ''
63- else :
64- stats ['tank_warning' ] = 'warning'
6546
6647stats ['file_server_uptime' ] = get_uptime ()
6748
@@ -123,10 +104,10 @@ def get_uptime():
123104'''
124105
125106pools = '<div id="pools"><h3>Filesystem Status</h3><div id="rpool_status"'
126- if stats ['rpool_healthy' ] is False :
107+ if stats ['rpool_healthy' ] == 'Not Healthy' :
127108 pools += ' class="warning"'
128109pools += '><span>rpool</span><span>%(rpool_healthy)s</span></div><div id="tank_status"'
129- if stats ['tank_healthy' ] is False :
110+ if stats ['tank_healthy' ] == 'Not Healthy' :
130111 pools += ' class="warning"'
131112pools += '><span>tank</span><span>%(tank_healthy)s</span></div></div>'
132113
0 commit comments