Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nodemonitor
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
nodemonitor
Commits
edd362af
Commit
edd362af
authored
Nov 24, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update server format
parent
55dd59a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
15 deletions
+32
-15
main.go
server/main.go
+32
-15
No files found.
server/main.go
View file @
edd362af
...
...
@@ -75,6 +75,7 @@ func (s *Server) handleNodes(w http.ResponseWriter, r *http.Request) {
.offline { background-color: #ffebee; }
.online { background-color: #e8f5e8; }
.disk-item { margin-bottom: 5px; }
.high { color: #c62828; font-weight: 700; } /* red bold for >90% */
</style>
</head>
<body>
...
...
@@ -99,7 +100,7 @@ func (s *Server) handleNodes(w http.ResponseWriter, r *http.Request) {
<td>{{.Status}}</td>
<td>{{.Height}}</td>
<td>{{printf "%.2f" .CPUUsage}}</td>
<td>
{{printf "%.2f" .MemoryUsage}}
</td>
<td>
<span class="{{.MemoryUsageClass}}">{{.MemoryUsageFormatted}}</span>
</td>
<td>{{.MemoryInfo}}</td>
<td>{{.AllDisksInfo}}</td>
<td>{{.PrivateIP}}</td>
...
...
@@ -114,11 +115,13 @@ func (s *Server) handleNodes(w http.ResponseWriter, r *http.Request) {
type
NodeView
struct
{
*
types
.
NodeStatus
Status
string
StatusClass
string
MemoryInfo
string
AllDisksInfo
template
.
HTML
LastReport
string
Status
string
StatusClass
string
MemoryInfo
string
AllDisksInfo
template
.
HTML
LastReport
string
MemoryUsageClass
string
MemoryUsageFormatted
string
}
nodeViews
:=
make
([]
NodeView
,
len
(
nodes
))
...
...
@@ -131,15 +134,19 @@ func (s *Server) handleNodes(w http.ResponseWriter, r *http.Request) {
statusClass
=
"offline"
}
// Format all disk information
// Format all disk information
and highlight usage > 90%
var
allDisksInfo
string
if
len
(
node
.
DiskInfos
)
>
0
{
for
_
,
diskInfo
:=
range
node
.
DiskInfos
{
mountPoint
:=
diskInfo
.
Path
usage
:=
diskInfo
.
UsedPercent
allDisksInfo
+=
fmt
.
Sprintf
(
"<div class='disk-item'><strong>%s:</strong> %.2f%% (%.2f GB / %.2f GB)</div>"
,
usageStr
:=
fmt
.
Sprintf
(
"%.2f%%"
,
usage
)
if
usage
>=
90.0
{
usageStr
=
fmt
.
Sprintf
(
"<span class='high'>%.2f%%</span>"
,
usage
)
}
allDisksInfo
+=
fmt
.
Sprintf
(
"<div class='disk-item'><strong>%s:</strong> %s (%.2f GB / %.2f GB)</div>"
,
mountPoint
,
usage
,
usage
Str
,
float64
(
diskInfo
.
Free
)
/
(
1024
*
1024
*
1024
),
float64
(
diskInfo
.
Total
)
/
(
1024
*
1024
*
1024
))
}
...
...
@@ -147,13 +154,23 @@ func (s *Server) handleNodes(w http.ResponseWriter, r *http.Request) {
allDisksInfo
=
"No disk information available"
}
// Memory usage highlight (red & bold if >= 90%)
memUsage
:=
node
.
MemoryUsage
memUsageClass
:=
""
if
memUsage
>=
90.0
{
memUsageClass
=
"high"
}
memUsageFormatted
:=
fmt
.
Sprintf
(
"%.2f%%"
,
memUsage
)
nodeViews
[
i
]
=
NodeView
{
NodeStatus
:
node
,
Status
:
status
,
StatusClass
:
statusClass
,
MemoryInfo
:
fmt
.
Sprintf
(
"%.2f GB / %.2f GB"
,
float64
(
node
.
MemoryFree
)
/
(
1024
*
1024
*
1024
),
float64
(
node
.
MemoryTotal
)
/
(
1024
*
1024
*
1024
)),
AllDisksInfo
:
template
.
HTML
(
allDisksInfo
),
LastReport
:
node
.
Timestamp
.
Format
(
"2006-01-02 15:04:05"
),
NodeStatus
:
node
,
Status
:
status
,
StatusClass
:
statusClass
,
MemoryInfo
:
fmt
.
Sprintf
(
"%.2f GB / %.2f GB"
,
float64
(
node
.
MemoryFree
)
/
(
1024
*
1024
*
1024
),
float64
(
node
.
MemoryTotal
)
/
(
1024
*
1024
*
1024
)),
AllDisksInfo
:
template
.
HTML
(
allDisksInfo
),
LastReport
:
node
.
Timestamp
.
Format
(
"2006-01-02 15:04:05"
),
MemoryUsageClass
:
memUsageClass
,
MemoryUsageFormatted
:
memUsageFormatted
,
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment