All Projects → atc0005 → send2teams

atc0005 / send2teams

Licence: MIT license
Small CLI tool used to submit messages to Microsoft Teams.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to send2teams

linux-teams
An unofficial Microsoft Teams application for Linux
Stars: ✭ 19 (+5.56%)
Mutual labels:  microsoft-teams
check clever tanken
Benzinpreis-Monitoring mit Icinga 2 || Kraftstoffmonitoring
Stars: ✭ 21 (+16.67%)
Mutual labels:  nagios
QuickTeams
Download, Clone, Archive, Un-Archive your Microsoft Teams and manage the apps you've installed to them
Stars: ✭ 31 (+72.22%)
Mutual labels:  microsoft-teams
MsftTeams
Module for Posting messages to MSTeams via Webhook
Stars: ✭ 35 (+94.44%)
Mutual labels:  microsoft-teams
interface
AngularJS based Web Interface for Statusengine
Stars: ✭ 15 (-16.67%)
Mutual labels:  nagios
sentry-msteams
Microsoft Teams Integration for Sentry
Stars: ✭ 27 (+50%)
Mutual labels:  microsoft-teams
Go Check Plugins
Check Plugins for monitoring written in golang
Stars: ✭ 225 (+1150%)
Mutual labels:  nagios
infrastructure
This repo contains all information about machine maintenance.
Stars: ✭ 75 (+316.67%)
Mutual labels:  nagios
msbotbuilder-go
Microsoft Bot Framework SDK for Go
Stars: ✭ 113 (+527.78%)
Mutual labels:  microsoft-teams
Microsoft365
Manage Microsoft 365 with PowerShell
Stars: ✭ 30 (+66.67%)
Mutual labels:  microsoft-teams
nagitheus
Nagios Check towards Prometheus
Stars: ✭ 19 (+5.56%)
Mutual labels:  nagios
List-Formatting
List Formatting Samples for use in SharePoint and Microsoft Lists
Stars: ✭ 1,227 (+6716.67%)
Mutual labels:  microsoft-teams
LXD-Cloud
Lightweight server management using LXD and Ansible
Stars: ✭ 19 (+5.56%)
Mutual labels:  nagios
nagmapReborn
Nagmap Reborn - Standalone integration with some server monitoring systems providing a user-friendly interface through geographic visualization.
Stars: ✭ 19 (+5.56%)
Mutual labels:  nagios
snmp notifier
A webhook to relay Prometheus alerts as SNMP traps, because sometimes, you have to deal with legacy
Stars: ✭ 33 (+83.33%)
Mutual labels:  nagios
check netscaler
A Nagios Plugin written in Perl for the Citrix ADC (formerly Citrix NetScaler). It uses the NetScaler NITRO API.
Stars: ✭ 36 (+100%)
Mutual labels:  nagios
nagios check
Ruby Nagios Check Integration
Stars: ✭ 13 (-27.78%)
Mutual labels:  nagios
check-ssl
Check the expiration date of your ssl-cert with bash (implemented for Nagios/Icinga)
Stars: ✭ 14 (-22.22%)
Mutual labels:  nagios
alignak
Monitoring tool, highly flexible and new standard oriented
Stars: ✭ 87 (+383.33%)
Mutual labels:  nagios
PSBlackListChecker
Basic functionality of this module is ability to quickly verify if given IP address is on any of over 80 defined DNSBL lists. Below code will return results only if IP is on any of the lists. Advanced functionality of this module is ability to send reports to your email when things get bad on one of those 80 defined DNSBL listrs.
Stars: ✭ 50 (+177.78%)
Mutual labels:  microsoft-teams

send2teams

Small CLI tool used to submit messages to Microsoft Teams.

Latest Release Go Reference Validate Codebase Validate Docs Lint and Build using Makefile Quick Validation

Table of contents

Project home

See our GitHub repo for the latest code, to file an issue or submit improvements for review and potential inclusion into the project.

Overview

First of all, many thanks to the developer/contributors of the original dasrick/go-teams-notify package. While this project now uses a fork of that original project, this project would likely not have been possible without the efforts of the original developer.

This project provides:

  • send2teams
    • Small CLI tool used to submit messages to Microsoft Teams. send2teams is intended for use by Nagios, scripts or other actions that may need to submit pass/fail results to a MS Teams channel.

Prior to v0.4.7, this project also provided a teams subpackage. All of that functionality has since been migrated to the atc0005/go-teams-notify project. All client code for that package has been updated to use atc0005/go-teams-notify in place of the previous teams subpackage of this project.

Features

  • single binary, no outside dependencies
  • minimal configuration
  • very few build dependencies
  • optional conversion of messages with Windows, Mac or Linux newlines to increase compatibility with Teams formatting
  • message delivery retry support with retry and retry delay values configurable via flag
  • support for user mentions
  • optional support for noting a sending application as the source of the message
  • optional support for specifying target url, description comma-separated pairs for use as labelled "buttons" within a Microsoft Teams message.
  • optional support for omitting the "branding" trailer from generated messages

Changelog

See the CHANGELOG.md file for the changes associated with each release of this application. Changes that have been merged to master, but not yet an official release may also be noted in the file under the Unreleased section. A helpful link to the Git commit history since the last official release is also provided for further review.

Requirements

The following is a loose guideline. Other combinations of Go and operating systems for building and running tools from this repo may work, but have not been tested.

Building source code

  • Go
    • see this project's go.mod file for preferred version
    • this project tests against officially supported Go releases
      • the most recent stable release (aka, "stable")
      • the prior, but still supported release (aka, "oldstable")
  • GCC
    • if building with custom options (as the provided Makefile does)
  • make
    • if using the provided Makefile

Running

  • Windows 10
  • Ubuntu Linux 18.04+

How to install it

From source

  1. Download Go
  2. Install Go
    • NOTE: Pay special attention to the remarks about $HOME/.profile
  3. Clone the repo
    1. cd /tmp
    2. git clone https://github.com/atc0005/send2teams
    3. cd send2teams
  4. Install dependencies (optional)
    • for Ubuntu Linux
      • sudo apt-get install make gcc
    • for CentOS Linux
      1. sudo yum install make gcc
  5. Build
    • for current operating system
      • go build -mod=vendor ./cmd/send2teams/
        • forces build to use bundled dependencies in top-level vendor folder
    • for all supported platforms (where make is installed)
      • make all
    • for Windows
      • make windows
    • for Linux
      • make linux
  6. Copy the applicable binary to whatever systems needs to run it
    • if using Makefile: look in /tmp/release_assets/send2teams/
    • if using go build: look in /tmp/send2teams/

Using release binaries

  1. Download the latest release binaries
  2. Deploy
    • Place send2teams in a location of your choice
      • e.g., /usr/local/bin/send2teams

Configuration Options

Webhook URLs

Expected format

Valid webhook URLs for Microsoft Teams use one of several (confirmed) FQDNs patterns:

  • outlook.office.com
  • outlook.office365.com
  • *.webhook.office.com
    • e.g., example.webhook.office.com

Using a webhook URL with any of these FQDN patterns appears to give identical results.

Here are complete, equivalent example webhook URLs from Microsoft's documentation using the FQDNs above:

All of these patterns should pass the default validation applied to user-specified webhook URLs.

How to create a webhook URL (Connector)

  1. Open Microsoft Teams
  2. Navigate to the channel where you wish to receive incoming messages from this application
  3. Select next to the channel name and then choose Connectors.
  4. Scroll through the list of Connectors to Incoming Webhook, and choose Add.
  5. Enter a name for the webhook, upload an image to associate with data from the webhook, and choose Create.
  6. Copy the webhook URL to the clipboard and save it. You'll need the webhook URL for sending information to Microsoft Teams.
    • NOTE: While you can create another easily enough, you should treat this webhook URL as sensitive information as anyone with this unique URL is able to send messages (without authentication) into the associated channel.
  7. Choose Done.

Credit: docs.microsoft.com, gist comment from shadabacc3934

Command-line

Currently send2teams only supports command-line configuration flags. Requests for other configuration sources will be considered.

Flag Required Default Possible Description
h, help No N/A N/A Display Help; show available flags.
v, version No false true, false Whether to display application version and then immediately exit application.
channel No unspecified valid Microsoft Teams channel name The target channel where we will send a message. If not specified, defaults to unspecified.
color No NotUsed N/A NOOP; this setting is no longer used. Values specified for this flag are ignored.
message Yes valid message string The (optionally) Markdown-formatted message to submit.
team No unspecified valid Microsoft Teams team name The name of the Team containing our target channel. If not specified, defaults to unspecified.
title No valid title string The (optional) title for the message to submit.
sender No valid application or script name The (optional) sending application name or generator of the message this app will attempt to deliver.
url Yes valid Microsoft Office 365 Webhook URL The Webhook URL provided by a pre-configured Connector.
target-url No valid comma-separated url, description pair The target URL and label (specified as comma separated pair) usually visible as a button towards the bottom of the Microsoft Teams message.
verbose No false true, false Whether detailed output should be shown after message submission success or failure
silent No false true, false Whether ANY output should be shown after message submission success or failure
convert-eol No false true, false Whether messages with Windows, Mac and Linux newlines are updated to use break statements before message submission
disable-url-validation No false true, false Whether webhook URL validation should be disabled. Useful when submitting generated JSON payloads to a service like https://httpbin.org/.
disable-branding-trailer No false true, false Whether the branding trailer should be omitted from all messages generated by this application.
ignore-invalid-response No false true, false Whether an invalid response from remote endpoint should be ignored. This is expected if submitting a message to a non-standard webhook URL.
retries No 2 positive whole number The number of attempts that this application will make to deliver messages before giving up.
retries-delay No 2 positive whole number The number of seconds that this application will wait before making another delivery attempt.
user-mention No one or more valid comma-separated name, id pairs The DisplayName and ID of the recipient (specified as comma separated pair) for a user mention. May be repeated to create multiple user mentions.

Limitations

message size

Per official documentation (see references), each message sent to Microsoft Teams can be approximately 28 KB. This includes the message itself (text, image links, etc.), @-mentions, and reactions.

Examples

One-off

This example illustrates the basics of using the application to submit a single message. This can serve as a starting point for use with Nagios, scripts or any other tool that calls out to others in order to perform its tasks.

The same example, shown split over multiple lines for readability (e.g., shell script):

./send2teams \
  --silent \
  --channel "Alerts" \
  --team "Support" \
  --message "System XYZ is down!" \
  --title "System outage alert" \
  --sender "Nagios" \
  --url "https://outlook.office.com/webhook/www@xxx/IncomingWebhook/yyy/zzz"

and on a single line (e.g., one-off via terminal or batch file):

./send2teams.exe --silent --channel "Alerts" --team "Support" --message "System XYZ is down!" --title "System outage alert" --sender "Nagios" --url "https://outlook.office.com/webhook/www@xxx/IncomingWebhook/yyy/zzz"

Note:

  • remove the -silent flag in order to see pass or failure output
  • use the -verbose flag to see the JSON payload submitted to Microsoft Teams
  • check the exit code ($?) to determine overall success/failure result

Using an invalid flag

Accidentally typing the wrong flag results in a message like this one:

flag provided but not defined: -fake-flag

Specifying url, description pairs

./send2teams \
  --silent \
  --channel "Alerts" \
  --team "Support" \
  --message "Useful starting points" \
  --title "Learn more about Go" \
  --sender "Nagios" \
  --url "https://outlook.office.com/webhook/www@xxx/IncomingWebhook/yyy/zzz" \
  --target-url "https://go.dev/, Go Homepage" \
  --target-url "https://github.com/dariubs/GoBooks, Awesome Go Books"

and on a single line (e.g., one-off via terminal or batch file):

./send2teams.exe --silent --channel "Alerts" --team "Support" --message "Useful starting points" --title "Learn more about Go" --sender "Nagios" --url "https://outlook.office.com/webhook/www@xxx/IncomingWebhook/yyy/zzz" --target-url "https://go.dev/, Go Homepage" --target-url "https://github.com/dariubs/GoBooks, Awesome Go Books"

User mentions

One mention

This example illustrates mentioning a user along with providing a brief message.

The example, shown split over multiple lines for readability (e.g., shell script):

./send2teams \
  --silent \
  --channel "Alerts" \
  --team "Support" \
  --message "System XYZ is down!" \
  --user-mention "John Doe,[email protected]" \
  --sender "Nagios" \
  --url "https://outlook.office.com/webhook/www@xxx/IncomingWebhook/yyy/zzz"

and on a single line (e.g., one-off via terminal or batch file):

./send2teams --silent --channel "Alerts" --team "Support" --message "System XYZ is down!" --user-mention "John Doe,[email protected]" --sender "Nagios" --url "https://outlook.office.com/webhook/www@xxx/IncomingWebhook/yyy/zzz"

Note:

  • remove the -silent flag in order to see pass or failure output
  • use the -verbose flag to see the JSON payload submitted to Microsoft Teams
  • check the exit code ($?) to determine overall success/failure result

Multiple mentions

This example illustrates mentioning multiple users along with providing a brief message. The --user-mention flag is repeated for each user mention.

Though valid syntax, repeating the same user mention does not increase the number of times the same user is notified of a user mention.

The example, shown split over multiple lines for readability (e.g., shell script):

./send2teams \
  --silent \
  --channel "Alerts" \
  --team "Support" \
  --message "System XYZ is down!" \
  --user-mention "John Doe,[email protected]" \
  --user-mention "Jane Doe,[email protected]" \
  --sender "Nagios" \
  --url "https://outlook.office.com/webhook/www@xxx/IncomingWebhook/yyy/zzz"

and on a single line (e.g., one-off via terminal or batch file):

./send2teams --silent --channel "Alerts" --team "Support" --message "System XYZ is down!" --user-mention "John Doe,[email protected]" --user-mention "Jane Doe,[email protected]" --sender "Nagios" --url "https://outlook.office.com/webhook/www@xxx/IncomingWebhook/yyy/zzz"

Note:

  • remove the -silent flag in order to see pass or failure output
  • use the -verbose flag to see the JSON payload submitted to Microsoft Teams
  • check the exit code ($?) to determine overall success/failure result

License

From the LICENSE file:

MIT License

Copyright 2021 Adam Chalkley

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].