Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/slacker87'
Browse files Browse the repository at this point in the history
New release 0.4.5
  • Loading branch information
rouben committed Jun 21, 2017
2 parents b5d18bc + c1394f5 commit 26c3630
Show file tree
Hide file tree
Showing 15 changed files with 284 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SHELL = /bin/sh

# Go tool and library path:
GO = `which go`
GOPATH = `pwd`/golibs
GOPATH = `pwd`/golibs:`go env GOPATH`

# Installation directories:
prefix = /usr
Expand Down
13 changes: 13 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
zfswatcher (0.4.5-1) unstable; urgency=medium

* New version 0.4.5.
* Contributions from slacker87:
* Fixed regression bug with progress bars not showing up
* Complete 45drives 45bay chassis enclosure page
* Other tweaks
* Contributions from kopernikus:
* Implement os info stubs for Illumos/Solaris
* Respect system GOPATH

-- Rouben <[email protected]> Wed, 21 Jun 2017 06:14:39 -0400

zfswatcher (0.4.4-1) unstable; urgency=medium

* New version 0.4.4.
Expand Down
4 changes: 2 additions & 2 deletions etc/zfswatcher.conf
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ devstatecssclassmap = OFFLINE:text-warning REMOVED:text-error \
; used space bar display. The pseudo severity "none" can be used to specify
; the class when none of the usage levels specified in "usedspace" has
; been reached.
usedstatecssclassmap = none:bar-info info:bar-info notice:bar-warning \
err:bar-warning crit:bar-danger
usedstatecssclassmap = none:progress-bar-info info:progress-bar-info notice:progress-bar-warning \
err:progress-bar-warning crit:progress-bar-danger

;
; alternate root directory - formatted as /zfs
Expand Down
55 changes: 51 additions & 4 deletions osutil_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,66 @@
package main

import (
"errors"
"fmt"
"os/exec"
"strconv"
"strings"
"time"
)

// Returns system uptime as time.Duration.
func getSystemUptime() (uptime time.Duration, err error) {
// XXX
return 0, nil
var (
i int
out []byte
err1 error
err2 error
)

cmd := "kstat"
args := []string{"-p", "unix:0:system_misc:snaptime"}
if out, err1 = exec.Command(cmd, args...).Output(); err1 != nil {
return 0, errors.New("Failed to run 'kstat'")
}
_s := string(out)
parts := strings.Split(_s, "\t")
_p1 := parts[1]
_s = strings.Split(_p1, ".")[0]
//fmt.Printf("Before the dot -> %s\n", _s)
if i, err2 = strconv.Atoi(_s); err2 != nil {
return 0, errors.New("Uptime was not an integer")
}
uptime = time.Duration(i) * time.Second
return uptime, nil
}

// Returns system load averages.
func getSystemLoadaverage() ([3]float32, error) {
// XXX
return [3]float32{0, 0, 0}, nil
var (
out []byte
err error
ret [3]float32
val float64
)
cmd := "uptime"
if out, err = exec.Command(cmd).Output(); err != nil {
return ret, errors.New("failed to run 'uptime'")
}
_s := string(out)
parts := strings.Split(_s, " ")
load := parts[len(parts)-3:]
//fmt.Printf("load parts -> %s\n", load)
for i, e := range load {
e = strings.Replace(e, ",", "", 1)
e = strings.Join(strings.Fields(e), "")
if val, err = strconv.ParseFloat(e, 32); err != nil {
return ret, errors.New(fmt.Sprintf("failed to convert load value '%s'", e))
}
ret[i] = float32(val)
}
return ret, nil
//return [3]float32{0, 0, 0}, nil
}

// Device lookup paths. (This list comes from lib/libzfs/libzfs_import.c)
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

const VERSION = "0.4.4"
const VERSION = "0.4.5"
49 changes: 46 additions & 3 deletions webpagehandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ package main

import (
"fmt"
"regexp"
auth "github.com/abbot/go-http-auth"
"github.com/damicon/zfswatcher/notifier"
"html/template"
"net/http"
"sync"
"time"
"sort"
"strings"
)

var templates *template.Template
Expand Down Expand Up @@ -145,7 +148,8 @@ type enclosureWeb struct {
Chassis45drives45l bool
Chassis45drives45 bool
Chassis45drives60 bool
Pools []*chassisStatusWeb
Drives1 []*devChassisStatusWeb
Drives2 []*devChassisStatusWeb
}

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

var ws []*chassisStatusWeb
var wsx []*devChassisStatusWeb
var wsz []*devChassisStatusWeb

for n, s := range state {
ws = append(ws, makeChassisStatusWeb(s))
ws[n].N = n
}

regx, _ := regexp.Compile("^1-.*")
regy, _ := regexp.Compile("^2-.*")

for _, v := range ws {
for _, x := range v.Devs {
wsa := &devChassisStatusWeb{
Name: x.Name,
State: x.State,
}
if regx.MatchString(x.Name) {
wsx = append(wsx, wsa)
} else if regy.MatchString(x.Name) {
wsz = append(wsz, wsa)
}
}
}

sort.Slice(wsx, func(i, j int) bool {
switch strings.Compare(wsx[i].Name[:1], wsx[j].Name[:1]) {
case -1:
return true
case 1:
return false
}
return wsx[i].State > wsx[j].State
})

sort.Slice(wsz, func(i, j int) bool {
switch strings.Compare(wsz[i].Name[:1], wsz[j].Name[:1]) {
case -1:
return true
case 1:
return false
}
return wsz[i].State > wsz[j].State
})

ewd := &enclosureWeb{
ChassisEnable: cfg.Chassis.Enable,
Chassis45drives15: cfg.Chassis.Chassis45drives15,
Chassis45drives30: cfg.Chassis.Chassis45drives30,
Chassis45drives45l: cfg.Chassis.Chassis45drives45l,
Chassis45drives45: cfg.Chassis.Chassis45drives45,
Chassis45drives60: cfg.Chassis.Chassis45drives60,
Pools: ws,
Drives1: wsx,
Drives2: wsz,
}

err := templates.ExecuteTemplate(w, "enclosure.html", &webData{Nav: wn, Data: ewd})
Expand Down
1 change: 1 addition & 0 deletions www/resources/bootstrap/css/bootstrap-theme.min.css.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions www/resources/bootstrap/css/bootstrap.min.css.map

Large diffs are not rendered by default.

Binary file added www/resources/circles-and-roundabouts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions www/resources/zfswatcher.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
body {
background: transparent url("circles-and-roundabouts.png") repeat scroll 0% 0%;
}

.table-zfswatcher-dashboard th,
.table-zfswatcher-dashboard td {
vertical-align:middle;
Expand All @@ -7,3 +11,81 @@
margin-bottom: 0px;
min-width: 50px;
}

/* for enclosure drive status classes */
.enclosure45table {
border: 4px solid #3e3a3a;
border-top: 30px solid #3e3a3a;
border-bottom: 30vh solid #3e3a3a;
background-color: #3e3a3a;
border-collapse: separate !important;
border-spacing: 7px;
border-radius: 5px;
-webkit-box-shadow: 1px 1px 2px 2px rgba(0,0,0,0.2);
-moz-box-shadow: 1px 1px 2px 2px rgba(0,0,0,0.2);
box-shadow: 1px 1px 2px 2px rgba(0,0,0,0.2);
}

.enclosuretabletd {
border: 3px solid #3e3a3a;
text-align: center;
padding-top: 5%;
padding-bottom: 5%;
min-width: 4vw;
border-radius: 12px 12px 12px 12px;
-moz-border-radius: 12px 12px 12px 12px;
-webkit-border-radius: 12px 12px 12px 12px;
-webkit-box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.2);
-moz-box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.2);
box-shadow: 1px 1px 1px 1px rgba(0,0,0,0.2);
}

.isONLINE {
background-color: #148614;
color: #d1d1d1;
}

.isOFFLINE {
background-color: : #2d2a2a;
color: #d1d1d1;
}

.isREMOVED {
background-color: : #e69d17;
color: #d1d1d1;
}

.isFAULTED {
background-color: : #e73737;
color: #d1d1d1;
}

.isSPLIT {
background-color: : #e69d17;
color: #d1d1d1;
}

.isUNAVAIL {
background-color: : #2d2a2a;
color: #d1d1d1;
}

.isDEGRADED {
background-color: : #e69d17;
color: #d1d1d1;
}

.isUNKNOWN {
background-color: : #656161;
color: #d1d1d1;
}

.isINUSE {
background-color: : #e69d17;
color: #d1d1d1;
}

.isAVAIL {
background-color: #1c691c;
color: #d1d1d1;
}
4 changes: 2 additions & 2 deletions www/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<a href="{{ .Root }}/usage/{{ .Name }}">
<div class="progress progress-zfswatcher-dashboard">
{{ if or .UsedPercent .AvailPercent }}
<div class="bar {{ .UsedClass }}" style="width: {{ .UsedPercent }}%"></div>
<div class="bar bar-success" style="width: {{ .AvailPercent }}%"></div>
<div class="progress-bar {{ .UsedClass }}" style="width: {{ .UsedPercent }}%"></div>
<div class="progress-bar progress-bar-success" style="width: {{ .AvailPercent }}%"></div>
{{ end }}
</div>
</a>
Expand Down
Loading

0 comments on commit 26c3630

Please sign in to comment.