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.de.html 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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');" style="font-size: 1.1em; font-family: 'Droid Sans', sans-serif;">
  33. <div class="navbar">
  34. <div class="navbar-inner">
  35. <ul class="nav">
  36. <li><a href="/index.html">Home</a></li>
  37. <li><a href="/blog.html">Blog</a></li>
  38. <li><a href="/contact.html">Contact</a></li>
  39. <li class="dropdown"><a href="/software.html" class="dropdown-toggle" data-toggle="dropdown">Software<b class="caret"></b></a><ul class="dropdown-menu">
  40. <li><a href="/avrnetstack.html">avrNetStack</a></li>
  41. <li><a href="/avrserial.html">AVR Serial Library</a></li>
  42. <li><a href="/yasab.html">YASAB AVR Bootloader</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. </ul>
  48. <li class="dropdown"><a href="/hardware.html" class="dropdown-toggle" data-toggle="dropdown">Hardware<b class="caret"></b></a><ul class="dropdown-menu">
  49. <li><a href="/ledcube.html">8x8x8 LED Cube</a></li>
  50. <li><a href="/xycontrol.html">xyControl</a></li>
  51. <li class="dropdown-submenu"><a href="/xyrobot.html" class="dropdown-toggle disabled" data-toggle="dropdown">xyRobot</a><ul class="dropdown-menu">
  52. <li><a href="/bluetooth.html">Bluetooth UART (BTM-222)</a></li>
  53. <li><a href="/k6x4008.html">K6x4008 SRAM</a></li>
  54. <li><a href="/rremote.html">rRemote</a></li>
  55. <li><a href="/xyrobotremote.html">xyRobotRemote</a></li>
  56. </ul>
  57. <li><a href="/ssop28.html">SSOP28 - DIL Adapter</a></li>
  58. <li><a href="/serialdebug.html">Serial Debug</a></li>
  59. <li><a href="/ledmatrix.html">LED Matrix</a></li>
  60. </ul>
  61. <li class="divider-vertical"></li>
  62. <li><a href="http://xythobuz.de/lastmusic">♫</a></li>
  63. <li class="divider-vertical"></li>
  64. <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Language<b class="caret"></b></a><ul class="dropdown-menu">
  65. <li><a href='ultimatenotifier.de.html'>Deutsch</a></li> <li><a href='ultimatenotifier.html'>English</a></li>
  66. </ul></li>
  67. <li class="divider-vertical"></li>
  68. <script type="text/javascript">
  69. function sitesearch(curobj) {
  70. curobj.q.value = "site:xythobuz.de " + curobj.r.value
  71. }
  72. </script>
  73. <form class="navbar-search" action="http://www.google.com/search" method="get" onSubmit="sitesearch(this)">
  74. <input name="q" type="hidden" />
  75. <input name="r" type="text" class="search-query span2" placeholder="Search..." />
  76. </form>
  77. </ul>
  78. </div>
  79. </div>
  80. <div style="width: 75%; margin-left: auto; margin-right: auto;">
  81. <h1>Ultimate Notifier Script</h1>
  82. <p>Der Dienst <a href="http://ultimatenotifier.com/">Ultimate Notifier</a> erlaubt es relativ problemlos, zum Beispiel mittels curl Push-Notifications an ein iPhone zu senden. Darauf basierend können Shell Skripte geschrieben werden, welche regelmäßig als Cron-Job gestartet werden. So kann man sich zum Beispiel über eine geänderte Public IP informieren lassen. Dafür muss dieses Skript irgendwo gespeichert werden:</p>
  83. <pre class="sh_sh">
  84. #!/bin/sh
  85. ipfile=".currentip"
  86. service="ifconfig.me"
  87. user="username"
  88. pass="password"
  89. message="IP:"
  90. ip=`curl -s $service`
  91. touch $ipfile
  92. lastip=`cat $ipfile`
  93. if [ "$ip" != "$lastip" ]; then
  94. echo "New public IP. Sending notification!"
  95. curl -s "https://www.ultimatenotifier.com/items/User/send/${user}/message=${message}%20${ip}/password=${pass}"
  96. fi
  97. cp /dev/null $ipfile
  98. echo $ip > $ipfile
  99. </pre>
  100. <p>Es liest die aktuelle öffentliche IP mittels curl vom Dienst <a href="http://ifconfig.me">ifconfig.me</a> aus und vergleicht diese mit der zwischengespeicherten IP in einer Datei namens .currentip. Unterscheiden sich die IPs, wird eine Push Notification gesendet und die neue IP gespeichert.</p>
  101. <p>Mit dem Befehl</p>
  102. <pre>crontab -e</pre>
  103. <p>Kann ein Eintrag ins cronfile hinzugefügt werden, sodass das Skript regelmäßig gestartet wird. Ein Beispiel, für 30 Minuten:</p>
  104. <pre>*/30 * * * * /Users/anon/bin/ipnotify.sh</pre>
  105. <p>Der Code findet sich auch auf <a href="https://github.com/xythobuz/Snippets/blob/master/ipnotify.sh">GitHub</a>.</p>
  106. <p>Natürlich kann dieses Prinzip beliebig erweitert werden. Dieses Bash Skript wird auf meinem Server alle 5 Minuten von cron gestartet und berichtet über eventuelle Probleme.</p>
  107. <pre class="sh_sh">
  108. #!/bin/bash
  109. # Checks for Health of Server and sends notifications to iPhone in case of error
  110. # Checks for:
  111. # - HDD Temperature
  112. # - HDD Space
  113. # - CPU Usage
  114. # Sends a notification via UltimateNotifier
  115. # Depends on bash, wget, hddtemp, grep, awk, sed, ps, sort and head.
  116. # ------------------------------
  117. # ------------------------------
  118. # Your UltimateNotifier Password
  119. UNUsername="YourUserName"
  120. UNPassword="YourPassWord"
  121. # Check for free space
  122. hddMountPoint="bay" # greps for this in mounted hdds
  123. maxPercentFull=75 # minimum percentage to send notification
  124. # Check for CPU Usage of processes
  125. maxCpuUsage=750 # Is in tenths of a percent (420 => 42%)
  126. # Checks hdd temperature
  127. # Depends on hddtemp tool
  128. hddDevice="/dev/sda"
  129. maxHddTemp=50
  130. # ------------------------------
  131. # ------------------------------
  132. # Set $message to your Message and then call this...
  133. function sendNotification {
  134. wget "https://www.ultimatenotifier.com/items/User/send/${UNUsername}/message=${message}/password=${UNPassword}" -O /dev/null -q
  135. echo "$message"
  136. }
  137. # ------------------------------
  138. # ------------------------------
  139. # Check for hdd temperature
  140. hddTemp=`/usr/sbin/hddtemp ${hddDevice} | awk '{print $4}' | awk -F '°' '{print $1}'`
  141. if [ $hddTemp -gt $maxHddTemp ]; then
  142. message="Marvin's HDD has reached ${hddTemp}°C!"
  143. sendNotification
  144. fi
  145. # Check for free space on hdd
  146. spaceUsed=`df -h | grep ${hddMountPoint} | awk '{print $5}' | sed 's/%//'`
  147. if [ $spaceUsed -gt $maxPercentFull ]; then
  148. message="Marvin's HDD is ${spaceUsed}% full!"
  149. sendNotification
  150. fi
  151. # Check for most cpu intensive process, report if usage too high
  152. 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}'`
  153. 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}'`
  154. if [ $processUsage -gt $maxCpuUsage ]; then
  155. processUsage=`echo "${processUsage} / 10.0" | bc -q`
  156. message="${processName} needs ${processUsage}% CPU!"
  157. sendNotification
  158. fi
  159. </pre>
  160. <span id="flattr">
  161. <a class="FlattrButton" href="http://www.xythobuz.de/ultimatenotifier.de.html" title="Ultimate Notifier Script">Sending Push Notifications to an iPhone from a Bash Script</a>
  162. </span>
  163. <span id="twitter">
  164. <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>
  165. </span>
  166. <span id="reddit">
  167. <script type="text/javascript">reddit_url = "http://www.xythobuz.de/ultimatenotifier.de.html";</script>
  168. <script type="text/javascript" src="http://www.redcom/static/button/button2.js"></script>
  169. </span>
  170. <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>
  171. <div id="disqus_thread"></div>
  172. <script type="text/javascript">
  173. var disqus_shortname = "xythobuz";
  174. (function() {
  175. var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
  176. dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js";
  177. (document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0] ).appendChild(dsq);
  178. })();
  179. </script>
  180. <noscript>Please enable JavaScript to view the <a href="http://disqus. com/?ref_noscript">comments powered by Disqus.</a></noscript>
  181. <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
  182. </div>
  183. <div style="color: gray; text-align: center;">
  184. Built with <a href="http://bitbucket.org/obensonne/poole">Poole</a>
  185. &middot;
  186. Made with <a href="http://twitter.github.io/bootstrap/index.html">Bootstrap</a>
  187. &middot;
  188. Using <a href="http://shjs.sourceforge.net">SHJS</a>
  189. &middot;
  190. Licensed as <a href="http://creativecommons.org/licenses/by/3.0">CC-BY</a>
  191. </div>
  192. <img src="http://xythobuz.de/stats/count.php?img" alt="Analytics">
  193. <script src="http://gitforked.com/api/1.1/button.js" type="text/javascript"></script>
  194. <script type="text/javascript">
  195. var _gaq = _gaq || [];
  196. _gaq.push(['_setAccount', 'UA-39163591-1']);
  197. _gaq.push(['_setDomainName', 'xythobuz.org']);
  198. _gaq.push(['_setAllowLinker', true]);
  199. _gaq.push(['_trackPageview']);
  200. setTimeout("_gaq.push(['_trackEvent', '30_seconds', 'read'])", 30000);
  201. (function() {
  202. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  203. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  204. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  205. })();
  206. </script>
  207. </body>
  208. </html>