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 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. <link rel="author" href="/xythobuz@xythobuz.de">
  9. <link rel="shortcut icon" href="/img/favicon.ico">
  10. <script type="text/javascript" src="/js/sh_main.js"></script>
  11. <link type="text/css" rel="stylesheet" href="/css/sh_bright.min.css" />
  12. <link rel="stylesheet" href="/css/style.css" type="text/css" media="screen" />
  13. <link rel="alternate" type="application/rss+xml" title="Blog" href="/rss.xml">
  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'>
  17. /* <![CDATA[ */
  18. (function() {
  19. var s = document.createElement('script');
  20. var t = document.getElementsByTagName('script')[0];
  21. s.type = 'text/javascript';
  22. s.async = true;
  23. s.src = '//api.flattr.com/js/0.6/load.js?mode=auto&uid=xythobuz&category=text';
  24. t.parentNode.insertBefore(s, t);
  25. })();
  26. /* ]]> */
  27. </script>
  28. </head>
  29. <body onload="sh_highlightDocument('/js/sh/', '.min.js');">
  30. <div id="header">
  31. <h1>xythobuz.de</h1>
  32. <p><a href="http://xythobuz.de/lastmusic">♫</a></p>
  33. <h2>Ultimate Notifier Script</h2>
  34. </div>
  35. <nav>
  36. <ul id="menu">
  37. <li><a href="/index.html">Home</a>
  38. </li>
  39. <li><a href="/blog.html">Blog</a>
  40. </li>
  41. <li><a href="/contact.html">Contact</a>
  42. </li>
  43. <li><a href="/software.html">Software</a>
  44. <ul>
  45. <li><a href="/avrnetstack.html">avrNetStack</a>
  46. </li>
  47. <li><a href="/avrserial.html">AVR Serial Library</a>
  48. </li>
  49. <li><a href="/c250.html">Mio C250 Unlock</a>
  50. </li>
  51. <li><a href="/nas.html">IB-NAS6210 Linux</a>
  52. </li>
  53. <li><a href="/serialhelper.html">Serial Helper</a>
  54. </li>
  55. <li><a href="/ultimatenotifier.html">Ultimate Notifier Script</a>
  56. </li>
  57. <li><a href="/yasab.html">YASAB AVR Bootloader</a>
  58. </li>
  59. </ul>
  60. </li>
  61. <li><a href="/hardware.html">Hardware</a>
  62. <ul>
  63. <li><a href="/ledcube.html">8x8x8 LED Cube</a>
  64. </li>
  65. <li><a href="/xycontrol.html">xyControl</a>
  66. </li>
  67. <li><a href="/xyrobot.html">xyRobot</a>
  68. <ul>
  69. <li><a href="/bluetooth.html">Bluetooth UART (BTM-222)</a>
  70. </li>
  71. <li><a href="/k6x4008.html">K6x4008 SRAM</a>
  72. </li>
  73. <li><a href="/rremote.html">rRemote</a>
  74. </li>
  75. <li><a href="/xyrobotremote.html">xyRobotRemote</a>
  76. </li>
  77. </ul>
  78. </li>
  79. <li><a href="/ssop28.html">SSOP28 - DIL Adapter</a>
  80. </li>
  81. <li><a href="/serialdebug.html">Serial Debug</a>
  82. </li>
  83. <li><a href="/ledmatrix.html">LED Matrix</a>
  84. </li>
  85. </ul>
  86. </li>
  87. </ul>
  88. <div>Translation:
  89. <a href='ultimatenotifier.de.html'>de</a> | <a href='ultimatenotifier.html'>en</a>
  90. </div>
  91. </nav>
  92. <div id="content">
  93. <h1>Ultimate Notifier Script</h1>
  94. <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>
  95. <pre class="sh_sh">
  96. #!/bin/sh
  97. ipfile=".currentip"
  98. service="ifconfig.me"
  99. user="username"
  100. pass="password"
  101. message="IP:"
  102. ip=`curl -s $service`
  103. touch $ipfile
  104. lastip=`cat $ipfile`
  105. if [ "$ip" != "$lastip" ]; then
  106. echo "New public IP. Sending notification!"
  107. curl -s "https://www.ultimatenotifier.com/items/User/send/${user}/message=${message}%20${ip}/password=${pass}"
  108. fi
  109. cp /dev/null $ipfile
  110. echo $ip > $ipfile
  111. </pre>
  112. <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>
  113. <p>With the command</p>
  114. <pre>crontab -e</pre>
  115. <blockquote>
  116. <p>You can add a cronfile entry. To execute the script every 30 minutes, use this:</p>
  117. </blockquote>
  118. <pre>*/30 * * * * /Users/anon/bin/ipnotify.sh</pre>
  119. <p>You can find the code on <a href="https://github.com/xythobuz/Snippets/blob/master/ipnotify.sh">GitHub</a>, too!</p>
  120. <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>
  121. <pre class="sh_sh">
  122. #!/bin/bash
  123. # Checks for Health of Server and sends notifications to iPhone in case of error
  124. # Checks for:
  125. # - HDD Temperature
  126. # - HDD Space
  127. # - CPU Usage
  128. # Sends a notification via UltimateNotifier
  129. # Depends on bash, wget, hddtemp, grep, awk, sed, ps, sort and head.
  130. # ------------------------------
  131. # ------------------------------
  132. # Your UltimateNotifier Password
  133. UNUsername="YourUserName"
  134. UNPassword="YourPassWord"
  135. # Check for free space
  136. hddMountPoint="bay" # greps for this in mounted hdds
  137. maxPercentFull=75 # minimum percentage to send notification
  138. # Check for CPU Usage of processes
  139. maxCpuUsage=750 # Is in tenths of a percent (420 => 42%)
  140. # Checks hdd temperature
  141. # Depends on hddtemp tool
  142. hddDevice="/dev/sda"
  143. maxHddTemp=50
  144. # ------------------------------
  145. # ------------------------------
  146. # Set $message to your Message and then call this...
  147. function sendNotification {
  148. wget "https://www.ultimatenotifier.com/items/User/send/${UNUsername}/message=${message}/password=${UNPassword}" -O /dev/null -q
  149. echo "$message"
  150. }
  151. # ------------------------------
  152. # ------------------------------
  153. # Check for hdd temperature
  154. hddTemp=`/usr/sbin/hddtemp ${hddDevice} | awk '{print $4}' | awk -F '°' '{print $1}'`
  155. if [ $hddTemp -gt $maxHddTemp ]; then
  156. message="Marvin's HDD has reached ${hddTemp}°C!"
  157. sendNotification
  158. fi
  159. # Check for free space on hdd
  160. spaceUsed=`df -h | grep ${hddMountPoint} | awk '{print $5}' | sed 's/%//'`
  161. if [ $spaceUsed -gt $maxPercentFull ]; then
  162. message="Marvin's HDD is ${spaceUsed}% full!"
  163. sendNotification
  164. fi
  165. # Check for most cpu intensive process, report if usage too high
  166. 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}'`
  167. 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}'`
  168. if [ $processUsage -gt $maxCpuUsage ]; then
  169. processUsage=`echo "${processUsage} / 10.0" | bc -q`
  170. message="${processName} needs ${processUsage}% CPU!"
  171. sendNotification
  172. fi
  173. </pre>
  174. <span id="flattr">
  175. <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>
  176. </span>
  177. <span id="twitter">
  178. <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>
  179. </span>
  180. <span id="reddit">
  181. <script type="text/javascript">reddit_url = "http://www.xythobuz.de/ultimatenotifier.html";</script>
  182. <script type="text/javascript" src="http://www.redcom/static/button/button2.js"></script>
  183. </span>
  184. <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>
  185. <div id="disqus_thread"></div>
  186. <script type="text/javascript">
  187. var disqus_shortname = "xythobuz";
  188. (function() {
  189. var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
  190. dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js";
  191. (document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0] ).appendChild(dsq);
  192. })();
  193. </script>
  194. <noscript>Please enable JavaScript to view the <a href="http://disqus. com/?ref_noscript">comments powered by Disqus.</a></noscript>
  195. <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
  196. </div>
  197. <div id="footer">
  198. Built with <a href="http://bitbucket.org/obensonne/poole">Poole</a>
  199. &middot;
  200. Licensed as <a href="http://creativecommons.org/licenses/by/3.0">CC-BY</a>
  201. &middot;
  202. <a href="http://validator.w3.org/check?uri=referer">Validate HTML</a>
  203. &middot;
  204. <a href="http://jigsaw.w3.org/css-validator/validator?uri=xythobuz.de%2Fstyle.css&amp;profile=css3">Validate CSS</a>
  205. &middot;
  206. <a href="http://feed1.w3.org/check.cgi?url=http://www.xythobuz.de/rss.xml">Validate RSS</a>
  207. &middot;
  208. <a href="http://www.validome.org/google/validate?url=http://www.xythobuz.de&amp;googleTyp=SITEMAP">Validate Sitemap</a>
  209. </div>
  210. <img src="/stats/count.php?img" alt="Analytics">
  211. <script src="http://gitforked.com/api/1.1/button.js" type="text/javascript"></script>
  212. <script type="text/javascript">
  213. var _gaq = _gaq || [];
  214. _gaq.push(['_setAccount', 'UA-39163591-1']);
  215. _gaq.push(['_setDomainName', 'xythobuz.org']);
  216. _gaq.push(['_setAllowLinker', true]);
  217. _gaq.push(['_trackPageview']);
  218. (function() {
  219. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  220. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  221. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  222. })();
  223. </script>
  224. </body>
  225. </html>