forked from kbudde/rabbitmq_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented flag for http checking health endpoint
- Loading branch information
Showing
4 changed files
with
32 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"os" | ||
"time" | ||
) | ||
|
||
// curl like check for an http url. | ||
// used inside docker image for checking health endpoint | ||
// will os.Exit(0) for http response code 200. Otherwise os.Exit(1) | ||
func curl(url string) { | ||
var client = &http.Client{Timeout: 30 * time.Second} | ||
resp, err := client.Get(url) | ||
if err != nil { | ||
fmt.Printf("Error checking url: %v\n", err) | ||
os.Exit(1) | ||
} | ||
if resp.StatusCode != http.StatusOK { | ||
fmt.Printf("Error checking url: Unexpected http code %v\n", resp.StatusCode) | ||
os.Exit(1) | ||
} | ||
os.Exit(0) | ||
} |
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