mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
chore: Add hostname to server monitor report
This commit adds the hostname field to the server monitor report in order to include the hostname of the server in the collected metrics. This information is useful for identifying and distinguishing between different servers in the monitoring system.
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
|
||||
The OneUptime Infrastructure Agent is a lightweight, open-source agent that collects system metrics and sends them to the OneUptime platform. It is designed to be easy to install and use, and to be extensible.
|
||||
|
||||
## Installation
|
||||
### Installation
|
||||
|
||||
```
|
||||
curl -s https://oneuptime.com/docs/static/scripts/infrastructure-agent/install.sh | bash
|
||||
```
|
||||
|
||||
## Configure the agent
|
||||
### Configure the agent
|
||||
|
||||
Configure the agent as a system service
|
||||
- You can change the host to your own host if you're self hosting the OneUptime platform.
|
||||
@@ -18,7 +18,7 @@ Configure the agent as a system service
|
||||
oneuptime-infrastructure-agent configure --secret-key=YOUR_SECRET_KEY --oneuptime-url=https://oneuptime.com
|
||||
```
|
||||
|
||||
## Starting the agent
|
||||
### Starting the agent
|
||||
|
||||
```
|
||||
oneuptime-infrastructure-agent start
|
||||
@@ -26,26 +26,48 @@ oneuptime-infrastructure-agent start
|
||||
|
||||
Once its up and running you should see the metrics on the OneUptime Dashboard.
|
||||
|
||||
## Stopping the agent
|
||||
### Stopping the agent
|
||||
|
||||
```
|
||||
oneuptime-infrastructure-agent stop
|
||||
```
|
||||
|
||||
## Restarting the agent
|
||||
### Restarting the agent
|
||||
|
||||
```
|
||||
oneuptime-infrastructure-agent restart
|
||||
```
|
||||
|
||||
## Uninstalling the agent
|
||||
### Uninstalling the agent
|
||||
|
||||
```
|
||||
oneuptime-infrastructure-agent uninstall && rm -rf /usr/bin/oneuptime-infrastructure-agent
|
||||
```
|
||||
|
||||
## Supported Platforms
|
||||
### Supported Platforms
|
||||
|
||||
- Linux
|
||||
- MacOS
|
||||
- Windows
|
||||
- Windows
|
||||
|
||||
## Development
|
||||
|
||||
This section is for developers who want to contribute to the agent. The agent is written in Go.
|
||||
|
||||
### Building the agent
|
||||
|
||||
```bash
|
||||
go build
|
||||
```
|
||||
|
||||
### Configure the agent
|
||||
|
||||
```bash
|
||||
sudo ./oneuptime-infrastructure-agent configure --secret-key=YOUR_SECRET_KEY --oneuptime-url=https://localhost
|
||||
```
|
||||
|
||||
### Starting the agent
|
||||
|
||||
```bash
|
||||
sudo ./oneuptime-infrastructure-agent start
|
||||
```
|
||||
@@ -110,6 +110,7 @@ func collectMetricsJob(secretKey string, oneuptimeURL string) {
|
||||
RequestReceivedAt: time.Now().UTC().Format("2006-01-02T15:04:05.000Z"),
|
||||
OnlyCheckRequestReceivedAt: false,
|
||||
Processes: servProcesses,
|
||||
Hostname: utils.GetHostname(),
|
||||
}
|
||||
|
||||
reqData := struct {
|
||||
|
||||
@@ -6,4 +6,5 @@ type ServerMonitorReport struct {
|
||||
RequestReceivedAt string `json:"requestReceivedAt"`
|
||||
OnlyCheckRequestReceivedAt bool `json:"onlyCheckRequestReceivedAt"`
|
||||
Processes []*ServerProcess `json:"processes"`
|
||||
Hostname string `json:"hostname"`
|
||||
}
|
||||
|
||||
16
InfrastructureAgent/utils/hostname.go
Normal file
16
InfrastructureAgent/utils/hostname.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"os"
|
||||
)
|
||||
|
||||
func GetHostname() string {
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
slog.Error("Failed to fetch hostname", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
return hostname
|
||||
}
|
||||
Reference in New Issue
Block a user