{"id":2992,"date":"2014-10-27T16:53:31","date_gmt":"2014-10-27T14:53:31","guid":{"rendered":"http:\/\/supportex.net\/blog\/?p=2992"},"modified":"2019-05-10T14:14:12","modified_gmt":"2019-05-10T12:14:12","slug":"sending-alerts-php-fatal-errors","status":"publish","type":"post","link":"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/","title":{"rendered":"Sending alerts for PHP fatal errors"},"content":{"rendered":"<p>If you need to send alerts for PHP errors or some other error messages you can use <a href=\"http:\/\/simple-evcorr.sourceforge.net\">SEC <\/a> \u2013<strong> simple event correlator<\/strong>. Here&#8217;s how you can do that. It&#8217;s assumed that you use php-fpm \/ nginx setup on Centos 6.5, but it should work on Debian\/Ubuntu as well.<\/p>\n<p>Let&#8217;s suppose your PHP log is in <em>\/var\/log\/php-fpm\/example.com-error.log<\/em>. Make sure you have\u00a0<em>catch_workers_output = yes<\/em> in your php-fpm configuration file so PHP errors go to a dedicated file.<\/p>\n<p>We need to install <strong>sec<\/strong>. Basically it&#8217;s a Perl script (~11k lines of code!), but we will install it from rpm with yum.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">yum install sec<\/code><\/p>\n<p>Now we need to creare a configuration files for it. Put this to\u00a0\/etc\/sec\/php.conf:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">type=Single\nptype=RegExp\npattern=^\\[.+\\] PHP Fatal error.+$\ndesc=PHP error\naction=add nginx-php-errors $0\n\ntype=Calendar\ntime=* * * * *\ndesc=Mail web errors\ncontext=nginx-php-errors\naction=report nginx-php-errors \/bin\/mail -s \"example.com\u00a0PHP errors\" admin@example.com; delete nginx-php-errors;\n\n<\/pre>\n<p>Now add the following line to\u00a0\/etc\/sysconfig\/sec:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">SEC_ARGS[0]=\"-detach --conf=\/etc\/sec\/php.conf --input=\/var\/log\/php-fpm\/example.com-error.log -log=\/var\/log\/sec -intevents -pid=\/var\/run\/sec.pid --debug=6\"<\/code><\/p>\n<p>If you need to monitor more than one log, you can add similar line:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">SEC_ARGS[1]=\"-detach --conf=\/etc\/sec\/php2.conf --input=\/var\/log\/php-fpm\/example2.com-error.log -log=\/var\/log\/sec -intevents -pid=\/var\/run\/sec2.pid --debug=6\"<\/code><\/p>\n<p>Start it:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">service sec start<\/code><\/p>\n<p>And wait. <strong>SEC<\/strong> will send you a notification when there&#8217;s a fatal error.<br \/>\nIt uses a regular expression to find what it needs to send. So you can use it for more complex setups, like application logs or web server access logs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you need to send alerts for PHP errors or some other error messages you can use SEC \u2013 simple event correlator. Here&#8217;s how you can do that. It&#8217;s assumed that you use php-fpm \/ nginx setup on Centos 6.5, but it should work on Debian\/Ubuntu as well. Let&#8217;s suppose your PHP log is in&hellip; <\/p>\n<div class=\"readmore-wrapper\"><a href=\"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/\" class=\"more-link\">Read <\/a><\/div>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[152],"tags":[275,160,161,159],"class_list":["post-2992","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux","tag-logs","tag-monitoring","tag-sec"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Sending alerts for PHP fatal errors &#8211; Supportex.NET blog<\/title>\n<meta name=\"description\" content=\"SEC tool help you processing PHP fatal errors. With SEC you can send PHP fatal errors to your log file.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Sending alerts for PHP fatal errors &#8211; Supportex.NET blog\" \/>\n<meta property=\"og:description\" content=\"SEC tool help you processing PHP fatal errors. With SEC you can send PHP fatal errors to your log file.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/\" \/>\n<meta property=\"og:site_name\" content=\"Supportex.NET blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-10-27T14:53:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-10T12:14:12+00:00\" \/>\n<meta name=\"author\" content=\"Oleksii Tykhonov\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Oleksii Tykhonov\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/\"},\"author\":{\"name\":\"Oleksii Tykhonov\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\"},\"headline\":\"Sending alerts for PHP fatal errors\",\"datePublished\":\"2014-10-27T14:53:31+00:00\",\"dateModified\":\"2019-05-10T12:14:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/\"},\"wordCount\":198,\"commentCount\":0,\"keywords\":[\"linux\",\"logs\",\"monitoring\",\"sec\"],\"articleSection\":[\"linux\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/\",\"url\":\"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/\",\"name\":\"Sending alerts for PHP fatal errors &#8211; Supportex.NET blog\",\"isPartOf\":{\"@id\":\"https:\/\/supportex.net\/blog\/en\/#website\"},\"datePublished\":\"2014-10-27T14:53:31+00:00\",\"dateModified\":\"2019-05-10T12:14:12+00:00\",\"author\":{\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\"},\"description\":\"SEC tool help you processing PHP fatal errors. With SEC you can send PHP fatal errors to your log file.\",\"breadcrumb\":{\"@id\":\"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/supportex.net\/blog\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Sending alerts for PHP fatal errors\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#website\",\"url\":\"https:\/\/supportex.net\/blog\/en\/\",\"name\":\"Supportex.NET blog\",\"description\":\"Server and network management company\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/supportex.net\/blog\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\",\"name\":\"Oleksii Tykhonov\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g\",\"caption\":\"Oleksii Tykhonov\"},\"url\":\"https:\/\/supportex.net\/blog\/author\/oleksiitykhonov\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Sending alerts for PHP fatal errors &#8211; Supportex.NET blog","description":"SEC tool help you processing PHP fatal errors. With SEC you can send PHP fatal errors to your log file.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/","og_locale":"en_US","og_type":"article","og_title":"Sending alerts for PHP fatal errors &#8211; Supportex.NET blog","og_description":"SEC tool help you processing PHP fatal errors. With SEC you can send PHP fatal errors to your log file.","og_url":"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/","og_site_name":"Supportex.NET blog","article_published_time":"2014-10-27T14:53:31+00:00","article_modified_time":"2019-05-10T12:14:12+00:00","author":"Oleksii Tykhonov","twitter_misc":{"Written by":"Oleksii Tykhonov","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/#article","isPartOf":{"@id":"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/"},"author":{"name":"Oleksii Tykhonov","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251"},"headline":"Sending alerts for PHP fatal errors","datePublished":"2014-10-27T14:53:31+00:00","dateModified":"2019-05-10T12:14:12+00:00","mainEntityOfPage":{"@id":"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/"},"wordCount":198,"commentCount":0,"keywords":["linux","logs","monitoring","sec"],"articleSection":["linux"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/","url":"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/","name":"Sending alerts for PHP fatal errors &#8211; Supportex.NET blog","isPartOf":{"@id":"https:\/\/supportex.net\/blog\/en\/#website"},"datePublished":"2014-10-27T14:53:31+00:00","dateModified":"2019-05-10T12:14:12+00:00","author":{"@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251"},"description":"SEC tool help you processing PHP fatal errors. With SEC you can send PHP fatal errors to your log file.","breadcrumb":{"@id":"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/supportex.net\/blog\/2014\/10\/sending-alerts-php-fatal-errors\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/supportex.net\/blog\/en\/"},{"@type":"ListItem","position":2,"name":"Sending alerts for PHP fatal errors"}]},{"@type":"WebSite","@id":"https:\/\/supportex.net\/blog\/en\/#website","url":"https:\/\/supportex.net\/blog\/en\/","name":"Supportex.NET blog","description":"Server and network management company","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/supportex.net\/blog\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251","name":"Oleksii Tykhonov","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g","caption":"Oleksii Tykhonov"},"url":"https:\/\/supportex.net\/blog\/author\/oleksiitykhonov\/"}]}},"_links":{"self":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/2992","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/comments?post=2992"}],"version-history":[{"count":6,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/2992\/revisions"}],"predecessor-version":[{"id":3114,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/2992\/revisions\/3114"}],"wp:attachment":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/media?parent=2992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/categories?post=2992"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/tags?post=2992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}