{"id":3051,"date":"2009-07-30T09:30:49","date_gmt":"2009-07-30T08:30:49","guid":{"rendered":"http:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/?p=3051"},"modified":"2009-07-30T09:30:49","modified_gmt":"2009-07-30T08:30:49","slug":"highly-sophisticated-wakeup-call-using-nagios","status":"publish","type":"post","link":"https:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/2009\/07\/highly-sophisticated-wakeup-call-using-nagios\/","title":{"rendered":"Highly sophisticated wakeup call using nagios"},"content":{"rendered":"<p>Hi there!<\/p>\n<p><a href=\"http:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/wp-content\/uploads\/2009\/07\/wecker.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3071 alignleft\" title=\"wecker\" src=\"http:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/wp-content\/uploads\/2009\/07\/wecker.png\" alt=\"wecker\" width=\"150\" height=\"300\" \/><\/a>Do you know this problem?! You have to get up at some certain time in the morning, so you set up your alarm clock to give you a friendly &#8220;rrrrrrring-rrrrring&#8221;. But you simply don&#8217;t wake up! Your alarm clock rings and rings and rings for like hours but you simply don&#8217;t hear it. Sometimes, you use the snooze button, but you cannot even remember you did it.<\/p>\n<p>Well, that&#8217;s like how I feel sometimes in the morning. Bad thing, if you have some kind of meeting or appointment. Several times in the past, I sent automated e-mails to my co-workers to give me a wakeup call on my cellphone, this surprisingly always works. But it&#8217;s annoying. For me and my co-workers.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Here comes the solution:<\/span><\/strong><\/p>\n<p><strong>use nagios to give you a highly sophisticated wakeup call.<\/strong><\/p>\n<p>Imagine, you have a <strong>linux box<\/strong> which is under surveillance of a <strong>nagios remote monitoring system<\/strong>. And imagine furthermore, this nagios system is <strong>configured to send out voice calls<\/strong> in cases of critical states. All you need is a new plugin (most commonly via NRPE) which tells nagios to\u00a0initiate your wakeup call.<\/p>\n<p><span style=\"text-decoration: underline;\">This is how I do it:<\/span><\/p>\n<p>1. Add the following line to your NRPE config file on your linux box (e. g. <code>\/etc\/nagios\/nrpe.cfg<\/code>):<\/p>\n<pre class=\"brush: bash\">command[wakeupcall]=\/usr\/lib\/nagios\/plugins\/wakeupcall<\/pre>\n<p>2. Create the plugin and place it\u00a0on your linux box at <code>\/usr\/lib\/nagios\/plugins\/wakeupcall<\/code><\/p>\n<pre class=\"brush: bash\">#!\/bin\/bash\r\n#\r\n# nagios nrpe plugin to initiate a wakeup call\r\n# 2009, Thomas Gericke, thomas (at) thomasgericke (dot) de\r\n#\r\n\r\nFILE=&quot;\/etc\/wakeupcall\/wakeupcall&quot;\r\n\r\nif [ -e $FILE ]; then\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo &quot;Wakeupcall needed. Gonna hit ya!&quot;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 exit 2\r\nelse\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo &quot;No wakeupcall needed. Sleep well.&quot;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 exit 0\r\nfi<\/pre>\n<p>3. Restart your NRPE service on your linux box (e. g. <code>\/etc\/init.d\/nagios-nrpe-server restart<\/code>)<\/p>\n<p>4. Set up the service check in your nagios configuration on your nagios server<\/p>\n<p>I assume, you already have the host configured on your nagios system and you already are familiar with nagios&#8217; notifications. Here&#8217;s the service check you need:<\/p>\n<pre class=\"brush: bash\">define service {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 use\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 generic-service\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 max_check_attempts\u00a0\u00a0\u00a0\u00a0\u00a0 1\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 notification_options\u00a0\u00a0\u00a0 c\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 service_description\u00a0\u00a0\u00a0\u00a0 Wakeup Call\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 host_name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0YOUR.HOST.NAME\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 check_command\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 check_nrpe!wakeupcall\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 contact_groups\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 YOUR_CONTACT_GROUP\r\n}<\/pre>\n<p>I hope you&#8217;re familiar with nagios&#8217; service check templates and such stuff.<\/p>\n<p>5. Reload your nagios on your nagios server (e. g. <code>\/etc\/init.d\/nagios reload<\/code>)<\/p>\n<p>6. Create the wakeupcall config directory on your linux box (<code>mkdir \/etc\/wakeupcall\/<\/code>)<\/p>\n<p>7. Set up a file for an at-job on your linux box (e. g. <code>~\/add.wakeupcall<\/code>)<\/p>\n<pre class=\"brush: bash\">touch \/etc\/wakeupcall\/wakeupcall<\/pre>\n<p>8. Set up an at-job on your linux box once you need to be woken up<\/p>\n<pre class=\"brush: bash\">at -f ~\/add.wakeupcall 06:40<\/pre>\n<p>Your linux box will create <code>\/etc\/wakeupcall\/wakeupcall<\/code> <strong>at 6.40AM<\/strong> (the very next time this moment occurs), nagios will realize it and will initiate the notification. If you have configured your nagios server to send out voice calls to your cellphone, you will receive a <strong>wakeup call<\/strong>.<\/p>\n<p>Have fun, comments are appreciated! \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi there! Do you know this problem?! You have to get up at some certain time in the morning, so you set up your alarm clock to give you a friendly &#8220;rrrrrrring-rrrrring&#8221;. But you simply don&#8217;t wake up! Your alarm clock rings and rings and rings for like hours but you simply don&#8217;t hear it. [&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,"ngg_post_thumbnail":0,"footnotes":""},"categories":[4,11],"tags":[421,61,431,151,101],"class_list":["post-3051","post","type-post","status-publish","format-standard","hentry","category-daily-life","category-tech","tag-cellphone","tag-linux","tag-nagios","tag-programming","tag-unix"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/wp-json\/wp\/v2\/posts\/3051","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/wp-json\/wp\/v2\/comments?post=3051"}],"version-history":[{"count":4,"href":"https:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/wp-json\/wp\/v2\/posts\/3051\/revisions"}],"predecessor-version":[{"id":3111,"href":"https:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/wp-json\/wp\/v2\/posts\/3051\/revisions\/3111"}],"wp:attachment":[{"href":"https:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/wp-json\/wp\/v2\/media?parent=3051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/wp-json\/wp\/v2\/categories?post=3051"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thomasgericke.de\/v4\/interactive\/blog\/wp-json\/wp\/v2\/tags?post=3051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}