{"id":72,"date":"2017-04-27T15:14:06","date_gmt":"2017-04-27T14:14:06","guid":{"rendered":"https:\/\/mindau.de\/blog\/?p=72"},"modified":"2019-01-21T22:49:51","modified_gmt":"2019-01-21T21:49:51","slug":"en-post-messages-slack-linux","status":"publish","type":"post","link":"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/","title":{"rendered":"[EN] Post messages to slack from linux"},"content":{"rendered":"<p>Firstly you need to create <strong>webhook url<\/strong> in slack. How to do it you can find at\u00a0<a href=\"https:\/\/www.programmableweb.com\/news\/how-to-integrate-webhooks-slack-api\/how-to\/2015\/10\/20\">https:\/\/www.programmableweb.com\/news\/how-to-integrate-webhooks-slack-api\/how-to\/2015\/10\/20<\/a><\/p>\n<p>Secondly you need for example a bash script. My version you can find\u00a0in gist:<\/p>\n<p><!--more--><\/p>\n<style>.gist table { margin-bottom: 0; }<\/style>\n<div style=\"tab-size: 8\" id=\"gist92225043\" class=\"gist\">\n<div class=\"gist-file\" translate=\"no\" data-color-mode=\"light\" data-light-theme=\"light\">\n<div class=\"gist-data\">\n<div class=\"js-gist-file-update-container js-task-list-container\">\n<div id=\"file-slackpost-sh\" class=\"file my-2\">\n<div itemprop=\"text\"\n      class=\"Box-body p-0 blob-wrapper data type-shell  \"\n      style=\"overflow: auto\" tabindex=\"0\" role=\"region\"\n      aria-label=\"slackpost.sh content, created by grambas on 07:45PM on October 01, 2018.\"\n    ><\/p>\n<div class=\"js-check-hidden-unicode js-blob-code-container blob-code-content\">\n<p>  <template class=\"js-file-alert-template\"><\/p>\n<div data-view-component=\"true\" class=\"flash flash-warn flash-full d-flex flex-items-center\">\n  <svg aria-hidden=\"true\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n    <span><br \/>\n      This file contains hidden or 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.<br \/>\n      <a class=\"Link--inTextBlock\" href=\"https:\/\/github.co\/hiddenchars\" target=\"_blank\">Learn more about bidirectional Unicode characters<\/a><br \/>\n    <\/span><\/p>\n<div data-view-component=\"true\" class=\"flash-action\">        <a href=\"{{ revealButtonHref }}\" data-view-component=\"true\" class=\"btn-sm btn\">    Show hidden characters<br \/>\n<\/a>\n<\/div>\n<\/div>\n<p><\/template><br \/>\n<template class=\"js-line-alert-template\"><br \/>\n  <span aria-label=\"This line has hidden Unicode characters\" data-view-component=\"true\" class=\"line-alert tooltipped tooltipped-e\"><br \/>\n    <svg aria-hidden=\"true\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n<\/span><\/template><\/p>\n<table data-hpc class=\"highlight tab-size js-file-line-container\" data-tab-size=\"4\" data-paste-markdown-skip data-tagsearch-path=\"slackpost.sh\">\n<tr>\n<td id=\"file-slackpost-sh-L1\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"1\"><\/td>\n<td id=\"file-slackpost-sh-LC1\" class=\"blob-code blob-code-inner js-file-line\">#!\/bin\/sh<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L2\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"2\"><\/td>\n<td id=\"file-slackpost-sh-LC2\" class=\"blob-code blob-code-inner js-file-line\"># Usage: date | sh slackpost.sh<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L3\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"3\"><\/td>\n<td id=\"file-slackpost-sh-LC3\" class=\"blob-code blob-code-inner js-file-line\"># Usage: echo &quot;Hello Word&quot; | sh slackpost.sh<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L4\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"4\"><\/td>\n<td id=\"file-slackpost-sh-LC4\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L5\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"5\"><\/td>\n<td id=\"file-slackpost-sh-LC5\" class=\"blob-code blob-code-inner js-file-line\">webhook_url=https:\/\/hooks.slack.com\/services\/&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L6\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"6\"><\/td>\n<td id=\"file-slackpost-sh-LC6\" class=\"blob-code blob-code-inner js-file-line\">username=&quot;PI&quot;         <\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L7\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"7\"><\/td>\n<td id=\"file-slackpost-sh-LC7\" class=\"blob-code blob-code-inner js-file-line\">channel=logs          <\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L8\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"8\"><\/td>\n<td id=\"file-slackpost-sh-LC8\" class=\"blob-code blob-code-inner js-file-line\">icon_emoji=&quot;:ghost:&quot;  # https:\/\/slackmojis.com\/<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L9\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"9\"><\/td>\n<td id=\"file-slackpost-sh-LC9\" class=\"blob-code blob-code-inner js-file-line\">#load all message to var<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L10\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"10\"><\/td>\n<td id=\"file-slackpost-sh-LC10\" class=\"blob-code blob-code-inner js-file-line\">while read LINE; do<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L11\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"11\"><\/td>\n<td id=\"file-slackpost-sh-LC11\" class=\"blob-code blob-code-inner js-file-line\">    text=&quot;$text\\n$LINE&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L12\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"12\"><\/td>\n<td id=\"file-slackpost-sh-LC12\" class=\"blob-code blob-code-inner js-file-line\">done<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L13\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"13\"><\/td>\n<td id=\"file-slackpost-sh-LC13\" class=\"blob-code blob-code-inner js-file-line\">#Default validation<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L14\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"14\"><\/td>\n<td id=\"file-slackpost-sh-LC14\" class=\"blob-code blob-code-inner js-file-line\">if [ &quot;$webhook_url&quot; = &quot;&quot; ]; then<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L15\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"15\"><\/td>\n<td id=\"file-slackpost-sh-LC15\" class=\"blob-code blob-code-inner js-file-line\">        echo &quot;No webhook_url specified&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L16\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"16\"><\/td>\n<td id=\"file-slackpost-sh-LC16\" class=\"blob-code blob-code-inner js-file-line\">        exit 1<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L17\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"17\"><\/td>\n<td id=\"file-slackpost-sh-LC17\" class=\"blob-code blob-code-inner js-file-line\">fi<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L18\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"18\"><\/td>\n<td id=\"file-slackpost-sh-LC18\" class=\"blob-code blob-code-inner js-file-line\">if [ &quot;$channel&quot; = &quot;&quot; ]; then<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L19\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"19\"><\/td>\n<td id=\"file-slackpost-sh-LC19\" class=\"blob-code blob-code-inner js-file-line\">        echo &quot;No channel specified&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L20\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"20\"><\/td>\n<td id=\"file-slackpost-sh-LC20\" class=\"blob-code blob-code-inner js-file-line\">        exit 1<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L21\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"21\"><\/td>\n<td id=\"file-slackpost-sh-LC21\" class=\"blob-code blob-code-inner js-file-line\">fi<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L22\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"22\"><\/td>\n<td id=\"file-slackpost-sh-LC22\" class=\"blob-code blob-code-inner js-file-line\">if [ &quot;$text&quot; = &quot;&quot; ]; then<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L23\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"23\"><\/td>\n<td id=\"file-slackpost-sh-LC23\" class=\"blob-code blob-code-inner js-file-line\">        echo &quot;No text specified&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L24\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"24\"><\/td>\n<td id=\"file-slackpost-sh-LC24\" class=\"blob-code blob-code-inner js-file-line\">        exit 1<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L25\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"25\"><\/td>\n<td id=\"file-slackpost-sh-LC25\" class=\"blob-code blob-code-inner js-file-line\">fi<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L26\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"26\"><\/td>\n<td id=\"file-slackpost-sh-LC26\" class=\"blob-code blob-code-inner js-file-line\">escapedText=$(echo $text | sed &#39;s\/&quot;\/\\&quot;\/g&#39; | sed &quot;s\/&#39;\/\\&#39;\/g&quot; )<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L27\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"27\"><\/td>\n<td id=\"file-slackpost-sh-LC27\" class=\"blob-code blob-code-inner js-file-line\">json=&quot;{\\&quot;channel\\&quot;: \\&quot;$channel\\&quot;,\\&quot;username\\&quot;: \\&quot;$username\\&quot;,\\&quot;icon_emoji\\&quot;: \\&quot;$icon_emoji\\&quot;,\\&quot;text\\&quot;: \\&quot;$escapedText\\&quot;}&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L28\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"28\"><\/td>\n<td id=\"file-slackpost-sh-LC28\" class=\"blob-code blob-code-inner js-file-line\">#by success returned &#39;ok&#39;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L29\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"29\"><\/td>\n<td id=\"file-slackpost-sh-LC29\" class=\"blob-code blob-code-inner js-file-line\">status=&quot;$(curl -s -d -X POST &#8211;silent &#8211;data-urlencode &quot;payload=$json&quot; &quot;$webhook_url&quot;)&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L30\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"30\"><\/td>\n<td id=\"file-slackpost-sh-LC30\" class=\"blob-code blob-code-inner js-file-line\">if [ &quot;$status&quot; != &quot;ok&quot; ]; then<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L31\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"31\"><\/td>\n<td id=\"file-slackpost-sh-LC31\" class=\"blob-code blob-code-inner js-file-line\">  # there were problems at curl request<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L32\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"32\"><\/td>\n<td id=\"file-slackpost-sh-LC32\" class=\"blob-code blob-code-inner js-file-line\">  # place to log error<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L33\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"33\"><\/td>\n<td id=\"file-slackpost-sh-LC33\" class=\"blob-code blob-code-inner js-file-line\">  echo &quot;curl error&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-slackpost-sh-L34\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"34\"><\/td>\n<td id=\"file-slackpost-sh-LC34\" class=\"blob-code blob-code-inner js-file-line\">fi<\/td>\n<\/tr>\n<\/table>\n<\/div><\/div>\n<\/p><\/div>\n<\/div><\/div>\n<div class=\"gist-meta\">\n        <a href=\"https:\/\/gist.github.com\/grambas\/67ef18335aa4fb8576bd9a89092b0a18\/raw\/0dd48d82bab260d8b75a284720762b8769db31e1\/slackpost.sh\" style=\"float:right\" class=\"Link--inTextBlock\">view raw<\/a><br \/>\n        <a href=\"https:\/\/gist.github.com\/grambas\/67ef18335aa4fb8576bd9a89092b0a18#file-slackpost-sh\" class=\"Link--inTextBlock\"><br \/>\n          slackpost.sh<br \/>\n        <\/a><br \/>\n        hosted with &#10084; by <a class=\"Link--inTextBlock\" href=\"https:\/\/github.com\">GitHub<\/a>\n      <\/div>\n<\/p><\/div>\n<\/div>\n<p>For comfort usage I\u00a0have copied it to bin folder<\/p>\n<pre class=\"lang:default decode:true\">cp \/current\/path\/to\/slackpost.sh \/usr\/local\/bin\/slackpost.sh\nchmod +x \/usr\/local\/bin\/slackpost.sh<\/pre>\n<p>Now you cant access \u00a0this script anywhere by typing :<\/p>\n<pre class=\"lang:default decode:true\">command_with_textual_output | slackpost.sh<\/pre>\n<p>Practically you can use it to get info about errors or notifications. Maybe you want to get notification about successfully database backup.<\/p>\n<pre class=\"lang:default decode:true\">#sh way\necho \"Your database backup was created successfully\" | slackpost.sh\n\n#python way\nos.system(\"echo 'Your database backup was created successfully' | slackpost.sh\")<\/pre>\n<p>Personaly I&#8217;m using it for notifying me if any of monitored website is offline &#8211;\u00a0<a href=\"https:\/\/mindau.de\/blog\/en\/simple-way-monitor-websites-linux\/\">https:\/\/mindau.de\/blog\/en\/simple-way-monitor-websites-linux\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Firstly you need to create webhook url in slack. How to do it you can find at\u00a0https:\/\/www.programmableweb.com\/news\/how-to-integrate-webhooks-slack-api\/how-to\/2015\/10\/20 Secondly you need for example a bash script. My version you can find\u00a0in gist:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"[EN] Post messages to slack from linux","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[5,11,14],"tags":[13,12],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[EN] Post messages to slack from linux - Mindau | Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[EN] Post messages to slack from linux - Mindau | Blog\" \/>\n<meta property=\"og:description\" content=\"Firstly you need to create webhook url in slack. How to do it you can find at\u00a0https:\/\/www.programmableweb.com\/news\/how-to-integrate-webhooks-slack-api\/how-to\/2015\/10\/20 Secondly you need for example a bash script. My version you can find\u00a0in gist:\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"Mindau | Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-04-27T14:14:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-01-21T21:49:51+00:00\" \/>\n<meta name=\"author\" content=\"Mindau\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@MindaugasMilius\" \/>\n<meta name=\"twitter:site\" content=\"@MindaugasMilius\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mindau\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/\"},\"author\":{\"name\":\"Mindau\",\"@id\":\"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998\"},\"headline\":\"[EN] Post messages to slack from linux\",\"datePublished\":\"2017-04-27T14:14:06+00:00\",\"dateModified\":\"2019-01-21T21:49:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/\"},\"wordCount\":120,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998\"},\"keywords\":[\"logging\",\"slack\"],\"articleSection\":[\"English\",\"Linux\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/\",\"url\":\"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/\",\"name\":\"[EN] Post messages to slack from linux - Mindau | Blog\",\"isPartOf\":{\"@id\":\"https:\/\/mindau.de\/blog\/#website\"},\"datePublished\":\"2017-04-27T14:14:06+00:00\",\"dateModified\":\"2019-01-21T21:49:51+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mindau.de\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[EN] Post messages to slack from linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mindau.de\/blog\/#website\",\"url\":\"https:\/\/mindau.de\/blog\/\",\"name\":\"Mindau | Blog\",\"description\":\"Mindaugas Milius\",\"publisher\":{\"@id\":\"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mindau.de\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998\",\"name\":\"Mindau\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mindau.de\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/mindau.de\/blog\/wp-content\/uploads\/2022\/02\/1639431846236.jpeg\",\"contentUrl\":\"https:\/\/mindau.de\/blog\/wp-content\/uploads\/2022\/02\/1639431846236.jpeg\",\"width\":250,\"height\":250,\"caption\":\"Mindau\"},\"logo\":{\"@id\":\"https:\/\/mindau.de\/blog\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/mindau.de\",\"https:\/\/www.linkedin.com\/in\/mindaugasmilius\/\",\"https:\/\/twitter.com\/MindaugasMilius\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[EN] Post messages to slack from linux - Mindau | Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/","og_locale":"en_US","og_type":"article","og_title":"[EN] Post messages to slack from linux - Mindau | Blog","og_description":"Firstly you need to create webhook url in slack. How to do it you can find at\u00a0https:\/\/www.programmableweb.com\/news\/how-to-integrate-webhooks-slack-api\/how-to\/2015\/10\/20 Secondly you need for example a bash script. My version you can find\u00a0in gist:","og_url":"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/","og_site_name":"Mindau | Blog","article_published_time":"2017-04-27T14:14:06+00:00","article_modified_time":"2019-01-21T21:49:51+00:00","author":"Mindau","twitter_card":"summary_large_image","twitter_creator":"@MindaugasMilius","twitter_site":"@MindaugasMilius","twitter_misc":{"Written by":"Mindau","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/#article","isPartOf":{"@id":"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/"},"author":{"name":"Mindau","@id":"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998"},"headline":"[EN] Post messages to slack from linux","datePublished":"2017-04-27T14:14:06+00:00","dateModified":"2019-01-21T21:49:51+00:00","mainEntityOfPage":{"@id":"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/"},"wordCount":120,"commentCount":1,"publisher":{"@id":"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998"},"keywords":["logging","slack"],"articleSection":["English","Linux","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/","url":"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/","name":"[EN] Post messages to slack from linux - Mindau | Blog","isPartOf":{"@id":"https:\/\/mindau.de\/blog\/#website"},"datePublished":"2017-04-27T14:14:06+00:00","dateModified":"2019-01-21T21:49:51+00:00","breadcrumb":{"@id":"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mindau.de\/blog\/"},{"@type":"ListItem","position":2,"name":"[EN] Post messages to slack from linux"}]},{"@type":"WebSite","@id":"https:\/\/mindau.de\/blog\/#website","url":"https:\/\/mindau.de\/blog\/","name":"Mindau | Blog","description":"Mindaugas Milius","publisher":{"@id":"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mindau.de\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998","name":"Mindau","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mindau.de\/blog\/#\/schema\/person\/image\/","url":"https:\/\/mindau.de\/blog\/wp-content\/uploads\/2022\/02\/1639431846236.jpeg","contentUrl":"https:\/\/mindau.de\/blog\/wp-content\/uploads\/2022\/02\/1639431846236.jpeg","width":250,"height":250,"caption":"Mindau"},"logo":{"@id":"https:\/\/mindau.de\/blog\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/mindau.de","https:\/\/www.linkedin.com\/in\/mindaugasmilius\/","https:\/\/twitter.com\/MindaugasMilius"]}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pcptsa-1a","jetpack-related-posts":[{"id":288,"url":"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/","url_meta":{"origin":72,"position":0},"title":"Auto webserver and database backup with GPG encryption to Amazon S3","date":"December 15, 2017","format":false,"excerpt":"In this tutorial I will show you step-by-step\u00a0 instructions how to make cheap and secure encrypted backups of you webserver (or any other dir)\u00a0 files on you linux\u00a0 server using Amazon Storage Service Create Bucket and User at Amazon AWS Some links that we will need Amazon Console link -\u2026","rel":"","context":"In &quot;English&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":93,"url":"https:\/\/mindau.de\/blog\/en\/send-notifications-linux-fail2ban-ssh-auth-actions-slack\/","url_meta":{"origin":72,"position":1},"title":"How to send notifications from Linux fail2ban, ssh auth and other actions to Slack","date":"April 27, 2017","format":false,"excerpt":"For this approach i will use my slackpost.sh script to send messages to Slack. More info about it you can find -\u00a0https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/ fail2ban How to install and configure fail2ban you can find for example here -\u00a0https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-protect-ssh-with-fail2ban-on-ubuntu-14-04 Now edit fail2ban jail.local file sudo nano \/etc\/fail2ban\/jail.local add \"slack\" hook where you want\u2026","rel":"","context":"In &quot;English&quot;","img":{"alt_text":"slack notification example","src":"https:\/\/i0.wp.com\/mindau.de\/blog\/wp-content\/uploads\/2017\/04\/slack_2017-04-27_19-02-45.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":82,"url":"https:\/\/mindau.de\/blog\/en\/simple-way-monitor-websites-linux\/","url_meta":{"origin":72,"position":2},"title":"[EN] Simple way to monitor websites in Linux with Slack","date":"April 27, 2017","format":false,"excerpt":"Mostly is very usefull to know if one or another website is down. Here is simple example to monitor your websites: https:\/\/gist.github.com\/6950da61b5ad31185931ddb2c0f9ecab#file-monitor-websites-sh sites.txt example website1.com website2.com Now you can add it to crontab. Type crontab -e and insert: # ping websites every minute * * * * * \/path\/to\/monitor-websites.sh >\u2026","rel":"","context":"In &quot;English&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":104,"url":"https:\/\/mindau.de\/blog\/en\/raspberry-pi-garden-assistant-project\/","url_meta":{"origin":72,"position":3},"title":"Raspberry Pi Garden Assistant Project","date":"May 31, 2017","format":false,"excerpt":"Project Plan and Goals The idea is to make smart garden house. Main tasks is to provide internet from mobile sim card to WiFi access point, automatizes mart watering and log some interesting data. This is my TO DO list. I will\u00a0continually update it by adding links to details. Internet\u2026","rel":"","context":"In &quot;English&quot;","img":{"alt_text":"Garden Project Scheme","src":"https:\/\/i0.wp.com\/mindau.de\/blog\/wp-content\/uploads\/2017\/05\/download.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":453,"url":"https:\/\/mindau.de\/blog\/en\/super-fast-and-easy-email-synchronization-with-imapsync-and-docker\/","url_meta":{"origin":72,"position":4},"title":"Super fast and easy email synchronization with imapsync and docker","date":"February 27, 2019","format":false,"excerpt":"If you need to migrate or transfer an email server to other provider, then you also need to export \/ import all your emails and folders. In that case you can struggle with many problems. For example: Different Email Clients with different export formatNo export or import function Costly import\u2026","rel":"","context":"In &quot;English&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mindau.de\/blog\/wp-content\/uploads\/2019\/02\/email-3249062_640.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":111,"url":"https:\/\/mindau.de\/blog\/en\/how-to-tutorials\/secure-nginx-configuration\/","url_meta":{"origin":72,"position":5},"title":"Secure Nginx configuration","date":"May 3, 2017","format":false,"excerpt":"After some research and digging, I made my nginx and domain configuration files. If I have something missed, you are welcome to write it in comment here or at Github. Mostly everything are commented so to understand code should be not problem. https:\/\/gist.github.com\/grambas\/a978ae5cdea456a5f8a55796a6cd6e7f#file-nginx-conf UPDATE: If you want more advanced solution,\u2026","rel":"","context":"In &quot;Linux&quot;","img":{"alt_text":"nginx secure configuration","src":"https:\/\/i0.wp.com\/mindau.de\/blog\/wp-content\/uploads\/2017\/05\/nginx-secure-configuration.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/posts\/72"}],"collection":[{"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/comments?post=72"}],"version-history":[{"count":12,"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/posts\/72\/revisions"}],"predecessor-version":[{"id":324,"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/posts\/72\/revisions\/324"}],"wp:attachment":[{"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/media?parent=72"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/categories?post=72"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/tags?post=72"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}