Skip to content

Commit 26c3630

Browse files
committed
Merge remote-tracking branch 'origin/slacker87'
New release 0.4.5
2 parents b5d18bc + c1394f5 commit 26c3630

File tree

15 files changed

+284
-53
lines changed

15 files changed

+284
-53
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SHELL = /bin/sh
2424

2525
# Go tool and library path:
2626
GO = `which go`
27-
GOPATH = `pwd`/golibs
27+
GOPATH = `pwd`/golibs:`go env GOPATH`
2828

2929
# Installation directories:
3030
prefix = /usr

debian/changelog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
zfswatcher (0.4.5-1) unstable; urgency=medium
2+
3+
* New version 0.4.5.
4+
* Contributions from slacker87:
5+
* Fixed regression bug with progress bars not showing up
6+
* Complete 45drives 45bay chassis enclosure page
7+
* Other tweaks
8+
* Contributions from kopernikus:
9+
* Implement os info stubs for Illumos/Solaris
10+
* Respect system GOPATH
11+
12+
-- Rouben <rouben@rouben.net> Wed, 21 Jun 2017 06:14:39 -0400
13+
114
zfswatcher (0.4.4-1) unstable; urgency=medium
215

316
* New version 0.4.4.

etc/zfswatcher.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ devstatecssclassmap = OFFLINE:text-warning REMOVED:text-error \
267267
; used space bar display. The pseudo severity "none" can be used to specify
268268
; the class when none of the usage levels specified in "usedspace" has
269269
; been reached.
270-
usedstatecssclassmap = none:bar-info info:bar-info notice:bar-warning \
271-
err:bar-warning crit:bar-danger
270+
usedstatecssclassmap = none:progress-bar-info info:progress-bar-info notice:progress-bar-warning \
271+
err:progress-bar-warning crit:progress-bar-danger
272272

273273
;
274274
; alternate root directory - formatted as /zfs

osutil_solaris.go

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,66 @@
2424
package main
2525

2626
import (
27+
"errors"
28+
"fmt"
29+
"os/exec"
30+
"strconv"
31+
"strings"
2732
"time"
2833
)
2934

3035
// Returns system uptime as time.Duration.
3136
func getSystemUptime() (uptime time.Duration, err error) {
32-
// XXX
33-
return 0, nil
37+
var (
38+
i int
39+
out []byte
40+
err1 error
41+
err2 error
42+
)
43+
44+
cmd := "kstat"
45+
args := []string{"-p", "unix:0:system_misc:snaptime"}
46+
if out, err1 = exec.Command(cmd, args...).Output(); err1 != nil {
47+
return 0, errors.New("Failed to run 'kstat'")
48+
}
49+
_s := string(out)
50+
parts := strings.Split(_s, "\t")
51+
_p1 := parts[1]
52+
_s = strings.Split(_p1, ".")[0]
53+
//fmt.Printf("Before the dot -> %s\n", _s)
54+
if i, err2 = strconv.Atoi(_s); err2 != nil {
55+
return 0, errors.New("Uptime was not an integer")
56+
}
57+
uptime = time.Duration(i) * time.Second
58+
return uptime, nil
3459
}
3560

3661
// Returns system load averages.
3762
func getSystemLoadaverage() ([3]float32, error) {
38-
// XXX
39-
return [3]float32{0, 0, 0}, nil
63+
var (
64+
out []byte
65+
err error
66+
ret [3]float32
67+
val float64
68+
)
69+
cmd := "uptime"
70+
if out, err = exec.Command(cmd).Output(); err != nil {
71+
return ret, errors.New("failed to run 'uptime'")
72+
}
73+
_s := string(out)
74+
parts := strings.Split(_s, " ")
75+
load := parts[len(parts)-3:]
76+
//fmt.Printf("load parts -> %s\n", load)
77+
for i, e := range load {
78+
e = strings.Replace(e, ",", "", 1)
79+
e = strings.Join(strings.Fields(e), "")
80+
if val, err = strconv.ParseFloat(e, 32); err != nil {
81+
return ret, errors.New(fmt.Sprintf("failed to convert load value '%s'", e))
82+
}
83+
ret[i] = float32(val)
84+
}
85+
return ret, nil
86+
//return [3]float32{0, 0, 0}, nil
4087
}
4188

4289
// Device lookup paths. (This list comes from lib/libzfs/libzfs_import.c)

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package main
22

3-
const VERSION = "0.4.4"
3+
const VERSION = "0.4.5"

webpagehandlers.go

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ package main
2323

2424
import (
2525
"fmt"
26+
"regexp"
2627
auth "github.com/abbot/go-http-auth"
2728
"github.com/damicon/zfswatcher/notifier"
2829
"html/template"
2930
"net/http"
3031
"sync"
3132
"time"
33+
"sort"
34+
"strings"
3235
)
3336

3437
var templates *template.Template
@@ -145,7 +148,8 @@ type enclosureWeb struct {
145148
Chassis45drives45l bool
146149
Chassis45drives45 bool
147150
Chassis45drives60 bool
148-
Pools []*chassisStatusWeb
151+
Drives1 []*devChassisStatusWeb
152+
Drives2 []*devChassisStatusWeb
149153
}
150154

151155
var (
@@ -246,7 +250,6 @@ func makeChassisStatusWeb(pool *PoolType) *chassisStatusWeb {
246250
devw := devChassisStatusWeb{
247251
Name: dev.name,
248252
State: dev.state,
249-
StateClass: cfg.Www.Devstatecssclassmap[dev.state],
250253
}
251254
devw.Indent = 1
252255
for d := n; pool.devs[d].parentDev != -1; d = pool.devs[d].parentDev {
@@ -450,20 +453,60 @@ func enclosureHandler(w http.ResponseWriter, r *auth.AuthenticatedRequest) {
450453
currentState.mutex.RUnlock()
451454

452455
var ws []*chassisStatusWeb
456+
var wsx []*devChassisStatusWeb
457+
var wsz []*devChassisStatusWeb
453458

454459
for n, s := range state {
455460
ws = append(ws, makeChassisStatusWeb(s))
456461
ws[n].N = n
457462
}
458463

464+
regx, _ := regexp.Compile("^1-.*")
465+
regy, _ := regexp.Compile("^2-.*")
466+
467+
for _, v := range ws {
468+
for _, x := range v.Devs {
469+
wsa := &devChassisStatusWeb{
470+
Name: x.Name,
471+
State: x.State,
472+
}
473+
if regx.MatchString(x.Name) {
474+
wsx = append(wsx, wsa)
475+
} else if regy.MatchString(x.Name) {
476+
wsz = append(wsz, wsa)
477+
}
478+
}
479+
}
480+
481+
sort.Slice(wsx, func(i, j int) bool {
482+
switch strings.Compare(wsx[i].Name[:1], wsx[j].Name[:1]) {
483+
case -1:
484+
return true
485+
case 1:
486+
return false
487+
}
488+
return wsx[i].State > wsx[j].State
489+
})
490+
491+
sort.Slice(wsz, func(i, j int) bool {
492+
switch strings.Compare(wsz[i].Name[:1], wsz[j].Name[:1]) {
493+
case -1:
494+
return true
495+
case 1:
496+
return false
497+
}
498+
return wsz[i].State > wsz[j].State
499+
})
500+
459501
ewd := &enclosureWeb{
460502
ChassisEnable: cfg.Chassis.Enable,
461503
Chassis45drives15: cfg.Chassis.Chassis45drives15,
462504
Chassis45drives30: cfg.Chassis.Chassis45drives30,
463505
Chassis45drives45l: cfg.Chassis.Chassis45drives45l,
464506
Chassis45drives45: cfg.Chassis.Chassis45drives45,
465507
Chassis45drives60: cfg.Chassis.Chassis45drives60,
466-
Pools: ws,
508+
Drives1: wsx,
509+
Drives2: wsz,
467510
}
468511

469512
err := templates.ExecuteTemplate(w, "enclosure.html", &webData{Nav: wn, Data: ewd})

www/resources/bootstrap/css/bootstrap-theme.min.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

www/resources/bootstrap/css/bootstrap.min.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
304 KB
Loading

www/resources/zfswatcher.css

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
body {
2+
background: transparent url("circles-and-roundabouts.png") repeat scroll 0% 0%;
3+
}
4+
15
.table-zfswatcher-dashboard th,
26
.table-zfswatcher-dashboard td {
37
vertical-align:middle;
@@ -7,3 +11,81 @@
711
margin-bottom: 0px;
812
min-width: 50px;
913
}
14+
15+
/* for enclosure drive status classes */
16+
.enclosure45table {
17+
border: 4px solid #3e3a3a;
18+
border-top: 30px solid #3e3a3a;
19+
border-bottom: 30vh solid #3e3a3a;
20+
background-color: #3e3a3a;
21+
border-collapse: separate !important;
22+
border-spacing: 7px;
23+
border-radius: 5px;
24+
-webkit-box-shadow: 1px 1px 2px 2px rgba(0,0,0,0.2);
25+
-moz-box-shadow: 1px 1px 2px 2px rgba(0,0,0,0.2);
26+
box-shadow: 1px 1px 2px 2px rgba(0,0,0,0.2);
27+
}
28+
29+
.enclosuretabletd {
30+
border: 3px solid #3e3a3a;
31+
text-align: center;
32+
padding-top: 5%;
33+
padding-bottom: 5%;
34+
min-width: 4vw;
35+
border-radius: 12px 12px 12px 12px;
36+
-moz-border-radius: 12px 12px 12px 12px;
37+
-webkit-border-radius: 12px 12px 12px 12px;
38+
-webkit-box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.2);
39+
-moz-box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.2);
40+
box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.2);
41+
}
42+
43+
.isONLINE {
44+
background-color: #148614;
45+
color: #d1d1d1;
46+
}
47+
48+
.isOFFLINE {
49+
background-color: : #2d2a2a;
50+
color: #d1d1d1;
51+
}
52+
53+
.isREMOVED {
54+
background-color: : #e69d17;
55+
color: #d1d1d1;
56+
}
57+
58+
.isFAULTED {
59+
background-color: : #e73737;
60+
color: #d1d1d1;
61+
}
62+
63+
.isSPLIT {
64+
background-color: : #e69d17;
65+
color: #d1d1d1;
66+
}
67+
68+
.isUNAVAIL {
69+
background-color: : #2d2a2a;
70+
color: #d1d1d1;
71+
}
72+
73+
.isDEGRADED {
74+
background-color: : #e69d17;
75+
color: #d1d1d1;
76+
}
77+
78+
.isUNKNOWN {
79+
background-color: : #656161;
80+
color: #d1d1d1;
81+
}
82+
83+
.isINUSE {
84+
background-color: : #e69d17;
85+
color: #d1d1d1;
86+
}
87+
88+
.isAVAIL {
89+
background-color: #1c691c;
90+
color: #d1d1d1;
91+
}

0 commit comments

Comments
 (0)