Skip to content

Commit

Permalink
fix percent calc failer
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Simon committed Oct 18, 2019
1 parent 308330c commit 2e8ecef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
5 changes: 0 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ push:
script:
- github-release release --user $GITHUB_REPO_OWNER --repo $GITHUB_REPO_NAME --tag $GITHUB_COMMIT_REF --name "Release 0.0.${CI_PIPELINE_IID}" --pre-release
- github-release upload --user $GITHUB_REPO_OWNER --repo $GITHUB_REPO_NAME --tag $GITHUB_COMMIT_REF --name "funk_metric_agent_LINUX_${CI_PIPELINE_IID}" --file bin/funk_metric_agent_LINUX_${CI_PIPELINE_IID}
# - touch bin/test123.txt
# - echo "hallo" > bin/test123.txt
# - ls -la bin
# - pwd
# - docker run --rm -e DRONE_BUILD_EVENT=tag -e DRONE_REPO_OWNER=fasibio -e DRONE_REPO_NAME=${CI_PROJECT_NAME} -e DRONE_COMMIT_REF=refs/heads/0.0.${CI_PIPELINE_IID} -e PLUGIN_API_KEY=${PLUGIN_API_KEY} -e PLUGIN_FILES="bin/*" -v $(pwd):$(pwd) -w $(pwd) plugins/github-release
stages:

# - test
Expand Down
18 changes: 10 additions & 8 deletions tracker/trackMetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ type CumulateMetrics struct {
}

type DiskInformation struct {
DiskName string `json:"disk_name,omitempty"`
MountPoint string `json:"mount_point,omitempty"`
DiskTotal uint64 `json:"disk_total,omitempty"`
DiskFree uint64 `json:"disk_free,omitempty"`
DiskUsed uint64 `json:"disk_used,omitempty"`
DiskUsedPercent float64 `json:"disk_used_percent,omitempty"`
DiskName string `json:"disk_name,omitempty"`
MountPoint string `json:"mount_point,omitempty"`
DiskTotal uint64 `json:"disk_total,omitempty"`
DiskFree uint64 `json:"disk_free,omitempty"`
DiskUsed uint64 `json:"disk_used,omitempty"`
DiskUsedPercent float64 `json:"disk_used_percent,omitempty"`
DiskAvailPercent float64 `json:"disk_avail_percent,omitempty"`
}

func GetDisksMetrics() ([]DiskInformation, error) {
Expand All @@ -46,7 +47,8 @@ func GetDisksMetrics() ([]DiskInformation, error) {
tmp.DiskTotal = diskuse.All
tmp.DiskFree = diskuse.Avail
tmp.DiskUsed = diskuse.Used
tmp.DiskUsedPercent = float64(diskuse.Avail) / float64(diskuse.All) * 100
tmp.DiskUsedPercent = float64(diskuse.Used) / float64(diskuse.All) * 100
tmp.DiskAvailPercent = float64(diskuse.Avail) / float64(diskuse.All) * 100
res = append(res, tmp)
}
}
Expand Down Expand Up @@ -82,7 +84,7 @@ func GetSystemMetrics() (CumulateMetrics, error) {
if err == nil {
res.CPUTotal = cpustats.Total
res.CPUUser = cpustats.User
res.CPUPercent = float64(cpustats.Total) / float64(cpustats.User) * 100
res.CPUPercent = float64(cpustats.User) / float64(cpustats.Total) * 100
} else {
logger.Get().Errorw("Error by reading cpu info: " + err.Error())
}
Expand Down

0 comments on commit 2e8ecef

Please sign in to comment.