Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

fix 500 errors and updated to 7.x gluster release #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM debian:stretch
MAINTAINER Oliver Fesseler <[email protected]>
LABEL maintainer="[email protected]"

EXPOSE 9189
EXPOSE 24007
EXPOSE 24009-24108

RUN apt-get update && apt-get install -y apt-utils apt-transport-https ca-certificates gnupg2
# Gluster debian Repo
ADD http://download.gluster.org/pub/gluster/glusterfs/3.12/rsa.pub /tmp
ADD http://download.gluster.org/pub/gluster/glusterfs/7/rsa.pub /tmp
RUN apt-key add /tmp/rsa.pub && rm -f /tmp/rsa.pub

# Add gluster debian repo and update apt
RUN echo "deb https://download.gluster.org/pub/gluster/glusterfs/3.12/LATEST/Debian/stretch/amd64/apt stretch main" > /etc/apt/sources.list.d/gluster.list
RUN echo "deb https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/Debian/stretch/amd64/apt stretch main" > /etc/apt/sources.list.d/gluster.list
RUN apt-get update

# Install Gluster server
Expand Down
9 changes: 9 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gluster-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ VOLNAME="data"
# Start gluster manually (systemd is not running)
/usr/sbin/glusterd -p /var/run/glusterd.pid --log-level INFO &
# Wait to start configuring gluster
sleep 30
sleep 10
# Create a volume
gluster volume create "$VOLNAME" "$(hostname)":/"$VOLNAME" force
# Start Gluster volume
Expand Down
11 changes: 4 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,6 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric(
nodeSizeFreeBytes, prometheus.GaugeValue, float64(node.SizeFree), node.Hostname, node.Path, vol.VolName,
)
ch <- prometheus.MustNewConstMetric(
nodeInodesTotal, prometheus.CounterValue, float64(node.InodesTotal), node.Hostname, node.Path, vol.VolName,
)

ch <- prometheus.MustNewConstMetric(
nodeInodesFree, prometheus.GaugeValue, float64(node.InodesFree), node.Hostname, node.Path, vol.VolName,
)
}
}
vols := e.volumes
Expand Down Expand Up @@ -369,6 +362,10 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
}
} else {
for _, mount := range mounts {
if strings.HasPrefix(mount.mountPoint, "/var/lib/docker/plugins/") {
continue
}

ch <- prometheus.MustNewConstMetric(
mountSuccessful, prometheus.GaugeValue, float64(1), mount.volume, mount.mountPoint,
)
Expand Down
135 changes: 88 additions & 47 deletions structs/xmlStructs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,23 @@ type Volumes struct {

// Volume element of "gluster volume info" command
type Volume struct {
XMLName xml.Name `xml:"volume"`
Name string `xml:"name"`
ID string `xml:"id"`
Status int `xml:"status"`
StatusStr string `xml:"statusStr"`
BrickCount int `xml:"brickCount"`
Bricks []Brick `xml:"bricks"`
DistCount int `xml:"distCount"`
XMLName xml.Name `xml:"volume"`
Name string `xml:"name"`
ID string `xml:"id"`
Status int `xml:"status"`
StatusStr string `xml:"statusStr"`
BrickCount int `xml:"brickCount"`
Bricks []Brick `xml:"bricks"`
DistCount int `xml:"distCount"`
SnapshotCount int `xml:"snapshotCount"`
StripeCount int `xml:"stripeCount"`
ReplicaCount int `xml:"replicaCount"`
ArbiterCount int `xml:"arbiterCount"`
DisperseCount int `xml:"disperseCount"`
RedundancyCount int `xml:"redundancyCount"`
Type int `xml:"type"`
TypeStr string `xml:"typeStr"`
Transport int `xml:"transport"`
}

// Brick element of "gluster volume info" command
Expand Down Expand Up @@ -108,6 +117,7 @@ type VolumeProfileXML struct {
// VolProfile element of "gluster volume {volume} profile" command
type VolProfile struct {
Volname string `xml:"volname"`
ProfileOp int `xml:"profileOp"`
BrickCount int `xml:"brickCount"`
Brick []BrickProfile `xml:"brick"`
}
Expand All @@ -121,10 +131,11 @@ type BrickProfile struct {

// CumulativeStats element of "gluster volume {volume} profile" command
type CumulativeStats struct {
FopStats FopStats `xml:"fopStats"`
Duration int `xml:"duration"`
TotalRead int `xml:"totalRead"`
TotalWrite int `xml:"totalWrite"`
BlockStats BlockStats `xml:"blockStats"`
FopStats FopStats `xml:"fopStats"`
Duration int `xml:"duration"`
TotalRead int `xml:"totalRead"`
TotalWrite int `xml:"totalWrite"`
}

// FopStats element of "gluster volume {volume} profile" command
Expand All @@ -141,9 +152,22 @@ type Fop struct {
MaxLatency float64 `xml:"maxLatency"`
}

// BlockStats element of "gluster volume {volume} profile" command
type BlockStats struct {
Block []Block `xml:"block"`
}

// Block is struct for BlockStats
type Block struct {
Size int `xml:"size"`
Reads int `xml:"reads"`
Writes int `xml:"writes"`
}

// HealInfoBrick is a struct of HealInfoBricks
type HealInfoBrick struct {
XMLName xml.Name `xml:"brick"`
HostUUID string `xml:"hostUuid,attr"`
Name string `xml:"name"`
Status string `xml:"status"`
NumberOfEntries string `xml:"numberOfEntries"`
Expand Down Expand Up @@ -233,42 +257,59 @@ func VolumeProfileGvInfoCumulativeXMLUnmarshall(cmdOutBuff io.Reader) (VolumePro
return vol, err
}

// VolumeStatusXML XML type of "gluster volume status"
// VolumeStatusXML XML type of "gluster volume status detail"
type VolumeStatusXML struct {
XMLName xml.Name `xml:"cliOutput"`
OpRet int `xml:"opRet"`
OpErrno int `xml:"opErrno"`
OpErrstr string `xml:"opErrstr"`
VolStatus struct {
Volumes struct {
Volume []struct {
VolName string `xml:"volName"`
NodeCount int `xml:"nodeCount"`
Node []struct {
Hostname string `xml:"hostname"`
Path string `xml:"path"`
PeerID string `xml:"peerid"`
Status int `xml:"status"`
Port int `xml:"port"`
Ports struct {
TCP int `xml:"tcp"`
RDMA string `xml:"rdma"`
} `xml:"ports"`
Pid int `xml:"pid"`
SizeTotal uint64 `xml:"sizeTotal"`
SizeFree uint64 `xml:"sizeFree"`
Device string `xml:"device"`
BlockSize int `xml:"blockSize"`
MntOptions string `xml:"mntOptions"`
FsName string `xml:"fsName"`
// As of Gluster3.12 this shows filesystem type. Bug?
//InodeSize uint64 `xml:"inodeSize"`
InodesTotal uint64 `xml:"inodesTotal"`
InodesFree uint64 `xml:"inodesFree"`
} `xml:"node"`
} `xml:"volume"`
} `xml:"volumes"`
} `xml:"volStatus"`
XMLName xml.Name `xml:"cliOutput"`
OpRet int `xml:"opRet"`
OpErrno int `xml:"opErrno"`
OpErrstr string `xml:"opErrstr"`
VolStatus VolStatus `xml:"volStatus"`
}

// VolStatus XML type of "gluster volume status detail"
type VolStatus struct {
XMLName xml.Name `xml:"volStatus"`
Volumes VolumesXML `xml:"volumes"`
}

// VolumesXML type of "gluster volume status detail"
type VolumesXML struct {
XMLName xml.Name `xml:"volumes"`
Volume []VolumeXML `xml:"volume"`
}

// VolumeXML type of "gluster volume status detail"
type VolumeXML struct {
VolName string `xml:"volName"`
NodeCount int `xml:"nodeCount"`
Node []Node `xml:"node"`
}

// Node XML type of "gluster volume status detail"
type Node struct {
Hostname string `xml:"hostname"`
Path string `xml:"path"`
PeerID string `xml:"peerid"`
Status int `xml:"status"`
Port int `xml:"port"`
Ports Ports `xml:"ports"`
Pid int `xml:"pid"`
SizeTotal uint64 `xml:"sizeTotal"`
SizeFree uint64 `xml:"sizeFree"`
Device string `xml:"device"`
BlockSize int `xml:"blockSize"`
MntOptions string `xml:"mntOptions"`
FsName string `xml:"fsName"`
// As of Gluster3.12 this shows filesystem type. Bug?
//InodeSize uint64 `xml:"inodeSize"`
InodesTotal uint64 `xml:"inodesTotal"`
InodesFree uint64 `xml:"inodesFree"`
}

// Ports XML type of "gluster volume status detail"
type Ports struct {
TCP int `xml:"tcp"`
RDMA string `xml:"rdma"`
}

// VolumeStatusAllDetailXMLUnmarshall reads bytes.buffer and returns unmarshalled xml
Expand Down