Last active
August 19, 2017 20:38
-
-
Save fogonthedowns/7a6cb46bd7080630c49ee61811530bee to your computer and use it in GitHub Desktop.
Go Slack Webhook
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
// webhookUrl "https://hooks.slack.com/services/somehash/somehash/somehash" | |
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"os/exec" | |
"github.com/ashwanthkumar/slack-go-webhook" | |
) | |
func main() { | |
webhookUrl := os.Args[1] | |
out, err := exec.Command("nvidia-smi").Output() | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Printf("The date is %s\n", out) | |
s := fmt.Sprintf("nvidia-smi: ``` %s ```", out) | |
payload := slack.Payload { | |
Text: s, | |
Username: "ETH Miner", | |
Channel: "#ocarina", | |
IconEmoji: ":monkey_face:", | |
} | |
errors := slack.Send(webhookUrl, "", payload) | |
if len(errors) > 0 { | |
fmt.Printf("error: %s\n", errors) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
then add to crontab: