Skip to content

Commit

Permalink
osHealth/disk: add table to under limit message
Browse files Browse the repository at this point in the history
  • Loading branch information
kreatoo committed Aug 27, 2024
1 parent c65a24b commit de04628
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions osHealth/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func DiskUsage() {
common.SplitSection("Disk Usage")

var exceededParts [][]string
var allParts [][]string
diskPartitions, err := disk.Partitions(false)

if err != nil {
Expand All @@ -35,6 +36,7 @@ func DiskUsage() {
} else {
common.PrettyPrint("Disk usage at " + partition.Mountpoint, common.Green + " less than " + strconv.FormatFloat(OsHealthConfig.Part_use_limit, 'f', 0, 64) + "%", usage.UsedPercent, true, false)
}
allParts = append(allParts, []string{strconv.FormatFloat(usage.UsedPercent, 'f', 0, 64), common.ConvertBytes(usage.Used), common.ConvertBytes(usage.Total), partition.Device, partition.Mountpoint})
}

if len(exceededParts) > 0 {
Expand Down Expand Up @@ -67,9 +69,16 @@ func DiskUsage() {
common.AlarmCheckDown("disk", msg)

common.RedmineCreate("disk", common.Config.Identifier + " - Diskteki bir (ya da birden fazla) bölümün doluluk seviyesi %"+strconv.FormatFloat(OsHealthConfig.Part_use_limit, 'f', 0, 64)+" üstüne çıktı", output.String())
} else {
common.AlarmCheckUp("disk", "All partitions are now under the limit of " + strconv.FormatFloat(OsHealthConfig.Part_use_limit, 'f', 0, 64) + "%")
common.RedmineClose("disk", common.Config.Identifier + " - Bütün disk bölümleri "+strconv.FormatFloat(OsHealthConfig.Part_use_limit, 'f', 0, 64)+"% altına indi, kapatılıyor.")
} else {
output := &strings.Builder{}
table := tablewriter.NewWriter(output)
table.SetHeader([]string{"%", "Used", "Total", "Partition", "Mount Point"})
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
table.SetCenterSeparator("|")
table.AppendBulk(allParts)
table.Render()
common.AlarmCheckUp("disk", "All partitions are now under the limit of " + strconv.FormatFloat(OsHealthConfig.Part_use_limit, 'f', 0, 64) + "%" + "\n\n" + output.String())
common.RedmineClose("disk", common.Config.Identifier + " - Bütün disk bölümleri "+strconv.FormatFloat(OsHealthConfig.Part_use_limit, 'f', 0, 64)+"% altına indi, kapatılıyor." + "\n\n" + output.String())
}
}

Expand Down
2 changes: 1 addition & 1 deletion osHealth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type OsHealth struct {
var OsHealthConfig OsHealth

func Main(cmd *cobra.Command, args []string) {
version := "1.0.0"
version := "2.1.0"
common.ScriptName = "osHealth"
common.TmpDir = common.TmpDir + "osHealth"
common.Init()
Expand Down

0 comments on commit de04628

Please sign in to comment.