0813.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Running Healthchecks - A Cron Job Monitoring Service - In Docker</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Homelab,Install Guide,Linux,Ubuntu,Home Lab Ideas,Home Lab,Healthchecks Cron Monitor,Healthchecks,Healthcheck Install Guide,Debian,Cron Monitor,Cron Job Monitor,Cron Job,Cron,Docker,Docker Container,Docker How To,Docker Made Easy,Docker Simplified,Docker Tutorial,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Running Healthchecks - A Cron Job Monitoring Service - In Docker">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="07/28/2024 06:48:04 AM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Running Healthchecks - A Cron Job Monitoring Service - In Docker</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <h2>What is Healthchecks?</h2>
  26. <blockquote>
  27. <p><em>Healthchecks is a cron job monitoring service. It listens for HTTP requests and email messages (&quot;pings&quot;) from your cron jobs and scheduled tasks (&quot;checks&quot;). When a ping does not arrive on time, Healthchecks sends out alerts.</em></p>
  28. <p><em>Healthchecks comes with a web dashboard, API, 25+ integrations for delivering notifications, monthly email reports, WebAuthn 2FA support, team management features: projects, team members, read-only access.</em><em> -<a href="https://github.com/healthchecks/healthchecks" target="_blank">https://github.com/healthchecks/healthchecks</a></em></p>
  29. </blockquote>
  30. <h2>Installing Docker</h2>
  31. <ol>
  32. <li>Log into the Linux based device</li>
  33. <li>Run the following commands in the terminal
  34. <div class="codeBlock"># install prerequisites<br />
  35. sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y<br />
  36. # add docker gpg key<br />
  37. curl -fsSL https://download.docker.com/linux/$(awk -F&#39;=&#39; &#39;/^ID=/{ print $NF }&#39; /etc/os-release)/gpg | sudo apt-key add -<br />
  38. # add docker software repository<br />
  39. sudo add-apt-repository &quot;deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F&#39;=&#39; &#39;/^ID=/{ print $NF }&#39; /etc/os-release) $(lsb_release -cs) stable&quot;<br />
  40. # install docker<br />
  41. sudo apt install docker-ce docker-compose containerd.io -y<br />
  42. # enable and start docker service<br />
  43. sudo systemctl enable docker &amp;&amp; sudo systemctl start docker<br />
  44. # add the current user to the docker group<br />
  45. sudo usermod -aG docker $USER<br />
  46. # reauthenticate for the new group membership to take effect<br />
  47. su - $USER</div>
  48. </li>
  49. </ol>
  50. <h2>Running the Healthchecks Container</h2>
  51. <ol>
  52. <li>Now that Docker is installed, run the following commands to setup the Healthchecks Docker container and run it
  53. <div class="codeBlock"># create working directories<br />
  54. mkdir ~/docker/postresql -p &amp;&amp; mkdir ~/docker/healthchecks -p<br />
  55. # create containers network<br />
  56. docker network create containers<br />
  57. # download the base configuration<br />
  58. wget -O ~/docker/healthchecks/.env https://raw.githubusercontent.com/healthchecks/healthchecks/master/docker/.env.example<br />
  59. # generate a 32 character random string<br />
  60. head /dev/urandom | LC_ALL=C tr -dc &#39;A-Za-z0-9&#39; | head -c 32<br />
  61. # copy the output string to the clipboard<br />
  62. # edit the .env file<br />
  63. nano ~/docker/healthchecks/.env</div>
  64. </li>
  65. <li>Scroll through the .env file, updating at least the key/value pairs listed below
  66. <p>ALLOWED_HOSTS=*<br />
  67. ---<br />
  68. DB=postgres<br />
  69. DB_HOST=postgres<br />
  70. DB_NAME=healthchecks<br />
  71. DB_PASSWORD=He@lt4Ch3ck$!<br />
  72. DB_USER=healthchecks_rw<br />
  73. ---<br />
  74. DEFAULT_FROM_EMAIL=healthchecks@i12bretro.local<br />
  75. ---<br />
  76. EMAIL_HOST=smtp.i12bretro.local<br />
  77. EMAIL_HOST_PASSWORD=<br />
  78. EMAIL_HOST_USER=<br />
  79. EMAIL_PORT=25<br />
  80. EMAIL_USE_TLS=False<br />
  81. EMAIL_USE_VERIFICATION=False<br />
  82. ---<br />
  83. SECRET_KEY=&lt;% random string from clipboard %&gt;</p>
  84. </li>
  85. <li>Press CTRL+W and search for localhost</li>
  86. <li>Update all references to localhost with the DNS or IP address of the docker host (ie SITE_ROOT=http://localhost:8000 -&gt; http://ubuntuserver.local:8000)</li>
  87. <li>Press CTRL+O, Enter, CTRL+X to write the changes to .env</li>
  88. <li>Continue with the following commands in terminal
  89. <div class="codeBlock"># set owner of working directories<br />
  90. sudo chown &quot;$USER&quot;:&quot;$USER&quot; ~/docker -R<br />
  91. # run the postgresql docker container<br />
  92. docker run -d --name postgres -e POSTGRES_USER=healthchecks_rw -e POSTGRES_PASSWORD=&#39;He@lt4Ch3ck$!&#39; -e POSTGRES_DB=healthchecks -v /home/$USER/docker/postresql:/var/lib/postgresql/data --network containers --restart=unless-stopped postgres<br />
  93. # run the healthchecks container<br />
  94. docker run -d --name healthchecks --env-file ~/docker/healthchecks/.env -p 8000:8000 --network containers --restart=unless-stopped healthchecks/healthchecks<br />
  95. # connect to healthchecks container shell<br />
  96. docker exec -ti healthchecks /bin/bash<br />
  97. # create an admin user<br />
  98. /opt/healthchecks/manage.py createsuperuser<br />
  99. # enter an email address<br />
  100. # enter and confirm a password<br />
  101. # exit the container shell<br />
  102. exit</div>
  103. </li>
  104. <li>Open a web browser and navigate to http://DNSorIP:8000</li>
  105. <li>Login with the admin account created earlier</li>
  106. <li>Welcome to HealthChecks</li>
  107. </ol>
  108. <p>Documentation: <a href="https://hub.docker.com/r/healthchecks/healthchecks" target="_blank">https://hub.docker.com/r/healthchecks/healthchecks</a></p> </div>
  109. </div>
  110. </body>
  111. </html>