{"id":1881,"date":"2016-06-15T00:24:31","date_gmt":"2016-06-14T21:24:31","guid":{"rendered":"http:\/\/joseph.zikusooka.com\/?p=1881"},"modified":"2016-06-15T12:25:57","modified_gmt":"2016-06-15T09:25:57","slug":"receive-linux-server-alerts-phone-via-whatsapp","status":"publish","type":"post","link":"https:\/\/joseph.zikusooka.com\/?p=1881","title":{"rendered":"How to receive Linux server alerts on your phone via WhatsApp"},"content":{"rendered":"<p>In my <a href=\"http:\/\/joseph.zikusooka.com\/?p=1823\" target=\"_blank\">last<\/a> article, I wrote about how to receive Linux server alerts on your phone via telegram.  While telegram has a rich feature set, it is still not as popular as whatsapp at least in most regions.  Almost, everyone I know is using whatsapp. With the <a href=\"https:\/\/www.eff.org\/deeplinks\/2016\/04\/whatsapp-rolls-out-end-end-encryption-its-1bn-users\" target=\"_blank\">recent addition<\/a> of end-to-end ecryption, I&#8217;ve since relaxed my negative opinions of this service. Therefore, I decided to write a follow-up to my previous article, and show you how to get alerts from your Linux server via whatsapp. I will not delve into the setup of <a href=\"http:\/\/www.icinga.org\" target=\"_blank\">icinga2<\/a>, however, once you are able to send messages to whatsapp, things should be pretty much self explanatory.<\/p>\n<p>Thanks to Tarek Galal, who wrote a python library called <a href=\"https:\/\/github.com\/tgalal\/yowsup\" target=\"_blank\">yowsup<\/a> to interface with whatsapp API. <\/p>\n<p>First install it as follows:<\/p>\n<p><code>pip install yowsup2<\/code><\/p>\n<p><em>If installation fails, ensure that your have installed all the required dependencies on your Linux box which include python2.6+, python-dateutil, argparse,readline, pillow.  If you intend to use encryption, you will need to install protobuf, pycrypto, python-axolotl-curve25519<br \/>\n<\/em><\/p>\n<p>Yowsup comes with a command-line tool appropriately named; yowsup-cli.  For a full understanding of its usage, please visit the yowsup-cli <a href=\"https:\/\/github.com\/tgalal\/yowsup\/wiki\/yowsup-cli-2.0\" target=\"_blank\">wiki<\/a><\/p>\n<p><strong>Registration<\/strong><\/p>\n<p>As expected, you will need to register your phone.  This can be done simply as follows:<\/p>\n<p><code>yowsup-cli registration -d -E android -m 641 -n 10 -p 256XXXXXXXXX -C 256 -r sms<\/code><\/p>\n<p>The arguments explained:<br \/>\n<strong>-d<\/strong>   For debugging<br \/>\n<strong>-E<\/strong>  This is the environment.  Specifically set this to android.  The default will cause you to run into &#8216;no_route&#8217; errors.<br \/>\n<strong>-m<\/strong>  This is the MCC for your country. In my case 641 is for Uganda. Use the site: http:\/\/mcclist.com\/mobile-network-codes-country-codes.asp to locate yours<br \/>\n<strong>-n <\/strong> This is the MNC for your Telecom provider.  Again, use the site: http:\/\/mcclist.com\/mobile-network-codes-country-codes.asp to locate yours<br \/>\n<strong>-p <\/strong> This is your phone number.  Include the country code specified in next option -C<br \/>\n<strong>-C <\/strong>This is the country telephone code. In my case 256 is for Uganda.<br \/>\n<strong>-r <\/strong>(sms|voice) This is method by which pin code will be sent to you<\/p>\n<p>If execution of the above command is successful, you will receive, either a text message or voice call with the PIN code.  Use this code to complete the registration process as follows:<\/p>\n<p><code>yowsup-cli registration -d -E android -p 2567XXXXX -C 256 -R PIN-CODE<\/code><\/p>\n<p>The arguments are similar to above, except for:<br \/>\n<strong>&#8211; R<\/strong> which allows you to register using the provided PIN-CODE<\/p>\n<p>Once the command above has been executed successfully, the results displayed will look like the following<\/p>\n<p>kind: free<br \/>\npw: dfggHHSGGdIcdddRN567gjy=<br \/>\nprice: US$0.99<br \/>\nprice_expiration: 147567899<br \/>\ncurrency: USD<br \/>\ncost: 0.99<br \/>\nexpiration: 4444444444.0<br \/>\nlogin: 256XXXXXXXXXX<br \/>\ntype: new<\/p>\n<p>Take note of the 2 fields: <strong>pw<\/strong> and <strong>login<\/strong><\/p>\n<p><strong>Sending Messages<\/strong><\/p>\n<p>You should now be able to send messages using the command line.  Test sending as follows:<\/p>\n<p><code>yowsup-cli demos -d -l \"256XXXXXXXX:dfggHHSGGdIcdddRN567gjy=\" -s 256XXXXXXXXX \"This is a test \u2013 Hello World\"<\/code><\/p>\n<p>The arguments explained:<br \/>\n<strong>-d <\/strong> For debugging<br \/>\n<strong>-l  <\/strong> login.  Enter in format [login:password]<br \/>\n<strong>-s<\/strong>  The recipient&#8217;s phone number<\/p>\n<p>At this point your recipient should be able to receive your message.  <\/p>\n<p>For monitoring with icinga2, you will need to create a script using the above command for sending messages.  Make it executable and place it in location of your scripts.  From, here, setup of icinga2 is like any other as shown in my <a href=\"http:\/\/joseph.zikusooka.com\/?p=1823\" target=\"_blank\">previous<\/a> article.<\/p>\n<p>If you need more assistance or are interested in Linux and Open Source stuff, follow me <a href=\"https:\/\/twitter.com\/jzikusooka\" target=\"_blank\">@jzikusooka<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my last article, I wrote about how to receive Linux server alerts on your phone via telegram. While telegram has a rich feature set, it is still not as popular as whatsapp at least in most regions. Almost, everyone I know is using whatsapp. With the recent addition of end-to-end ecryption, I&#8217;ve since relaxed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"footnotes":""},"categories":[6,19],"tags":[],"class_list":["post-1881","post","type-post","status-publish","format-standard","hentry","category-apps","category-tutorial"],"_links":{"self":[{"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=\/wp\/v2\/posts\/1881","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1881"}],"version-history":[{"count":5,"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=\/wp\/v2\/posts\/1881\/revisions"}],"predecessor-version":[{"id":1886,"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=\/wp\/v2\/posts\/1881\/revisions\/1886"}],"wp:attachment":[{"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joseph.zikusooka.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}