My static website generator using poole https://www.xythobuz.de
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ultimatenotifier.de.html 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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>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>
  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>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>
  113. <p>Mit dem Befehl</p>
  114. <pre>crontab -e</pre>
  115. <p>Kann ein Eintrag ins cronfile hinzugefügt werden, sodass das Skript regelmäßig gestartet wird. Ein Beispiel, für 30 Minuten:</p>
  116. <pre>*/30 * * * * /Users/anon/bin/ipnotify.sh</pre>
  117. <p>Der Code findet sich auch auf <a href="https://github.com/xythobuz/Snippets/blob/master/ipnotify.sh">GitHub</a>.</p>
  118. <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>
  119. <pre class="sh_sh">
  120. #!/bin/bash
  121. # Checks for Health of Server and sends notifications to iPhone in case of error
  122. # Checks for:
  123. # - HDD Temperature
  124. # - HDD Space
  125. # - CPU Usage
  126. # Sends a notification via UltimateNotifier
  127. # Depends on bash, wget, hddtemp, grep, awk, sed, ps, sort and head.
  128. # ------------------------------
  129. # ------------------------------
  130. # Your UltimateNotifier Password
  131. UNUsername="YourUserName"
  132. UNPassword="YourPassWord"
  133. # Check for free space
  134. hddMountPoint="bay" # greps for this in mounted hdds
  135. maxPercentFull=75 # minimum percentage to send notification
  136. # Check for CPU Usage of processes
  137. maxCpuUsage=750 # Is in tenths of a percent (420 => 42%)
  138. # Checks hdd temperature
  139. # Depends on hddtemp tool
  140. hddDevice="/dev/sda"
  141. maxHddTemp=50
  142. # ------------------------------
  143. # ------------------------------
  144. # Set $message to your Message and then call this...
  145. function sendNotification {
  146. wget "https://www.ultimatenotifier.com/items/User/send/${UNUsername}/message=${message}/password=${UNPassword}" -O /dev/null -q
  147. echo "$message"
  148. }
  149. # ------------------------------
  150. # ------------------------------
  151. # Check for hdd temperature
  152. hddTemp=`/usr/sbin/hddtemp ${hddDevice} | awk '{print $4}' | awk -F '°' '{print $1}'`
  153. if [ $hddTemp -gt $maxHddTemp ]; then
  154. message="Marvin's HDD has reached ${hddTemp}°C!"
  155. sendNotification
  156. fi
  157. # Check for free space on hdd
  158. spaceUsed=`df -h | grep ${hddMountPoint} | awk '{print $5}' | sed 's/%//'`
  159. if [ $spaceUsed -gt $maxPercentFull ]; then
  160. message="Marvin's HDD is ${spaceUsed}% full!"
  161. sendNotification
  162. fi
  163. # Check for most cpu intensive process, report if usage too high
  164. 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}'`
  165. 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}'`
  166. if [ $processUsage -gt $maxCpuUsage ]; then
  167. processUsage=`echo "${processUsage} / 10.0" | bc -q`
  168. message="${processName} needs ${processUsage}% CPU!"
  169. sendNotification
  170. fi
  171. </pre>
  172. <span id="flattr">
  173. <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>
  174. </span>
  175. <span id="twitter">
  176. <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>
  177. </span>
  178. <span id="reddit">
  179. <script type="text/javascript">reddit_url = "http://www.xythobuz.de/ultimatenotifier.de.html";</script>
  180. <script type="text/javascript" src="http://www.redcom/static/button/button2.js"></script>
  181. </span>
  182. <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>
  183. <div id="disqus_thread"></div>
  184. <script type="text/javascript">
  185. var disqus_shortname = "xythobuz";
  186. (function() {
  187. var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
  188. dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js";
  189. (document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0] ).appendChild(dsq);
  190. })();
  191. </script>
  192. <noscript>Please enable JavaScript to view the <a href="http://disqus. com/?ref_noscript">comments powered by Disqus.</a></noscript>
  193. <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
  194. </div>
  195. <div id="footer">
  196. Built with <a href="http://bitbucket.org/obensonne/poole">Poole</a>
  197. &middot;
  198. Licensed as <a href="http://creativecommons.org/licenses/by/3.0">CC-BY</a>
  199. &middot;
  200. <a href="http://validator.w3.org/check?uri=referer">Validate HTML</a>
  201. &middot;
  202. <a href="http://jigsaw.w3.org/css-validator/validator?uri=xythobuz.de%2Fstyle.css&amp;profile=css3">Validate CSS</a>
  203. &middot;
  204. <a href="http://feed1.w3.org/check.cgi?url=http://www.xythobuz.de/rss.xml">Validate RSS</a>
  205. &middot;
  206. <a href="http://www.validome.org/google/validate?url=http://www.xythobuz.de&amp;googleTyp=SITEMAP">Validate Sitemap</a>
  207. </div>
  208. <img src="/stats/count.php?img" alt="Analytics">
  209. <script src="http://gitforked.com/api/1.1/button.js" type="text/javascript"></script>
  210. <script type="text/javascript">
  211. var _gaq = _gaq || [];
  212. _gaq.push(['_setAccount', 'UA-39163591-1']);
  213. _gaq.push(['_setDomainName', 'xythobuz.org']);
  214. _gaq.push(['_setAllowLinker', true]);
  215. _gaq.push(['_trackPageview']);
  216. (function() {
  217. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  218. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  219. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  220. })();
  221. </script>
  222. </body>
  223. </html>