fix: system_data als RawJSON durchreichen — Windows-Daten nicht mehr weggeworfen
This commit is contained in:
parent
e94fea3e91
commit
0e6154a0dd
@ -339,10 +339,15 @@ func (h *Handler) getAgent(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// system_data als Roh-JSON ausgeben (plattformunabhaengig)
|
||||
var rawSD interface{} = sysData
|
||||
if sysData != nil && len(sysData.RawJSON) > 0 {
|
||||
rawSD = json.RawMessage(sysData.RawJSON)
|
||||
}
|
||||
result := map[string]interface{}{
|
||||
"agent": agent,
|
||||
"status": models.CalculateAgentStatus(agent.LastHeartbeat),
|
||||
"system_data": sysData,
|
||||
"system_data": rawSD,
|
||||
}
|
||||
writeJSON(w, http.StatusOK, result)
|
||||
}
|
||||
|
||||
@ -634,7 +634,7 @@ func (d *Database) GetAgent(id string) (*models.Agent, *models.SystemData, error
|
||||
a.CustomerID = &cid
|
||||
}
|
||||
|
||||
// Systemdaten laden
|
||||
// Systemdaten laden (raw JSON — plattformunabhaengig)
|
||||
var dataJSON sql.NullString
|
||||
err = d.db.QueryRow("SELECT data_json FROM system_data WHERE agent_id = $1", id).Scan(&dataJSON)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
@ -642,11 +642,10 @@ func (d *Database) GetAgent(id string) (*models.Agent, *models.SystemData, error
|
||||
}
|
||||
|
||||
var sysData *models.SystemData
|
||||
if dataJSON.Valid {
|
||||
if dataJSON.Valid && dataJSON.String != "" {
|
||||
sysData = &models.SystemData{}
|
||||
if err := json.Unmarshal([]byte(dataJSON.String), sysData); err != nil {
|
||||
return &a, nil, nil
|
||||
}
|
||||
json.Unmarshal([]byte(dataJSON.String), sysData)
|
||||
sysData.RawJSON = json.RawMessage(dataJSON.String)
|
||||
}
|
||||
|
||||
return &a, sysData, nil
|
||||
|
||||
@ -31,6 +31,10 @@ type SystemData struct {
|
||||
PFStates *PFStatesInfo `json:"pf_states,omitempty"`
|
||||
HAProxy *HAProxyData `json:"haproxy,omitempty"`
|
||||
Caddy *CaddyData `json:"caddy,omitempty"`
|
||||
// Plattform-spezifische Rohdaten (Windows, Linux, etc.)
|
||||
Windows json.RawMessage `json:"windows,omitempty"`
|
||||
// RawJSON: vollstaendige Rohdaten aus DB (wird im API-Response verwendet)
|
||||
RawJSON json.RawMessage `json:"-"`
|
||||
}
|
||||
|
||||
type LicenseInfo struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user