This repository has been archived by the owner on May 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c14767
commit 70078fb
Showing
12 changed files
with
226 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package ohgi | ||
|
||
import ( | ||
"strconv" | ||
"strings" | ||
|
||
"../sensu" | ||
) | ||
|
||
func GetResults(api *sensu.API) string { | ||
var line string | ||
|
||
results, err := api.GetResults() | ||
checkError(err) | ||
|
||
if len(results) == 0 { | ||
return "No current check results\n" | ||
} | ||
|
||
print := []byte(bold(" CLIENT CHECK EXECUTED\n")) | ||
for _, result := range results { | ||
line = indicateStatus(result.Check.Status) + fillSpace(result.Client, 40) + fillSpace(result.Check.Name, 30) + utoa(result.Check.Executed) + "\n" | ||
print = append(print, line...) | ||
} | ||
|
||
return string(print) | ||
} | ||
|
||
func GetResultsClient(api *sensu.API, client string) string { | ||
var line, output string | ||
|
||
results, err := api.GetResultsClient(client) | ||
checkError(err) | ||
|
||
if len(results) == 0 { | ||
return "No current check results for " + client + "\n" | ||
} | ||
|
||
print := []byte(bold(" CHECK OUTPUT EXECUTED\n")) | ||
for _, result := range results { | ||
output = strings.Replace(result.Check.Output, "\n", " ", -1) | ||
line = indicateStatus(result.Check.Status) + fillSpace(result.Check.Name, 30) + fillSpace(output, 50) + utoa(result.Check.Executed) + "\n" | ||
print = append(print, line...) | ||
} | ||
|
||
return string(print) | ||
} | ||
|
||
func GetResultsClientCheck(api *sensu.API, client string, check string) string { | ||
var print []byte | ||
|
||
result, err := api.GetResultsClientCheck(client, check) | ||
checkError(err) | ||
|
||
print = append(print, (bold("CLIENT ") + result.Client + "\n")...) | ||
print = append(print, (bold("CHECK ") + result.Check.Name + "\n")...) | ||
print = append(print, (bold("COMMAND ") + result.Check.Command + "\n")...) | ||
print = append(print, (bold("SUBSCRIBERS ") + strings.Join(result.Check.Subscribers, ", ") + "\n")...) | ||
print = append(print, (bold("INTERVAL ") + strconv.Itoa(result.Check.Interval) + "\n")...) | ||
print = append(print, (bold("HANDLERS ") + strings.Join(result.Check.Handlers, ", ") + "\n")...) | ||
print = append(print, (bold("ISSUED ") + utoa(result.Check.Issued) + "\n")...) | ||
print = append(print, (bold("EXECUTED ") + utoa(result.Check.Executed) + "\n")...) | ||
print = append(print, (bold("OUTPUT ") + strings.Replace(result.Check.Output, "\n", " ", -1) + "\n")...) | ||
print = append(print, (bold("STATUS ") + paintStatus(result.Check.Status) + "\n")...) | ||
print = append(print, (bold("DURATION ") + strconv.FormatFloat(result.Check.Duration, 'f', 3, 64) + "\n")...) | ||
|
||
return string(print) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.