{"id":3301,"date":"2021-07-12T00:07:13","date_gmt":"2021-07-11T15:07:13","guid":{"rendered":"http:\/\/matoken.org\/blog\/?p=3301"},"modified":"2021-07-12T00:08:48","modified_gmt":"2021-07-11T15:08:48","slug":"output-acpid-log-to-syslog-part-2-acpi-event-action","status":"publish","type":"post","link":"https:\/\/matoken.org\/blog\/2021\/07\/12\/output-acpid-log-to-syslog-part-2-acpi-event-action\/","title":{"rendered":"Debian\u74b0\u5883\u3067acpid\u306e\u30ed\u30b0\u3092syslog\u306b\u51fa\u529b\u3059\u308b2(acpi event &#038; action)"},"content":{"rendered":"<div class=\"paragraph\">\n<p>acpid\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u3059\u3079\u3066\u30ed\u30b0\u306b\u51fa\u529b\u3067\u304d\u308b\u3088\u3046\u8a2d\u5b9a\u3057\u307e\u3057\u305f\uff0e<\/p>\n<\/div>\n<div class=\"ulist\">\n<ul>\n<li><a href=\"https:\/\/matoken.org\/blog\/2021\/07\/11\/output-acpid-log-to-syslog\/\">Debian\u74b0\u5883\u3067acpid\u306e\u30ed\u30b0\u3092syslog\u306b\u51fa\u529b\u3059\u308b \u2013 matoken\u2019s meme<\/a><\/li>\n<\/ul>\n<\/div>\n<div class=\"paragraph\">\n<p>\u3057\u304b\u3057\u3061\u3087\u3063\u3068\u5197\u9577\u3067\u3059\uff0eAC\u30a2\u30c0\u30d7\u30bf\u306e\u72b6\u6cc1\u3060\u3051\u3092\u30ed\u30ae\u30f3\u30b0\u3059\u308b\u3088\u3046\u8a2d\u5b9a\u3057\u3066\u307f\u307e\u3057\u305f\uff0e<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><!--more--><\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>\u307e\u305aAC\u30a2\u30c0\u30d7\u30bf\u306e\u629c\u304d\u5dee\u3057\u6642\u306e\u30ed\u30b0\u3092\u78ba\u8a8d\u3057\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\">AC\u30a2\u30c0\u30d7\u30bf\u5207\u65ad\u6642<\/div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-log\" data-lang=\"log\">Jul 11 23:05:51 yoga-260 acpid: completed netlink event \"ac_adapter ACPI0003:00 00000080 00000000\"<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\">AC\u30a2\u30c0\u30d7\u30bf\u63a5\u7d9a\u6642<\/div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-log\" data-lang=\"log\">Jul 11 23:05:55 yoga-260 acpid: received netlink event \"ac_adapter ACPI0003:00 00000080 00000001\"<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>man\u306eEXAMPLE \u3092\u78ba\u8a8d\u3057\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"quoteblock\">\n<div class=\"title\">man acpid\u3088\u308a<\/div>\n<blockquote>\n<div class=\"paragraph\">\n<p>EXAMPLE<br \/>\nThis example will shut down your system if you press the power button.<\/p>\n<\/div>\n<div class=\"literalblock\">\n<div class=\"content\">\n<pre>Create a file named \/etc\/acpi\/events\/power that contains the following:<\/pre>\n<\/div>\n<\/div>\n<div class=\"literalblock\">\n<div class=\"content\">\n<pre>event=button\/power\naction=\/etc\/acpi\/power.sh \"%e\"<\/pre>\n<\/div>\n<\/div>\n<div class=\"literalblock\">\n<div class=\"content\">\n<pre>Then create a file named \/etc\/acpi\/power.sh that contains the following:<\/pre>\n<\/div>\n<\/div>\n<div class=\"literalblock\">\n<div class=\"content\">\n<pre>\/sbin\/shutdown -h now \"Power button pressed\"<\/pre>\n<\/div>\n<\/div>\n<div class=\"literalblock\">\n<div class=\"content\">\n<pre>Now,  when  acpid  is  running,  a  press  of  the power button will cause the rule in \/etc\/acpi\/events\/power to trigger the script in\n\/etc\/acpi\/power.sh.  The script will then shut down the system.<\/pre>\n<\/div>\n<\/div>\n<\/blockquote>\n<\/div>\n<div class=\"paragraph\">\n<p>\u3053\u306eEXAMPLE\u3092\u771f\u4f3c\u3057\u3066\u3053\u3093\u306a\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\uff0eacpid\u304b\u3089 <code>ac_adapter<\/code> \u306e\u30a4\u30d9\u30f3\u30c8\u5b9f\u884c\u6642\u306baction \u306b\u6307\u5b9a\u3055\u308c\u305fscript \u3092\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\">\/etc\/acpi\/events\/ac_event_logging<\/div>\n<div class=\"content\">\n<pre class=\"highlight\"><code>event=ac_adapter\naction=\/etc\/acpi\/ac_event_logging.sh %e<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>\u305d\u3057\u3066\u547c\u3073\u51fa\u3055\u308c\u308bscript \u3068\u3057\u3066\u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u610f\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\">\/etc\/acpi\/ac_event_logging.sh<\/div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-shell\" data-lang=\"shell\">#!\/bin\/sh\ncase \"$4\" in\n        00000000)\n                echo 'AC offline'\n                logger -t acpid AC offline\n                ;;\n        00000001)\n                echo 'AC online'\n                logger -t acpid AC online\n                ;;\nesac<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>\u3053\u306escript\u306b\u306f\u5b9f\u884c\u6a29\u3082\u4ed8\u4e0e\u3057\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-shell\" data-lang=\"shell\">$ sudo chmod +x \/etc\/acpi\/ac_event_logging.sh<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>\u52d5\u4f5c\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b acpid \u3092\u518d\u8d77\u52d5\u3057\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-shell\" data-lang=\"shell\">$ sudo service acpid restart<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>\u3053\u306e\u72b6\u614b\u3067AC\u30a2\u30c0\u30d7\u30bf\u3092\u629c\u304d\u5dee\u3057\u3059\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u306e\u30ed\u30b0\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\"><code>$ sudo tail -f \/var\/log\/syslog | grep acpid:<\/code><\/div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-log\" data-lang=\"log\">Jul 11 23:51:10 yoga-260 acpid: received netlink event \"battery PNP0C0A:00 00000080 00000001\"\nJul 11 23:51:10 yoga-260 acpid: 0 total rules matched\nJul 11 23:51:10 yoga-260 acpid: completed netlink event \"battery PNP0C0A:00 00000080 00000001\"\nJul 11 23:51:10 yoga-260 acpid: received netlink event \"ac_adapter ACPI0003:00 00000080 00000000\" <b class=\"conum\">(1)<\/b>\nJul 11 23:51:10 yoga-260 acpid: rule from \/etc\/acpi\/events\/ac_event_logging matched <b class=\"conum\">(2)<\/b>\nJul 11 23:51:10 yoga-260 acpid: executing action \"\/etc\/acpi\/ac_event_logging.sh ac_adapter ACPI0003:00 00000080 00000000\" <b class=\"conum\">(3)<\/b>\nJul 11 23:51:10 yoga-260 acpid: AC offline <b class=\"conum\">(4)<\/b>\nJul 11 23:51:10 yoga-260 acpid: action exited with status 0 <b class=\"conum\">(5)<\/b>\nJul 11 23:51:10 yoga-260 acpid: 1 total rule matched\nJul 11 23:51:10 yoga-260 acpid: completed netlink event \"ac_adapter ACPI0003:00 00000080 00000000\"\nJul 11 23:51:11 yoga-260 acpid: received netlink event \"ibm\/hotkey LEN0068:00 00000080 00006030\"\nJul 11 23:51:11 yoga-260 acpid: 0 total rules matched\nJul 11 23:51:11 yoga-260 acpid: completed netlink event \"ibm\/hotkey LEN0068:00 00000080 00006030\"\nJul 11 23:51:11 yoga-260 acpid: received netlink event \"thermal_zone LNXTHERM:00 00000081 00000000\"\nJul 11 23:51:11 yoga-260 acpid: 0 total rules matched\nJul 11 23:51:11 yoga-260 acpid: completed netlink event \"thermal_zone LNXTHERM:00 00000081 00000000\"\nJul 11 23:51:12 yoga-260 acpid: received netlink event \"battery PNP0C0A:00 00000080 00000001\"\nJul 11 23:51:12 yoga-260 acpid: 0 total rules matched\nJul 11 23:51:12 yoga-260 acpid: completed netlink event \"battery PNP0C0A:00 00000080 00000001\"\nJul 11 23:51:13 yoga-260 acpid: received netlink event \"ac_adapter ACPI0003:00 00000080 00000001\"\nJul 11 23:51:13 yoga-260 acpid: rule from \/etc\/acpi\/events\/ac_event_logging matched\nJul 11 23:51:13 yoga-260 acpid: executing action \"\/etc\/acpi\/ac_event_logging.sh ac_adapter ACPI0003:00 00000080 00000001\"\nJul 11 23:51:13 yoga-260 acpid: AC online\nJul 11 23:51:13 yoga-260 acpid: action exited with status 0\nJul 11 23:51:13 yoga-260 acpid: 1 total rule matched\nJul 11 23:51:13 yoga-260 acpid: completed netlink event \"ac_adapter ACPI0003:00 00000080 00000001\"\nJul 11 23:51:13 yoga-260 acpid: received netlink event \"ibm\/hotkey LEN0068:00 00000080 00006030\"\nJul 11 23:51:13 yoga-260 acpid: 0 total rules matched\nJul 11 23:51:13 yoga-260 acpid: completed netlink event \"ibm\/hotkey LEN0068:00 00000080 00006030\"\nJul 11 23:51:13 yoga-260 acpid: received netlink event \"thermal_zone LNXTHERM:00 00000081 00000000\"\nJul 11 23:51:13 yoga-260 acpid: 0 total rules matched\nJul 11 23:51:13 yoga-260 acpid: completed netlink event \"thermal_zone LNXTHERM:00 00000081 00000000\"<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"colist arabic\">\n<ol>\n<li>AC\u30a2\u30c0\u30d7\u30bf\u5207\u65ad\u306e\u30ed\u30b0<\/li>\n<li>AC\u30a2\u30c0\u30d7\u30bf\u7528\u306eevent\u3092\u898b\u3064\u3051\u308b<\/li>\n<li>AC\u30a2\u30c0\u30d7\u30bf\u30ed\u30ae\u30f3\u30b0\u7528\u306escript\u3092%e \u3092\u4f7f\u3063\u3066\u5f15\u6570\u3092\u6e21\u3057\u3064\u3064\u5b9f\u884c<\/li>\n<li>\u30ed\u30ae\u30f3\u30b0\u7528\u306escript\u3067\u30ed\u30b0\u3092\u51fa\u529b<\/li>\n<li>action\u7d42\u4e86<\/li>\n<\/ol>\n<\/div>\n<div class=\"paragraph\">\n<p>\u3046\u307e\u304f\u884c\u3063\u305f\u3088\u3046\u3067\u3059 :)<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u4ed6\u306e\u30a4\u30d9\u30f3\u30c8\u30ed\u30b0\u3092\u8981\u3089\u306a\u3044\u306e\u3067\uff0c <code>\/etc\/default\/acpid<\/code> \u3092\u7de8\u96c6\u3057\u3066\u5f15\u6570\u3092\u6d88\u3057\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>--- a\/default\/acpid\n+++ b\/default\/acpid\n@@ -1,7 +1,7 @@\n # Options to pass to acpid\n #\n # OPTIONS are appended to the acpid command-line\n-OPTIONS=\"-l\"\n+#OPTIONS=\"-l\"\n\n # Linux kernel modules to load before starting acpid\n #<\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>\u53cd\u6620\u3059\u308b\u305f\u3081\u306b acpid \u3092\u518d\u8d77\u52d5\u3057\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-shell\" data-lang=\"shell\">$ sudo service acpid restart\n$ ps aux | grep [\/]sbin\/acpid\nroot     3990040  0.0  0.0   2352   780 ?        Ss   23:59   0:00 \/usr\/sbin\/acpid<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>\u518d\u5ea6\u30ed\u30b0\u3092\u78ba\u8a8d\u3057\u306a\u304c\u3089AC\u30a2\u30c0\u30d7\u30bf\u306e\u629c\u304d\u5dee\u3057\u3092\u3057\u3066\u30ed\u30b0\u304c\u5fc5\u8981\u306a\u3082\u306e\u3060\u3051\u51fa\u529b\u3055\u308c\u3066\u3044\u308b\u306e\u3092\u78ba\u8a8d\u3057\u307e\u3057\u305f\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\"><code>sudo tail -f \/var\/log\/syslog | grep acpid:<\/code><\/div>\n<div class=\"content\">\n<pre>Jul 12 00:00:04 yoga-260 acpid: AC offline\nJul 12 00:00:07 yoga-260 acpid: AC online<\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>\u826f\u3055\u305d\u3046\u3067\u3059 :)<br \/>\n\u30b5\u30b9\u30da\u30f3\u30c9\u30ec\u30b8\u30e5\u30fc\u30e0\u3082\u8a2d\u5b9a\u3057\u3066\u307f\u3088\u3046\u304b\u306a?<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\">\u74b0\u5883<\/div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-shell\" data-lang=\"shell\">$ dpkg-query -W acpid rsyslog systemd bsdutils\nacpid   1:2.0.32-1\nbsdutils        1:2.36.1-7\nrsyslog 8.2102.0-2\nsystemd 247.3-5\n$ lsb_release -dr\nDescription:    Debian GNU\/Linux 11 (bullseye)\nRelease:        11\n$ arch\nx86_64\n$ sudo lshw | grep -E '^\\ \\ \\ \\ product:|^\\ \\ \\ \\ version:'\n    product: 20FEA02WJP (LENOVO_MT_20FE_BU_Think_FM_ThinkPad Yoga 260)\n    version: ThinkPad Yoga 260<\/code><\/pre>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>acpid\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u3059\u3079\u3066\u30ed\u30b0\u306b\u51fa\u529b\u3067\u304d\u308b\u3088\u3046\u8a2d\u5b9a\u3057\u307e\u3057\u305f\uff0e Debian\u74b0\u5883\u3067acpid\u306e\u30ed\u30b0\u3092syslog\u306b\u51fa\u529b\u3059\u308b \u2013 matoken\u2019s meme \u3057\u304b\u3057\u3061\u3087\u3063\u3068\u5197\u9577\u3067\u3059\uff0eAC\u30a2\u30c0\u30d7\u30bf\u306e\u72b6\u6cc1\u3060\u3051\u3092\u30ed\u30ae\u30f3\u30b0\u3059\u308b\u3088 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"webmentions_disabled_pings":false,"webmentions_disabled":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[658,7,6,90],"tags":[617,674,194],"class_list":["post-3301","post","type-post","status-publish","format-standard","hentry","category-bullseye","category-debian-linux","category-linux","category-testing","tag-acpi","tag-acpid","tag-power"],"_links":{"self":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts\/3301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/comments?post=3301"}],"version-history":[{"count":0,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts\/3301\/revisions"}],"wp:attachment":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/media?parent=3301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/categories?post=3301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/tags?post=3301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}