Skip to content

Commit

Permalink
Merge branch 'dn2_super' into unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnewhall committed Oct 16, 2024
2 parents afd6b1b + 7e5f467 commit 7a53b9e
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pkg/apps/apppkg/plex/plex.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (s *Server) reqPlexURL(
}

if resp.StatusCode != http.StatusOK {
return body, ErrBadStatus
return body, fmt.Errorf("%w: %s", ErrBadStatus, resp.Status)
}

return body, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindata/files/js/golists.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function testInstance(from, instanceType, index)
toast('Web Server Error',
'Notifiarr client appears to be down! Hard refresh recommended.', 'error', 30000);
} else {
toast(instanceType+' Check Error', error+': '+response.responseText, 'error', 15000);
toast(instanceType+' Check Error', response.responseText, 'error', 15000);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindata/templates/snapshot/mysql.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h3><i class="fas fa-comment text-orange"></i> MySQL Notes</h3>
<li><i class="fas fa-star"></i> You may add MySQL credentials to your Notifiarr client configuration to snapshot MySQL service health.</li>
<li><i class="fas fa-star"></i> This feature snapshots <code>SHOW PROCESSLIST</code> and <code>SHOW STATUS</code> data.</li>
<li><i class="fas fa-star"></i>Access to a database is not required. Example Grant: <code>GRANT PROCESS ON *.* to 'notifiarr'@'localhost'</code></li>
<li><i class="fas fa-star"></i> Access to a database is not required. Example Grant: <code>GRANT PROCESS ON *.* to 'notifiarr'@'localhost'</code></li>
</p>
<div class="table-responsive">
<table class="table bk-dark table-bordered">
Expand Down
7 changes: 6 additions & 1 deletion pkg/bindata/templates/snapshot/nvidia.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<div class="table-responsive">
</p>
<h3><i class="fas fa-comment text-orange"></i> Nvidia Notes</h3>
<li><i class="fas fa-star"></i> This integration displays Nvidia CUDA info in Snapshot notifications.</li>
<li><i class="fas fa-star"></i> To use this feature in Docker, you must use the CUDA image: <code>ghcr.io/notifiarr/notifiarr:cuda</code></li>
</p>
<div class="table-responsive">
<table class="table bk-dark table-bordered">
<thead>
<tr>
Expand Down
18 changes: 9 additions & 9 deletions pkg/checkapp/downloaders.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
func testQbit(ctx context.Context, config *apps.QbitConfig) (string, int) {
qbit, err := qbit.New(ctx, config.Config)
if err != nil {
return connecting + err.Error(), http.StatusBadGateway
return connecting + err.Error(), http.StatusBadRequest
}

xfers, err := qbit.GetXfersContext(ctx)
if err != nil {
return "Getting Transfers: " + err.Error(), http.StatusBadGateway
return "Getting Transfers: " + err.Error(), http.StatusBadRequest
}

return fmt.Sprintf("Connection Successful! %d Transfers", len(xfers)), http.StatusOK
Expand All @@ -34,7 +34,7 @@ func testRtorrent(_ context.Context, config *apps.RtorrentConfig) (string, int)

result, err := config.Client.Call("system.hostname")
if err != nil {
return "Getting Server Name: " + err.Error(), http.StatusBadGateway
return "Getting Server Name: " + err.Error(), http.StatusFailedDependency
}

if names, ok := result.([]any); ok {
Expand All @@ -45,15 +45,15 @@ func testRtorrent(_ context.Context, config *apps.RtorrentConfig) (string, int)
return "Connection Successful! Server name: " + name, http.StatusOK
}

return "Getting Server Name: result was not a string?", http.StatusBadGateway
return "Getting Server Name: result was not a string?", http.StatusFailedDependency
}

func testSabNZB(ctx context.Context, app *apps.SabNZBConfig) (string, int) {
app.Setup(0, nil)

sab, err := app.GetQueue(ctx)
if err != nil {
return "Getting Queue: " + err.Error(), http.StatusBadGateway
return "Getting Queue: " + err.Error(), http.StatusFailedDependency
}

return success + sab.Version, http.StatusOK
Expand All @@ -62,7 +62,7 @@ func testSabNZB(ctx context.Context, app *apps.SabNZBConfig) (string, int) {
func testNZBGet(ctx context.Context, config *apps.NZBGetConfig) (string, int) {
ver, err := nzbget.New(config.Config).VersionContext(ctx)
if err != nil {
return "Getting Version: " + err.Error(), http.StatusBadGateway
return "Getting Version: " + err.Error(), http.StatusFailedDependency
}

return fmt.Sprintf("%s%s", success, ver), http.StatusOK
Expand All @@ -71,7 +71,7 @@ func testNZBGet(ctx context.Context, config *apps.NZBGetConfig) (string, int) {
func testDeluge(ctx context.Context, config *apps.DelugeConfig) (string, int) {
deluge, err := deluge.New(ctx, config.Config)
if err != nil {
return connecting + err.Error(), http.StatusBadGateway
return connecting + err.Error(), http.StatusFailedDependency
}

return fmt.Sprintf("%s%s", success, deluge.Version), http.StatusOK
Expand All @@ -80,7 +80,7 @@ func testDeluge(ctx context.Context, config *apps.DelugeConfig) (string, int) {
func testTransmission(ctx context.Context, config *apps.XmissionConfig) (string, int) {
endpoint, err := url.Parse(config.URL)
if err != nil {
return "parsing url: " + err.Error(), http.StatusBadGateway
return "parsing url: " + err.Error(), http.StatusFailedDependency
} else if config.User != "" {
endpoint.User = url.UserPassword(config.User, config.Pass)
}
Expand All @@ -91,7 +91,7 @@ func testTransmission(ctx context.Context, config *apps.XmissionConfig) (string,

args, err := client.SessionArgumentsGetAll(ctx)
if err != nil {
return "Getting Server Version: " + err.Error(), http.StatusBadGateway
return "Getting Server Version: " + err.Error(), http.StatusFailedDependency
}

return "Transmission Server version: " + *args.Version, http.StatusOK
Expand Down
4 changes: 2 additions & 2 deletions pkg/checkapp/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func testPlex(ctx context.Context, app *apps.PlexConfig) (string, int) {

info, err := app.GetInfo(ctx)
if err != nil {
return "Getting Info: " + err.Error(), http.StatusBadGateway
return "Getting Info: " + err.Error(), http.StatusFailedDependency
}

return "Plex OK! Version: " + info.Version, http.StatusOK
Expand All @@ -24,7 +24,7 @@ func testTautulli(ctx context.Context, app *apps.TautulliConfig) (string, int) {

users, err := app.GetUsers(ctx)
if err != nil {
return "Getting Users: " + err.Error(), http.StatusBadGateway
return "Getting Users: " + err.Error(), http.StatusFailedDependency
}

return fmt.Sprintf("Tautulli OK! Users: %d", len(users.Response.Data)), http.StatusOK
Expand Down
8 changes: 4 additions & 4 deletions pkg/checkapp/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func testTCP(ctx context.Context, svc *services.Service) (string, int) {

res := svc.CheckOnly(ctx)
if res.State != services.StateOK {
return res.State.String() + " " + res.Output.String(), http.StatusBadGateway
return res.State.String() + " " + res.Output.String(), http.StatusFailedDependency
}

return "TCP Port is OPEN and reachable: " + res.Output.String(), http.StatusOK
Expand All @@ -27,7 +27,7 @@ func testHTTP(ctx context.Context, svc *services.Service) (string, int) {

res := svc.CheckOnly(ctx)
if res.State != services.StateOK {
return res.State.String() + " " + res.Output.String(), http.StatusBadGateway
return res.State.String() + " " + res.Output.String(), http.StatusFailedDependency
}

// add test
Expand All @@ -41,7 +41,7 @@ func testProcess(ctx context.Context, svc *services.Service) (string, int) {

res := svc.CheckOnly(ctx)
if res.State != services.StateOK {
return res.State.String() + " " + res.Output.String(), http.StatusBadGateway
return res.State.String() + " " + res.Output.String(), http.StatusFailedDependency
}

return "Process Tested OK: " + res.Output.String(), http.StatusOK
Expand All @@ -54,7 +54,7 @@ func testPing(ctx context.Context, svc *services.Service) (string, int) {

res := svc.CheckOnly(ctx)
if res.State != services.StateOK {
return res.State.String() + " " + res.Output.String(), http.StatusBadGateway
return res.State.String() + " " + res.Output.String(), http.StatusFailedDependency
}

return "Ping Tested OK: " + res.Output.String(), http.StatusOK
Expand Down
2 changes: 1 addition & 1 deletion pkg/checkapp/snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func testNvidia(ctx context.Context, config *snapshot.NvidiaConfig) (string, int
config.Disabled = false

if err := snaptest.GetNvidia(ctx, config); err != nil {
return err.Error(), http.StatusBadGateway
return err.Error(), http.StatusFailedDependency
}

msg := fmt.Sprintf("SMI found %d Graphics Adapter", len(snaptest.Nvidia))
Expand Down
10 changes: 5 additions & 5 deletions pkg/checkapp/starr.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func testLidarr(ctx context.Context, config *apps.LidarrConfig) (string, int) {
status, err := lidarr.New(config.Config).GetSystemStatusContext(ctx)
if err != nil {
return connecting + err.Error(), http.StatusBadGateway
return connecting + err.Error(), http.StatusFailedDependency
}

return success + status.Version, http.StatusOK
Expand All @@ -24,7 +24,7 @@ func testLidarr(ctx context.Context, config *apps.LidarrConfig) (string, int) {
func testProwlarr(ctx context.Context, config *apps.ProwlarrConfig) (string, int) {
status, err := prowlarr.New(config.Config).GetSystemStatusContext(ctx)
if err != nil {
return connecting + err.Error(), http.StatusBadGateway
return connecting + err.Error(), http.StatusFailedDependency
}

return success + status.Version, http.StatusOK
Expand All @@ -33,7 +33,7 @@ func testProwlarr(ctx context.Context, config *apps.ProwlarrConfig) (string, int
func testRadarr(ctx context.Context, config *apps.RadarrConfig) (string, int) {
status, err := radarr.New(config.Config).GetSystemStatusContext(ctx)
if err != nil {
return connecting + err.Error(), http.StatusBadGateway
return connecting + err.Error(), http.StatusFailedDependency
}

return success + status.Version, http.StatusOK
Expand All @@ -42,7 +42,7 @@ func testRadarr(ctx context.Context, config *apps.RadarrConfig) (string, int) {
func testReadarr(ctx context.Context, config *apps.ReadarrConfig) (string, int) {
status, err := readarr.New(config.Config).GetSystemStatusContext(ctx)
if err != nil {
return connecting + err.Error(), http.StatusBadGateway
return connecting + err.Error(), http.StatusFailedDependency
}

return success + status.Version, http.StatusOK
Expand All @@ -51,7 +51,7 @@ func testReadarr(ctx context.Context, config *apps.ReadarrConfig) (string, int)
func testSonarr(ctx context.Context, config *apps.SonarrConfig) (string, int) {
status, err := sonarr.New(config.Config).GetSystemStatusContext(ctx)
if err != nil {
return connecting + err.Error(), http.StatusBadGateway
return connecting + err.Error(), http.StatusFailedDependency
}

return success + status.Version, http.StatusOK
Expand Down
1 change: 1 addition & 0 deletions pkg/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ func (c *Config) runServiceChecker() { //nolint:cyclop
case event := <-c.checkChan:
c.Printf("Running service check '%s' via event: %s, buffer: %d/%d",
event.Service.Name, event.Source, len(c.checks), cap(c.checks))

if c.runCheck(event.Service, true, time.Now()) {
c.SendResults(&Results{What: event.Source, Svcs: c.GetResults()})
}
Expand Down

0 comments on commit 7a53b9e

Please sign in to comment.