My static website generator using poole https://www.xythobuz.de
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ultimatenotifier.de.html 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. <h2>Ultimate Notifier Script</h2>
  33. </div>
  34. <div id="lang"><span id="lang2">Translation:
  35. <a href='ultimatenotifier.de.html'>de</a> | <a href='ultimatenotifier.html'>en</a>
  36. </span></div>
  37. <div class="colmask leftmenu"><div class="colleft">
  38. <div class="content">
  39. <div id="flattr">
  40. <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>
  41. </div>
  42. <div id="twitter">
  43. <a href="https://twitter.com/share" class="twitter-share-button" data-via="xythobuz" data-dnt="true" data-related="xythobuz" data-count="vertical">Tweet</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
  44. </div>
  45. <div id="reddit">
  46. <script type="text/javascript">reddit_url = "http://www.xythobuz.de/ultimatenotifier.de.html";</script>
  47. <script type="text/javascript" src="http://www.reddit.com/static/button/button2.js"></script>
  48. </div>
  49. <h1>Ultimate Notifier Script</h1>
  50. <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>
  51. <pre class="sh_sh">
  52. #!/bin/sh
  53. ipfile=".currentip"
  54. service="ifconfig.me"
  55. user="username"
  56. pass="password"
  57. message="IP:"
  58. ip=`curl -s $service`
  59. touch $ipfile
  60. lastip=`cat $ipfile`
  61. if [ "$ip" != "$lastip" ]; then
  62. echo "New public IP. Sending notification!"
  63. curl -s "https://www.ultimatenotifier.com/items/User/send/${user}/message=${message}%20${ip}/password=${pass}"
  64. fi
  65. cp /dev/null $ipfile
  66. echo $ip > $ipfile
  67. </pre>
  68. <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>
  69. <p>Mit dem Befehl</p>
  70. <pre>crontab -e</pre>
  71. <p>Kann ein Eintrag ins cronfile hinzugefügt werden, sodass das Skript regelmäßig gestartet wird. Ein Beispiel, für 30 Minuten:</p>
  72. <pre>*/30 * * * * /Users/anon/bin/ipnotify.sh</pre>
  73. <p>Der Code findet sich auch auf <a href="https://github.com/xythobuz/Snippets/blob/master/ipnotify.sh">GitHub</a>.</p>
  74. <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>
  75. <pre class="sh_sh">
  76. #!/bin/bash
  77. # Checks for Health of Server and sends notifications to iPhone in case of error
  78. # Checks for:
  79. # - HDD Temperature
  80. # - HDD Space
  81. # - CPU Usage
  82. # Sends a notification via UltimateNotifier
  83. # Depends on bash, wget, hddtemp, grep, awk, sed, ps, sort and head.
  84. # ------------------------------
  85. # ------------------------------
  86. # Your UltimateNotifier Password
  87. UNUsername="YourUserName"
  88. UNPassword="YourPassWord"
  89. # Check for free space
  90. hddMountPoint="bay" # greps for this in mounted hdds
  91. maxPercentFull=75 # minimum percentage to send notification
  92. # Check for CPU Usage of processes
  93. maxCpuUsage=750 # Is in tenths of a percent (420 => 42%)
  94. # Checks hdd temperature
  95. # Depends on hddtemp tool
  96. hddDevice="/dev/sda"
  97. maxHddTemp=50
  98. # ------------------------------
  99. # ------------------------------
  100. # Set $message to your Message and then call this...
  101. function sendNotification {
  102. wget "https://www.ultimatenotifier.com/items/User/send/${UNUsername}/message=${message}/password=${UNPassword}" -O /dev/null -q
  103. echo "$message"
  104. }
  105. # ------------------------------
  106. # ------------------------------
  107. # Check for hdd temperature
  108. hddTemp=`/usr/sbin/hddtemp ${hddDevice} | awk '{print $4}' | awk -F '°' '{print $1}'`
  109. if [ $hddTemp -gt $maxHddTemp ]; then
  110. message="Marvin's HDD has reached ${hddTemp}°C!"
  111. sendNotification
  112. fi
  113. # Check for free space on hdd
  114. spaceUsed=`df -h | grep ${hddMountPoint} | awk '{print $5}' | sed 's/%//'`
  115. if [ $spaceUsed -gt $maxPercentFull ]; then
  116. message="Marvin's HDD is ${spaceUsed}% full!"
  117. sendNotification
  118. fi
  119. # Check for most cpu intensive process, report if usage too high
  120. 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}'`
  121. 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}'`
  122. if [ $processUsage -gt $maxCpuUsage ]; then
  123. processUsage=`echo "${processUsage} / 10.0" | bc -q`
  124. message="${processName} needs ${processUsage}% CPU!"
  125. sendNotification
  126. fi
  127. </pre>
  128. <div id="disqus_thread"></div>
  129. <script type="text/javascript">
  130. var disqus_shortname = "xythobuz";
  131. (function() {
  132. var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
  133. dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js";
  134. (document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
  135. })();
  136. </script>
  137. <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
  138. <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
  139. </div>
  140. <div class="nav">
  141. <h3>Thomas Buck</h3>
  142. <div id="logo"><img id="logoImg" src="http://www.gravatar.com/avatar/8d18fec40a74782052fb4c007d212475?s=180" alt="Avatar"></div>
  143. <p id="bio">
  144. I'm a 19 year old Information Engineering student from Germany, mostly building cool stuff with AVR microcontrollers. All of my projects are released as Free Software.
  145. </p>
  146. <ul id="menuList">
  147. <li><a href="/index.html">Home</a></li>
  148. <li><a href="/blog.html">Blog</a></li>
  149. <li><a href="/contact.html">Contact</a></li>
  150. <li>&nbsp;</li>
  151. <li><a href="/ledcube.html">8x8x8 LED Cube</a></li>
  152. <li><a href="/yasab.html">YASAB AVR Bootloader</a></li>
  153. <li><a href="/avrnetstack.html">avrNetStack</a></li>
  154. <li><a href="/avrserial.html">AVR Serial Library</a></li>
  155. <li><a href="/serialdebug.html">Serial Debug</a></li>
  156. <li><a href="/ledmatrix.html">LED Matrix</a></li>
  157. <li><a href="/ssop28.html">SSOP28 - DIL Adapter</a></li>
  158. <li><a href="/xyrobot.html">xyRobot</a></li>
  159. <li><a href="/bluetooth.html">Bluetooth UART (BTM-222)</a></li>
  160. <li><a href="/k6x4008.html">K6x4008 SRAM</a></li>
  161. <li><a href="/xyrobotremote.html">xyRobotRemote</a></li>
  162. <li><a href="/rremote.html">rRemote</a></li>
  163. <li>&nbsp;</li>
  164. <li><a href="/c250.html">Mio C250 Unlock</a></li>
  165. <li><a href="/nas.html">IB-NAS6210 Linux</a></li>
  166. <li><a href="/ultimatenotifier.html">Ultimate Notifier Script</a></li>
  167. <li><a href="/serialhelper.html">Serial Helper</a></li>
  168. </ul>
  169. <div id="recent">
  170. Recent blog posts:
  171. <ul id="recentList">
  172. <li class="recentList"><a href="/2013_04_04_html5.html">Kein DRM in HTML5</a></li><li class="recentDate">2013-04-04</li>
  173. <li class="recentList"><a href="/2013_04_02_zaphod.html">Neuer Webserver</a></li><li class="recentDate">2013-04-02</li>
  174. <li class="recentList"><a href="/2013_03_25_doxygen.html">xyControl Doxygen Dokumentation</a></li><li class="recentDate">2013-03-25</li>
  175. <li class="recentList"><a href="/2013_03_16_pid.html">xyCopter PID-Parameter</a></li><li class="recentDate">2013-03-16</li>
  176. <li class="recentList"><a href="/2013_03_13_test_rig.html">Quadrocopter Test Rig Video</a></li><li class="recentDate">2013-03-13</li>
  177. </ul>
  178. </div>
  179. </div>
  180. </div></div>
  181. <img id="dude" alt="The Dude abides..." src="/img/dude.png">
  182. <img id="walter" alt="Mark it zero!" src="/img/walter.png">
  183. <div id="footer">
  184. Built with <a href="http://bitbucket.org/obensonne/poole">Poole</a>
  185. &middot;
  186. Licensed as <a href="http://creativecommons.org/licenses/by/3.0">CC-BY</a>
  187. &middot;
  188. <a href="http://validator.w3.org/check?uri=referer">Validate HTML</a>
  189. &middot;
  190. <a href="http://jigsaw.w3.org/css-validator/validator?uri=xythobuz.de%2Fstyle.css&amp;profile=css3">Validate CSS</a>
  191. &middot;
  192. <a href="http://feed1.w3.org/check.cgi?url=http://www.xythobuz.de/rss.xml">Validate RSS</a>
  193. &middot;
  194. <a href="http://www.validome.org/google/validate?url=http://www.xythobuz.de&amp;googleTyp=SITEMAP">Validate Sitemap</a>
  195. </div>
  196. <img src="/stats/count.php?img" alt="Analytics">
  197. <script src="http://gitforked.com/api/1.1/button.js" type="text/javascript"></script>
  198. </body>
  199. </html>