<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Arjun Komath</title>
    <description>The latest articles on Forem by Arjun Komath (@arjunkomath).</description>
    <link>https://forem.com/arjunkomath</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F269792%2F3cf33f35-f86a-4f6b-98a3-de47f01a5ccb.png</url>
      <title>Forem: Arjun Komath</title>
      <link>https://forem.com/arjunkomath</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/arjunkomath"/>
    <language>en</language>
    <item>
      <title>Free website monitoring with instant push notification alerts</title>
      <dc:creator>Arjun Komath</dc:creator>
      <pubDate>Tue, 11 Feb 2020 22:11:56 +0000</pubDate>
      <link>https://forem.com/arjunkomath/free-website-monitoring-with-instant-push-notification-alerts-374i</link>
      <guid>https://forem.com/arjunkomath/free-website-monitoring-with-instant-push-notification-alerts-374i</guid>
      <description>&lt;p&gt;In this article, I’ll help you set up a free and simple website monitoring tool which sends instant alerts using push notification. Before we begin, let’s have a look a what we will need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;a website URL to test, obviously&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;a computer/server to run our bash script&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;a free account at &lt;a href="https://push.techulus.com/"&gt;push.techulus.com&lt;/a&gt;, we will be using &lt;a href="https://push.techulus.com/"&gt;Push by Techulus&lt;/a&gt; for delivering real-time push notifications.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What is a website monitoring service? It’s simply a tool that lets us check if our website/server is live or not and also send us instant alerts the moment our website/server goes down. There are many SaaS platform which has several other advanced features, but in this tutorial, we will keep things simple.&lt;/p&gt;

&lt;p&gt;Before we start, make sure you’ve set up your account at &lt;a href="https://push.techulus.com/"&gt;push.techulus.com&lt;/a&gt;, installed the app on your device and copied the API key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JY4c7KE3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2292/1%2Agq6_oPAuLjnMe4Y8RJnDdA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JY4c7KE3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2292/1%2Agq6_oPAuLjnMe4Y8RJnDdA.png" alt="Get the API key from Push console"&gt;&lt;/a&gt;&lt;em&gt;Get the API key from Push console&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here is the bash script we will be using. You’ve to make two changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;change the website URL in the script to the one you want to monitor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update the file with API key from push.techulus.com&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!/bin/bash

# This script will check to see if a website is up/down by pinging the url
# your url 
url="http://blahblahblah.com"
# your api key from https://push.techulus.com/ 
push_api_key=""
# push settings 
sendNotification(){
 curl -X "POST" "https://push.techulus.com/api/v1/notify/${push_api_key}" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -d "{
 \"title\": \" $1 \",
 \"body\": \" $2 \"
}"
}
# check url 
wget --server-response --spider --tries=3 $url
# This wget will only return exit 0 if response is 200 ok
if [ "$?" -eq 0 ] # so if we have exit status of zero then server is UP
then
 exit 0
else
 echo "DOWN | `date`"
 sendNotification "$url is DOWN" "DOWN | `date`"
 exit 0
fi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;All you need to do is, download this script into your machine or server and keep running this script in a regular interval using something like cronjob and we’re done! That’s it! 🥳&lt;/p&gt;

&lt;p&gt;The script tries to load our website and if it fails (the server doesn’t respond with status code 200 OK), we assume that something has gone wrong and trigger a push notification.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--02_G1UiS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2484/1%2ArZIS2Lzr2qslmBnlXy0ubA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--02_G1UiS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2484/1%2ArZIS2Lzr2qslmBnlXy0ubA.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make sure you run this script frequently so that we can be alerted on time. To run this script every minute using &lt;em&gt;cronjob&lt;/em&gt;, we can add the following command to &lt;em&gt;crontab&lt;/em&gt;. Open crontab using the command&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;crontab -e
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and then add the following line:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* * * * * /bin/bash /path_to_your_file/script.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Make sure that you add the correct and absolute path to the script file on your machine/server.&lt;/p&gt;

&lt;p&gt;Feel free to modify the script, maybe change the message to make it more meaningful or more contextual. Before I wrap this up, huge shoutout to &lt;a href="https://gist.github.com/vbarrier/4d28d71ee8227d8a80cc6c1d57f46702"&gt;vbarrier&lt;/a&gt;. The bash script I’m using here is a modified version of &lt;a href="https://gist.github.com/vbarrier/4d28d71ee8227d8a80cc6c1d57f46702"&gt;his script&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Feel free to leave comments in case you have any questions.&lt;/p&gt;

&lt;p&gt;Thank you!&lt;/p&gt;

</description>
      <category>server</category>
      <category>uptime</category>
      <category>monitoring</category>
      <category>notification</category>
    </item>
    <item>
      <title>How to: Get push notifications from GitHub</title>
      <dc:creator>Arjun Komath</dc:creator>
      <pubDate>Tue, 12 Nov 2019 09:23:23 +0000</pubDate>
      <link>https://forem.com/arjunkomath/how-to-get-push-notifications-from-github-2bei</link>
      <guid>https://forem.com/arjunkomath/how-to-get-push-notifications-from-github-2bei</guid>
      <description>&lt;p&gt;If you’ve got a mobile phone, then you probably know what push notifications are. A &lt;a href="https://www.twilio.com/docs/glossary/what-is-push-notification"&gt;push notification&lt;/a&gt; (also known as a server push notification) is the delivery of information to a computing device from an application server where the request for the transaction is started by the server rather than by an explicit request from the client.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We will use Push (&lt;a href="https://push.techulus.com"&gt;push.techulus.com&lt;/a&gt;) as the medium for receiving push notifications.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this article, we’ll be discussing how we can get notifications from GitHub as push notifications on our device.&lt;/p&gt;

&lt;h1&gt;
  
  
  Let’s get started
&lt;/h1&gt;

&lt;p&gt;We will setup a real-time push notification workflow using &lt;a href="https://github.com/marketplace/actions/send-push-notification"&gt;GitHub actions&lt;/a&gt; (FYI, we could do the same using &lt;a href="https://zapier.com/platform/public-invite/7743/eacfd29c4087cb67e7798c9876698682/"&gt;Zapier integration&lt;/a&gt; also). Before we start, make sure you’ve setup your account at &lt;a href="https://push.techulus.com/"&gt;push.techulus.com&lt;/a&gt;, installed the app on your device and copied the API key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S_GedkQv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1573550060239/nBKysFjL6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S_GedkQv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1573550060239/nBKysFjL6.png" alt="1_aZajy6OtuvSyE26rZIFDLQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we have everything ready, let’s create our workflow on GitHub. We will create a workflow that sends a push notification whenever there is a new issue in our repository.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1.&lt;/strong&gt; Open your GitHub repository page (I will use this repository &lt;a href="https://github.com/arjunkomath/ama"&gt;https://github.com/arjunkomath/ama&lt;/a&gt;) and go to &lt;strong&gt;Actions&lt;/strong&gt; page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MI665vrn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1573550083777/7lEG7R6RK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MI665vrn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1573550083777/7lEG7R6RK.png" alt="1_91_bKN62hBMmZCgrarpjvw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt; To create a new workflow click on “New workflow” or “Set up a workflow yourself” button. Now GitHub will draft a new workflow for you with an &lt;code&gt;echo Hello, world!&lt;/code&gt; command. Let’s change this and add our custom action.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt; Rename the file to &lt;code&gt;issues_push.yml&lt;/code&gt; and then paste the following into your editor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Notify issues

on:
  issues:
    types: [opened]

jobs:
  push:

    runs-on: ubuntu-latest

    steps:
    - name: Send Push Notification
      uses: techulus/push-github-action@v0.0.2
      env:
        API_KEY: ${{ secrets.PUSH_API_KEY }}
        MESSAGE: "There is a new issue 😅"&amp;lt;/span&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let’s go through the lines one by one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The first line defines the &lt;code&gt;name&lt;/code&gt; of this workflow&lt;/li&gt;
&lt;li&gt;  The second line specify the trigger for this workflow, in our case it is when a new issue is opened&lt;/li&gt;
&lt;li&gt;  Next we have defined a job &lt;code&gt;push&lt;/code&gt; that runs on &lt;code&gt;ubuntu-latest&lt;/code&gt; , the &lt;a href="https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners"&gt;virtual environment&lt;/a&gt; in which our workflow commands will be executed.&lt;/li&gt;
&lt;li&gt;  Finally, we have the steps for the workflow which is to send the actual notification. We will use &lt;a href="https://github.com/marketplace/actions/send-push-notification"&gt;Send Push Notification&lt;/a&gt; action that has been published to GitHub marketplace.&lt;/li&gt;
&lt;li&gt;  Below that we’ve specified our &lt;code&gt;API_KEY&lt;/code&gt; as a secret and at last the message for our notification. We will see how to create a secret in a moment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Commit this file to master and we have created our workflow! 🎉&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4.&lt;/strong&gt; Before testing the notification we have to create a secret to store our &lt;code&gt;API_KEY&lt;/code&gt; . Open your repository settings and go to secrets tab and then click on &lt;strong&gt;Add a new secret.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XX0-xZbf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1573550109904/0B7o4bMPA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XX0-xZbf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1573550109904/0B7o4bMPA.png" alt="1_QxVgmlDA-jbRXKUQUBGXnw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter the name as &lt;code&gt;PUSH_API_KEY&lt;/code&gt; (we specified this in our workflow using &lt;code&gt;secrets.PUSH_API_KEY&lt;/code&gt; ) and enter the API key you copied from push console as the value. Click on &lt;strong&gt;Add secret&lt;/strong&gt; and we’re done!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z_EmqpWx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1573550196132/tEWuuw_iu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z_EmqpWx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1573550196132/tEWuuw_iu.png" alt="1_UhU2Zq1edR_oN9v_qTvhkA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Time to test our workflow, create a new issue in your repository and momentarily you should get the notification on your device.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mt3eEyGe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1573550236786/IJrHH0NXW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mt3eEyGe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1573550236786/IJrHH0NXW.png" alt="1_3t5btXWbEh385vAMps546Q.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can reuse the same action to implement different notifications based on different triggers. You can find more examples on the marketplace page &lt;a href="https://github.com/marketplace/actions/send-push-notification"&gt;https://github.com/marketplace/actions/send-push-notification&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Feel free to leave comments in case you have any questions.&lt;/p&gt;

&lt;p&gt;Thank you!&lt;/p&gt;

</description>
      <category>github</category>
      <category>actions</category>
      <category>push</category>
      <category>notifications</category>
    </item>
  </channel>
</rss>
