My static website generator using poole https://www.xythobuz.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ultimatenotifier.html 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Ultimate Notifier Script (#) xythobuz.de</title>
  6. <meta name="description" content="Sending Push Notifications to an iPhone from a Bash Script" />
  7. <meta name="keywords" content="xythobuz" />
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  9. <link rel="author" href="/xythobuz@xythobuz.de">
  10. <link rel="shortcut icon" href="/img/favicon.ico">
  11. <link rel="alternate" type="application/rss+xml" title="Blog" href="/rss.xml">
  12. <link type="text/css" rel="stylesheet" href="/css/sh_bright.min.css" />
  13. <link rel="stylesheet" href="/css/bootstrap.css" type="text/css" media="screen" />
  14. <link rel="stylesheet" href="/css/gh-fork-ribbon.css" />
  15. <link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
  16. <script type="text/javascript" src="/js/sh_main.js"></script>
  17. <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>
  18. <script type="text/javascript" src="/js/bootstrap.js"></script>
  19. <script type='text/javascript'>
  20. /* <![CDATA[ */
  21. (function() {
  22. var s = document.createElement('script');
  23. var t = document.getElementsByTagName('script')[0];
  24. s.type = 'text/javascript';
  25. s.async = true;
  26. s.src = '//api.flattr.com/js/0.6/load.js?mode=auto&uid=xythobuz&category=text';
  27. t.parentNode.insertBefore(s, t);
  28. })();
  29. /* ]]> */
  30. </script>
  31. </head>
  32. <body onload="sh_highlightDocument('/js/sh/', '.min.js');">
  33. <div class="navbar">
  34. <div class="navbar-inner">
  35. <a class="brand" href="http://xythobuz.de/lastmusic">♫</a>
  36. <ul class="nav">
  37. <li><a href="/index.html">Home</a></li>
  38. <li><a href="/blog.html">Blog</a></li>
  39. <li><a href="/contact.html">Contact</a></li>
  40. <li class="dropdown"><a href="/software.html" class="dropdown-toggle" data-toggle="dropdown">Software<b class="caret"></b></a><ul class="dropdown-menu">
  41. <li><a href="/avrnetstack.html">avrNetStack</a></li>
  42. <li><a href="/avrserial.html">AVR Serial Library</a></li>
  43. <li><a href="/c250.html">Mio C250 Unlock</a></li>
  44. <li><a href="/nas.html">IB-NAS6210 Linux</a></li>
  45. <li><a href="/serialhelper.html">Serial Helper</a></li>
  46. <li><a href="/ultimatenotifier.html">Ultimate Notifier Script</a></li>
  47. <li><a href="/yasab.html">YASAB AVR Bootloader</a></li>
  48. </ul>
  49. <li class="dropdown"><a href="/hardware.html" class="dropdown-toggle" data-toggle="dropdown">Hardware<b class="caret"></b></a><ul class="dropdown-menu">
  50. <li><a href="/ledcube.html">8x8x8 LED Cube</a></li>
  51. <li><a href="/xycontrol.html">xyControl</a></li>
  52. <li class="dropdown-submenu"><a href="/xyrobot.html" class="dropdown-toggle" data-toggle="dropdown">xyRobot</a><ul class="dropdown-menu">
  53. <li><a href="/bluetooth.html">Bluetooth UART (BTM-222)</a></li>
  54. <li><a href="/k6x4008.html">K6x4008 SRAM</a></li>
  55. <li><a href="/rremote.html">rRemote</a></li>
  56. <li><a href="/xyrobotremote.html">xyRobotRemote</a></li>
  57. </ul>
  58. <li><a href="/ssop28.html">SSOP28 - DIL Adapter</a></li>
  59. <li><a href="/serialdebug.html">Serial Debug</a></li>
  60. <li><a href="/ledmatrix.html">LED Matrix</a></li>
  61. </ul>
  62. </ul>
  63. </div>
  64. </div>
  65. <div id="header">
  66. <h1>xythobuz.de</h1>
  67. <p><a href="http://xythobuz.de/lastmusic">♫</a></p>
  68. <h2>Ultimate Notifier Script</h2>
  69. </div>
  70. <div class="btn-group"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Language<span class="caret"></span></a><ul class="dropdown-menu">
  71. <li><a href='Ultimate Notifier Script'>title_de</a></li> | <li><a href='notifier'>compat</a></li> | <li><a href='true'>reddit</a></li> | <li><a href='Sending Push Notifications to an iPhone from a Bash Script'>description</a></li> | <li><a href='software'>parent</a></li> | <li><a href='Ultimate Notifier Script'>title</a></li> | <li><a href='ultimatenotifier.html'>url</a></li> | <li><a href='xythobuz'>twitter</a></li> | <li><a href='true'>comments</a></li> | <li><a href='en'>lang</a></li> | <li><a href='{u'de': u'ultimatenotifier.de.html', 'en': u'ultimatenotifier.html'}'>lang_links</a></li> | <li><a href='./input/ultimatenotifier.md'>fname</a></li> | <li><a href='[u'de', 'en']'>other_lang</a></li> | <li><a href='true'>print</a></li> | <li><a href='5'>position</a></li> | <li><a href='true'>flattr</a></li>
  72. </ul></div>
  73. <div id="content">
  74. <h1>Ultimate Notifier Script</h1>
  75. <p>The service <a href="http://ultimatenotifier.com">Ultimate Notifier</a> allows you to send Push-Notification to your iPhone easily. Based on this, you can write shell scripts that are executed regularly via cron. This could inform you about a changed public IP. To do this, save this script somewhere:</p>
  76. <pre class="sh_sh">
  77. #!/bin/sh
  78. ipfile=".currentip"
  79. service="ifconfig.me"
  80. user="username"
  81. pass="password"
  82. message="IP:"
  83. ip=`curl -s $service`
  84. touch $ipfile
  85. lastip=`cat $ipfile`
  86. if [ "$ip" != "$lastip" ]; then
  87. echo "New public IP. Sending notification!"
  88. curl -s "https://www.ultimatenotifier.com/items/User/send/${user}/message=${message}%20${ip}/password=${pass}"
  89. fi
  90. cp /dev/null $ipfile
  91. echo $ip > $ipfile
  92. </pre>
  93. <p>It gets the current public IP via <a href="http://ifconfig.me">ifconfig.me</a> and compares it to the IP stored in a file named .currentip. If they differ, a Push-Notification will be sent and the new IP stored.</p>
  94. <p>With the command</p>
  95. <pre>crontab -e</pre>
  96. <blockquote>
  97. <p>You can add a cronfile entry. To execute the script every 30 minutes, use this:</p>
  98. </blockquote>
  99. <pre>*/30 * * * * /Users/anon/bin/ipnotify.sh</pre>
  100. <p>You can find the code on <a href="https://github.com/xythobuz/Snippets/blob/master/ipnotify.sh">GitHub</a>, too!</p>
  101. <p>Of course, you can extend this principle. This script is called every 5 minutes on my server to notify me about eventual problems.</p>
  102. <pre class="sh_sh">
  103. #!/bin/bash
  104. # Checks for Health of Server and sends notifications to iPhone in case of error
  105. # Checks for:
  106. # - HDD Temperature
  107. # - HDD Space
  108. # - CPU Usage
  109. # Sends a notification via UltimateNotifier
  110. # Depends on bash, wget, hddtemp, grep, awk, sed, ps, sort and head.
  111. # ------------------------------
  112. # ------------------------------
  113. # Your UltimateNotifier Password
  114. UNUsername="YourUserName"
  115. UNPassword="YourPassWord"
  116. # Check for free space
  117. hddMountPoint="bay" # greps for this in mounted hdds
  118. maxPercentFull=75 # minimum percentage to send notification
  119. # Check for CPU Usage of processes
  120. maxCpuUsage=750 # Is in tenths of a percent (420 => 42%)
  121. # Checks hdd temperature
  122. # Depends on hddtemp tool
  123. hddDevice="/dev/sda"
  124. maxHddTemp=50
  125. # ------------------------------
  126. # ------------------------------
  127. # Set $message to your Message and then call this...
  128. function sendNotification {
  129. wget "https://www.ultimatenotifier.com/items/User/send/${UNUsername}/message=${message}/password=${UNPassword}" -O /dev/null -q
  130. echo "$message"
  131. }
  132. # ------------------------------
  133. # ------------------------------
  134. # Check for hdd temperature
  135. hddTemp=`/usr/sbin/hddtemp ${hddDevice} | awk '{print $4}' | awk -F '°' '{print $1}'`
  136. if [ $hddTemp -gt $maxHddTemp ]; then
  137. message="Marvin's HDD has reached ${hddTemp}°C!"
  138. sendNotification
  139. fi
  140. # Check for free space on hdd
  141. spaceUsed=`df -h | grep ${hddMountPoint} | awk '{print $5}' | sed 's/%//'`
  142. if [ $spaceUsed -gt $maxPercentFull ]; then
  143. message="Marvin's HDD is ${spaceUsed}% full!"
  144. sendNotification
  145. fi
  146. # Check for most cpu intensive process, report if usage too high
  147. processName=`ps -e -o cp,args | sed -e 's/^[ \\t]*//' | awk -F " " '{print $1, $2}' | sed -e '1d' | sort -rn | head -1 | awk '{print $2}'`
  148. processUsage=`ps -e -o cp,args | sed -e 's/^[ \\t]*//' | awk -F " " '{print $1, $2}' | sed -e '1d' | sort -rn | head -1 | awk '{print $1}'`
  149. if [ $processUsage -gt $maxCpuUsage ]; then
  150. processUsage=`echo "${processUsage} / 10.0" | bc -q`
  151. message="${processName} needs ${processUsage}% CPU!"
  152. sendNotification
  153. fi
  154. </pre>
  155. <span id="flattr">
  156. <a class="FlattrButton" href="http://www.xythobuz.de/ultimatenotifier.html" title="Ultimate Notifier Script">Sending Push Notifications to an iPhone from a Bash Script</a>
  157. </span>
  158. <span id="twitter">
  159. <a href="https://twitter.com/share" class="twitter-share-buttdata-via="xythobuz" data-dnt="true" data-related="xythobuz" data-count="vertical">Tweet</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s;if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twi.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitwjs");</script>
  160. </span>
  161. <span id="reddit">
  162. <script type="text/javascript">reddit_url = "http://www.xythobuz.de/ultimatenotifier.html";</script>
  163. <script type="text/javascript" src="http://www.redcom/static/button/button2.js"></script>
  164. </span>
  165. <div id="print"><script>var pfHeaderImgUrl = '';var pfHeaderTagline = '';var pfdisableClickToDel = 0;var pfHideImages = 0;var pfImageDisplayStyle = 'right';var pfDisablePDF = 0;var pfDisableEmail = 0;var pfDisablePrint = 0;var pfCustomCSS = '';var pfBtVersion='1';(function(){var js, pf;pf = document.createElement('script');pf.type = 'text/javascript';if('https:' == document.location.protocol){js='https://pf-cdn.printfriendly.com/ssl/main.js'}else{js='http://cdn.printfriendly.com/printfriendly.js'}pf.src=js;document.getElementsByTagName('head')[0].appendChild(pf)})();</script><a href="http://www.printfriendly.com" style="color:#6D9F00;text-decoration:none;" class="printfriendly" onclick="window.print();return false;" title="Printer Friendly and PDF"><img style="border:none;margin:0 6px" src="https://pf-cdn.printfriendly.com/images/icons/pf-print-icon.gif" width="16" height="15" alt="Print Friendly Version of this page" />Print <img style="border:none;margin:0 6px" src="https://pf-cdn.printfriendly.com/images/icons/pf-pdf-icon.gif" width="12" height="12" alt="Get a PDF version of this webpage" />PDF</a></div>
  166. <div id="disqus_thread"></div>
  167. <script type="text/javascript">
  168. var disqus_shortname = "xythobuz";
  169. (function() {
  170. var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
  171. dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js";
  172. (document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0] ).appendChild(dsq);
  173. })();
  174. </script>
  175. <noscript>Please enable JavaScript to view the <a href="http://disqus. com/?ref_noscript">comments powered by Disqus.</a></noscript>
  176. <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
  177. </div>
  178. <div style="color: gray; text-align: center;">
  179. Built with <a href="http://bitbucket.org/obensonne/poole">Poole</a>
  180. &middot;
  181. Made with <a href="http://twitter.github.io/bootstrap/index.html">Bootstrap</a>
  182. &middot;
  183. Using <a href="http://shjs.sourceforge.net">SHJS</a>
  184. &middot;
  185. Licensed as <a href="http://creativecommons.org/licenses/by/3.0">CC-BY</a>
  186. </div>
  187. <img src="/stats/count.php?img" alt="Analytics">
  188. <script src="http://gitforked.com/api/1.1/button.js" type="text/javascript"></script>
  189. <script type="text/javascript">
  190. var _gaq = _gaq || [];
  191. _gaq.push(['_setAccount', 'UA-39163591-1']);
  192. _gaq.push(['_setDomainName', 'xythobuz.org']);
  193. _gaq.push(['_setAllowLinker', true]);
  194. _gaq.push(['_trackPageview']);
  195. (function() {
  196. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  197. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  198. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  199. })();
  200. </script>
  201. </body>
  202. </html>