Skip to content

Commit 9b87a6c

Browse files
committed
feat(redmine): use display URL instead of API URL in notifications
1 parent cce6720 commit 9b87a6c

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

common/config.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ type Common struct {
3232
Priority_id int
3333
Interval float64
3434

35-
Api_key string
36-
Url string
35+
Api_key string
36+
Url string
37+
Display_url string
3738
}
3839
}
3940

@@ -113,6 +114,13 @@ func ConfInit(configName string, config interface{}) interface{} {
113114
return config
114115
}
115116

117+
func GetRedmineDisplayUrl() string {
118+
if Config.Redmine.Display_url != "" {
119+
return Config.Redmine.Display_url
120+
}
121+
return strings.Replace(Config.Redmine.Url, "://api.", "://", 1)
122+
}
123+
116124
// expandEnvInMap recursively expands environment variables in nested map structures
117125
func expandEnvInMap(data map[string]interface{}) {
118126
for key, value := range data {

osHealth/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func collectHealthData(version string) *HealthData {
147147
issues.CheckDown("zfsdataset", subject, tableOnly, false, 0)
148148
id := issues.Show("zfsdataset")
149149
if id != "" {
150-
fullMsg = fullMsg + "\n\n" + "Redmine Issue: " + common.Config.Redmine.Url + "/issues/" + id
150+
fullMsg = fullMsg + "\n\n" + "Redmine Issue: " + common.GetRedmineDisplayUrl() + "/issues/" + id
151151
common.AlarmCheckUp("zfsdataset_redmineissue", "Redmine issue exists for ZFS dataset usage", false)
152152
} else {
153153
log.Debug().Msg("osHealth/main.go: issues.Show(\"zfsdataset\") returned empty. Proceeding without Redmine link in alarm.")
@@ -199,7 +199,7 @@ func collectDiskInfo() []DiskInfo {
199199
id := issues.Show("disk")
200200

201201
if id != "" {
202-
fullMsg = fullMsg + "\n\n" + "Redmine Issue: " + common.Config.Redmine.Url + "/issues/" + id
202+
fullMsg = fullMsg + "\n\n" + "Redmine Issue: " + common.GetRedmineDisplayUrl() + "/issues/" + id
203203
common.AlarmCheckUp("disk_redmineissue", "Redmine issue exists for disk usage", false)
204204
} else {
205205
log.Debug().Msg("osHealth/main.go: issues.Show(\"disk\") returned empty. Proceeding without Redmine link in alarm.")

osHealth/zfs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ func ZFSHealth() []ZFSPoolInfo {
358358
common.AlarmCheckDown("zfs_health", message, false, "", "")
359359
} else {
360360
common.AlarmCheckUp("zfs_health_redmineissue", "Redmine issue has been created for ZFS health", false)
361-
message = message + "\n\n" + "Redmine Issue: " + common.Config.Redmine.Url + "/issues/" + id
361+
message = message + "\n\n" + "Redmine Issue: " + common.GetRedmineDisplayUrl() + "/issues/" + id
362362
common.AlarmCheckDown("zfs_health", message, false, "", "")
363363
}
364364
}

tmp/mono/winHealth/monokit.lock

Whitespace-only changes.

winHealth/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func collectDiskInfo() []DiskInfo {
225225
id := issues.Show("disk")
226226

227227
if id != "" {
228-
fullMsg = fullMsg + "\n\n" + "Redmine Issue: " + common.Config.Redmine.Url + "/issues/" + id
228+
fullMsg = fullMsg + "\n\n" + "Redmine Issue: " + common.GetRedmineDisplayUrl() + "/issues/" + id
229229
common.AlarmCheckUp("disk_redmineissue", "Redmine issue exists for disk usage", false)
230230
} else {
231231
log.Debug().Msg("osHealth/main.go: issues.Show(\"disk\") returned empty. Proceeding without Redmine link in alarm.")

0 commit comments

Comments
 (0)