{"id":596,"date":"2014-10-03T07:44:48","date_gmt":"2014-10-03T05:44:48","guid":{"rendered":"http:\/\/dety.net.ua\/?p=596"},"modified":"2014-10-03T07:45:05","modified_gmt":"2014-10-03T05:45:05","slug":"another-script-for-temperature-monitoring-on-pfsense","status":"publish","type":"post","link":"https:\/\/dety.net.ua\/?p=596","title":{"rendered":"Another script for temperature monitoring on PFSense"},"content":{"rendered":"<p>Just the script:<\/p>\n<blockquote><p>#!\/bin\/sh<br \/>\ncd \/usr\/local\/etc<br \/>\nS0=`\/usr\/local\/etc\/digitemp_DS9097 -t 0 -q -s \/dev\/cuau0 -o\\%.C`<br \/>\n#date=`date -j +&#8221;%Y-%m-%d %H:%M:%S`<br \/>\n#echo &#8220;&lt;tr&gt;&lt;td align=center&gt;Temperature for $date&lt;\/td&gt;&lt;\/tr&gt;&lt;\/table&gt;&lt;\/div&gt;&#8221; &gt;&gt; \/usr\/local\/www\/temp\/index.html<br \/>\ntmp1=`cat \/tmp\/temp.tmp`<br \/>\nflag=`expr $S0 &#8211; $tmp1`<br \/>\necho $S0 &gt; \/tmp\/temp.tmp<\/p>\n<p># Prepare a mail<br \/>\necho &#8220;To: admin@domain.com&#8221; &gt; mail.txt<br \/>\necho &#8220;From: admin@domain.com&#8221; &gt;&gt; mail.txt<br \/>\necho &#8220;Subject: Server room = $S0&#8221; &gt;&gt; mail.txt<br \/>\necho &#8220;text&#8221; &gt;&gt; mail.txt<\/p>\n<p>if [ $S0 -eq 85 ]; then<br \/>\n$S0=$tmp1<br \/>\nfi<\/p>\n<p>if [ $flag -ge 1 ]; then<br \/>\nif [ $S0 -ge 30 ]; then<br \/>\n\/usr\/local\/sbin\/ssmtp admin@domain.com &lt; \/usr\/local\/etc\/mail.txt<br \/>\nfi<br \/>\nfi<\/p>\n<p>echo &#8220;Flag = $flag tmp = $tmp1 s0 = $S0&#8221;<\/p>\n<p>\/usr\/local\/bin\/rrdtool update \/var\/db\/rrd\/temp_all.rrd N:$S0<br \/>\necho $S0<\/p>\n<p>WWWPREFIX=\/usr\/local\/www\/images<br \/>\nRRDPREFIX=\/var\/db\/rrd<br \/>\n\/usr\/local\/bin\/rrdtool graph $WWWPREFIX\/temp_all.png \\<br \/>\n&#8211;width 500 &#8211;height 300 &#8211;imgformat PNG \\<br \/>\n&#8211;title &#8220;Temperature for 12h&#8221;\u00a0 &#8211;rigid\u00a0 &#8211;color BACK#FAFAFA\u00a0 \\<br \/>\n&#8211;vertical-label Celsius \\<br \/>\n&#8211;upper-limit 35 \\<br \/>\n&#8211;lower-limit 15 \\<br \/>\n&#8211;slope-mode \\<br \/>\nDEF:S0=$RRDPREFIX\/temp_all.rrd:S0:MAX \\<br \/>\nVDEF:cur0=S0,LAST \\<br \/>\nLINE3:S0#006500:&#8221;ServerRoom\u00a0\u00a0\u00a0 &#8221; \\<br \/>\nAREA:S0#00640080:&#8221;Temperature&#8221; \\<br \/>\nGPRINT:cur0:&#8221;S0=%2.0lf\\n&#8221; \\<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Just the script: #!\/bin\/sh cd \/usr\/local\/etc S0=`\/usr\/local\/etc\/digitemp_DS9097 -t 0 -q -s \/dev\/cuau0 -o\\%.C` #date=`date -j +&#8221;%Y-%m-%d %H:%M:%S` #echo &#8220;&lt;tr&gt;&lt;td align=center&gt;Temperature for $date&lt;\/td&gt;&lt;\/tr&gt;&lt;\/table&gt;&lt;\/div&gt;&#8221; &gt;&gt; \/usr\/local\/www\/temp\/index.html tmp1=`cat \/tmp\/temp.tmp` flag=`expr $S0 &#8211; $tmp1` echo $S0 &gt; \/tmp\/temp.tmp # Prepare a mail echo &#8220;To: admin@domain.com&#8221; &gt; mail.txt echo &#8220;From: admin@domain.com&#8221; &gt;&gt; mail.txt echo &#8220;Subject: Server room = $S0&#8221; &gt;&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6,13],"tags":[],"class_list":["post-596","post","type-post","status-publish","format-standard","hentry","category-freebsd","category-linux","category-novosti"],"_links":{"self":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=596"}],"version-history":[{"count":2,"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/596\/revisions"}],"predecessor-version":[{"id":598,"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/596\/revisions\/598"}],"wp:attachment":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}