Skip to content

Commit

Permalink
Merge pull request #13 from rechecked/develop
Browse files Browse the repository at this point in the history
Fix issues with windows services. Update for version 1.0.2.
  • Loading branch information
jomann09 authored Mar 30, 2023
2 parents 46c89b7 + c03c9ec commit e0114cf
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
03/29/2023 - 1.0.2
==================
- Fixed issue with windows services not having proper status (#22)
- Fixed empty windows services JSON output to be [] instead of null

03/10/2023 - 1.0.1
==================
- Added Access-Control-Allow-Origin header for CORS requests
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.1
1.0.2
2 changes: 1 addition & 1 deletion internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func setupEndpoints() {
endpointFunc("memory/swap", status.HandleSwap)
endpointFunc("cpu/percent", status.HandleCPU)
endpointFunc("disk", status.HandleDisks)
//endpointFunc("docker", status.HandleDocker)
endpointFunc("services", status.HandleServices)
endpointFunc("processes", status.HandleProcesses)
endpointFunc("plugins", status.HandlePlugins)
Expand All @@ -85,6 +84,7 @@ func setupEndpoints() {
if runtime.GOOS != "windows" {
endpointFunc("load", status.HandleLoad)
endpointFunc("disk/inodes", status.HandleInodes)
//endpointFunc("docker", status.HandleDocker)
}

// Windows only
Expand Down
5 changes: 4 additions & 1 deletion internal/status/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import (
)

func HandleDocker(cv config.Values) interface{} {
dockerIds, _ := docker.GetDockerIDList()
dockerIds, err := docker.GetDockerIDList()
if err != nil {
return []string{}
}
return dockerIds
}
2 changes: 1 addition & 1 deletion internal/status/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (s Service) CheckValue() string {
func HandleServices(cv config.Values) interface{} {
svcs, err := getServices()
if err != nil {
return nil
return []string{}
}

// Filter services
Expand Down
17 changes: 15 additions & 2 deletions internal/status/services_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,28 @@ package status

import (
"github.com/shirou/gopsutil/v3/winservices"
"golang.org/x/sys/windows"
)

func getServices() ([]Service, error) {
var srvs []Service
services, err := winservices.ListServices()
for _, s := range services {
status := "stopped"
if s.Status.Pid > 0 {
status := "unknown"
// Need to create a new service before querying for status
service, err := winservices.NewService(s.Name)
if err != nil {
continue
}
qs, err := service.QueryStatus()
if err != nil {
continue
}
// Check status is running or not from returned ServiceStatus
if qs.State == windows.SERVICE_RUNNING {
status = "running"
} else if qs.State == windows.SERVICE_STOPPED {
status = "stopped"
}
srvs = append(srvs, Service{
Name: s.Name,
Expand Down
8 changes: 4 additions & 4 deletions versioninfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"FileVersion": {
"Major": 1,
"Minor": 0,
"Patch": 0,
"Patch": 2,
"Build": 0
},
"ProductVersion": {
"Major": 1,
"Minor": 0,
"Patch": 0,
"Patch": 2,
"Build": 0
},
"FileFlagsMask": "3f",
Expand All @@ -22,14 +22,14 @@
"Comments": "",
"CompanyName": "ReChecked",
"FileDescription": "ReChecked system status and monitoring agent.",
"FileVersion": "v1.0.0.0",
"FileVersion": "v1.0.2.0",
"InternalName": "rcagent.exe",
"LegalCopyright": "(c) 2023 ReChecked",
"LegalTrademarks": "",
"OriginalFilename": "",
"PrivateBuild": "",
"ProductName": "ReChecked Agent",
"ProductVersion": "v1.0.0.0",
"ProductVersion": "v1.0.2.0",
"SpecialBuild": ""
},
"VarFileInfo": {
Expand Down

0 comments on commit e0114cf

Please sign in to comment.