{"id":266082,"date":"2015-09-21T18:16:02","date_gmt":"2015-09-21T14:16:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=266082"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=266082","title":{"rendered":"SMS \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043e \u043f\u0435\u0440\u0435\u0431\u043e\u0435 \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Asterisk + Dongle \u0438 apcupsd"},"content":{"rendered":"<p>       \u041d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e \u0441\u043c\u0441 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u0447\u0435\u0437\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0438 \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u0415\u0441\u0442\u044c Freebsd \u0434\u0435\u043c\u043e\u043d apcupsd \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0418\u0411\u041f APC \u0438 asterisk \u0441 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u043a \u043d\u0435\u043c\u0443 GSM \u043c\u043e\u0434\u0435\u043c\u0430\u043c\u0438.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0434\u0430\u043d\u043d\u044b\u0439 \u0434\u0435\u043c\u043e\u043d \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0418\u0411\u041f \u0441\u0442\u043e\u0438\u0442 \u043d\u0430 \u0442\u043e\u0439 \u0436\u0435 \u043c\u0430\u0448\u0438\u043d\u0435 \u0447\u0442\u043e \u0438 \u0430\u0441\u0442\u0435\u0440\u0438\u0441\u043a, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<pre><code class=\"bash\">#!\/usr\/local\/bin\/bash  \/usr\/local\/sbin\/asterisk -rx &quot;dongle sms KS_out +380501111234 Power fackup&quot; <\/code><\/pre>\n<p>  \u041d\u043e \u0443 \u043c\u0435\u043d\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0418\u0411\u041f \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0442\u0443\u0442 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 AMI Asterisk.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c AMI \u0438 \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0412 \u0444\u0430\u0439\u043b \/etc\/asterisk\/manager.conf:<\/p>\n<pre><code class=\"bash\">[general] enabled = yes port = 5038 bindaddr = 0.0.0.0 <\/code><\/pre>\n<p>  \/etc\/asterisk\/manager.conf<\/p>\n<pre><code class=\"bash\">[admin] secret=FrUyHn6FSaX deny=0.0.0.0\/0.0.0.0 permit=192.168.0.0\/255.255.0.0 read=system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate write=system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c reload:<br \/>  <code>asterisk -rx &quot;module reload manager&quot;<\/code><\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0432\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430 \u0431\u0430\u0437\u0435 PHP. \u041e\u0441\u043d\u043e\u0432\u0430 \u0432\u0437\u044f\u0442\u0430 <a href=\"http:\/\/habrahabr.ru\/company\/centosadmin\/blog\/161521\/\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>.<\/p>\n<p>  poweroff.php:<\/p>\n<pre><code class=\"php\">&lt;?php  # \u2014- define globals \u2014- $strhost = &quot;192.168.1.6&quot;; $strport = &quot;5038&quot;; $timeout = &quot;10&quot;; $d=date(DATE_RFC822); $errno=0 ; $errstr=0 ;  $sconn = fsockopen ($strhost, $strport, &$errno, &$errstr, $timeout) or die(&quot;Connection to $strhost:$strport failed&quot;);  if (!$sconn) { echo &quot;$errstr ($errno)&lt;br&gt;\\n&quot;; }  else {  fputs ($sconn, &quot;Action: login\\r\\n&quot;); fputs ($sconn, &quot;Username: admin\\r\\n&quot;); fputs ($sconn, &quot;Secret: FrUyHn6FSaX\\r\\n&quot;); fputs ($sconn, &quot;Events: on\\r\\n\\r\\n&quot;); usleep(1000); fputs ($sconn, &quot;Action: Command\\r\\n&quot;); fputs ($sconn, &quot;Command: dongle sms MTS_out +380661111234 Power failure. $d \\r\\n&quot;); fputs ($sconn, &quot;Action: Logoff\\r\\n\\r\\n&quot;); usleep (500);  fclose ($sconn);  } <\/code><\/pre>\n<p>  \u0418 poweron.php:<\/p>\n<pre><code class=\"php\">&lt;?php  # \u2014- define globals \u2014- $strhost = &quot;192.168.1.6&quot;; $strport = &quot;5038&quot;; $timeout = &quot;10&quot;; $d=date(DATE_RFC822); $errno=0 ; $errstr=0 ;  $sconn = fsockopen ($strhost, $strport, &$errno, &$errstr, $timeout) or die(&quot;Connection to $strhost:$strport failed&quot;);  if (!$sconn) { echo &quot;$errstr ($errno)&lt;br&gt;\\n&quot;; }  else {  fputs ($sconn, &quot;Action: login\\r\\n&quot;); fputs ($sconn, &quot;Username: admin\\r\\n&quot;); fputs ($sconn, &quot;Secret: FrUyHn6FSaX\\r\\n&quot;); fputs ($sconn, &quot;Events: on\\r\\n\\r\\n&quot;); usleep(1000); fputs ($sconn, &quot;Action: Command\\r\\n&quot;); fputs ($sconn, &quot;Command: dongle sms MTS_out +380661111234 Power is back. $d \\r\\n&quot;); fputs ($sconn, &quot;Action: Logoff\\r\\n\\r\\n&quot;); usleep (500);  fclose ($sconn);  }  <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c <\/p>\n<p>  <code># cd \/usr\/local\/etc\/apcupsd\/<\/code><\/p>\n<p>  \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430<b> onbattery<\/b> \u2014 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043d\u0430 \u0431\u0430\u0442\u0430\u0440\u0435\u044e \u0438<b> offbattery<\/b> \u2014 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0438\u0442\u0430\u043d\u0438\u0435.<br \/>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430: <\/p>\n<p>  <code>\/usr\/local\/bin\/php -f \/root\/scripts\/poweroff.php<\/code><\/p>\n<p>  \u0438 \u0442\u0430\u043a \u0436\u0435 \u0434\u043b\u044f poweron.php<\/p>\n<p>  <code>\/usr\/local\/bin\/php -f \/root\/scripts\/poweron.php<\/code><\/p>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0418\u0411\u041f \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u043e\u0442 \u0431\u0430\u0442\u0430\u0440\u0435\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441\u043c\u0441 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u00abPower failure. Wed, 05 Jun 13 15:53:59 +0300.<\/p>\n<p>  \u0418 \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u043c\u0441 \u043f\u0440\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043f\u0438\u0442\u0430\u043d\u0438\u044f.               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/267353\/\"> http:\/\/habrahabr.ru\/post\/267353\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e \u0441\u043c\u0441 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u0447\u0435\u0437\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0438 \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u0415\u0441\u0442\u044c Freebsd \u0434\u0435\u043c\u043e\u043d apcupsd \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0418\u0411\u041f APC \u0438 asterisk \u0441 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u043a \u043d\u0435\u043c\u0443 GSM \u043c\u043e\u0434\u0435\u043c\u0430\u043c\u0438.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-266082","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266082","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=266082"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266082\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}