Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement df handler #5

Merged
merged 1 commit into from
Nov 6, 2024
Merged

Implement df handler #5

merged 1 commit into from
Nov 6, 2024

Conversation

onee-only
Copy link
Contributor

Type of PR

Implemented /linux/df endpoint.

Description

Same as above. Closes #2

Comment on lines +26 to +33
func DfLinuxHandler(w http.ResponseWriter, r *http.Request) {
response, err := df.Df()
if err != nil {
http.Error(w, "Failed to retrieve disk info: "+err.Error(), http.StatusInternalServerError)
return
}
json.NewEncoder(w).Encode(response)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add this part to other handlers and commands? It seems that the error handling is not implemented for other handlers as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing you are talking about UptimeLinuxHandler.
IMO I think this PR should only contain the changes of df command.
So creating a new issue for this could be the good idea.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k

Comment on lines +36 to +41
fields := strings.Fields(line)
if fields[0] == "map" {
// Filesystem is "map auto_home"
fields[1] = "map " + fields[1]
fields = fields[1:]
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems too sporadic... There should typically be single spaces in filesystem names, so could we identify information from other categories by noticing that the spacing between characters is more than two?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the example below, you can see that the number of spaces between data of Used and Available is 1.
It means that there should be the case when there is a single space between Filesystem and 512-blocks.

Filesystem     512-blocks      Used Available Capacity iused      ifree %iused  Mounted on
/dev/disk3s1s1  478724992  20844296 225635920     9%  407401 1128179600    0%   /
devfs                 711       711         0   100%    1230          0  100%   /dev

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'll let it go as an occasional case.

Copy link
Owner

@esperar esperar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@esperar esperar merged commit fc53d75 into esperar:master Nov 6, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Command Linux df
2 participants