Answers: <p>To me it looks like you are trying to reinvent the wheel. As I understood you would like to restart a container if a health check fails. As you are using docker you should use a orchestration platform in my opinion like Fargate (ECS) or Kubernetes (k8s). I know from the latter that it is possible to define healthchecks, like readiness and health probes. If the health check fails, kubernetes will restart the POD (auto healing). </p>
  
  <p>It could be possible that you would argue that k8s is not an option. If that is the case, you could also have a look to AWS OpsWorks. Although I did not try it myself yet, it is able to perform auto healing as well.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-08-23T14:21:22.083Z
Answers: we are using ECS for the healthchecks, only problem was that Jenkins slaves do not expose a Health check on their container images. So i was wondering what the best solution would be to add such a healthcheck on a Jenkins Slave: 
  1) Creating a custom image, and add NGINX which exposes a healthcheck or 2) try to use that Jenkins API in a slave which doesnt seem to work. 
  We used option 1 for now and this is working fine.
Answers: Rob Van Pamel
Answers: CC BY-SA 4.0
Answers: 2021-01-13T10:34:04.127Z
Answers: Could you not do something very basic such as check if a process is running or check for exceptions in a log? Historically this is how you would check for arbitrary services on *nix systems.
Answers: Grizzle
Answers: CC BY-SA 4.0
Answers: 2019-08-18T11:40:11.833Z
Answers: 2019-08-18T11:40:11.833Z
Answers: 030
Answers: <p>Take a look at this Jenkins Plugin: <a href="https://plugins.jenkins.io/slave-status/" rel="nofollow noreferrer">https://plugins.jenkins.io/slave-status/</a></p>
  <p>It'll expose a healthcheck endpoint + other information like memory on port 3141 (you can configure a custom port). You can then ping that healthcheck endpoint and send the data to CloudWatch.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-03-05T13:22:17.957Z
Answers: While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference.  Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/9756)
Answers: Bruce Becker
Answers: CC BY-SA 4.0
Answers: 2021-03-05T16:47:57.083Z
Answers: @BruceBecker updated
Answers: Akram Fares
Answers: CC BY-SA 4.0
Answers: 2021-03-04T19:48:03.803Z
Answers: 2021-03-05T16:47:38.480Z
Answers: 2021-03-05T16:47:38.480Z
Answers: Akram Fares
Body: <p>For a project I'm working on, we need to create a Jenkins node in an AWS environment. For this task,  we will work with the docker image, which is available on <a href="https://github.com/jenkinsci/docker-ssh-slave" rel="nofollow noreferrer">https://github.com/jenkinsci/docker-ssh-slave</a>
  . The Jenkins node will be responsible for executing AWS commands which can only be done from inside the AWS environment (not outside).</p>
  <p>This Jenkins Master is running in our local environment. We will add the node as a permanent node in the Jenkins master. The Jenkins master is not responsible for setting up the Jenkins Node, since it has no permissions to do this ( this is managed in AWS ).</p>
  <p>However, we would like to monitor the Jenkins Slave inside AWS to see if it it still running successfully. With other docker containers, we also expose a health check. If the health check fails, the docker container is treated as unhealthy, and is restarted accordingly.
  Just like we do with the other docker containers, we would like to expose such a health port as well on the Jenkins Slave. If it is not responding anymore, AWS will restart the docker container, and we have a stable system.</p>
  <p>We already explored the Nagios monitoring, but it looks like this is exposing the health in the master, and not directly in the slave.</p>
  <p>Is it available, or how can we add such functionality?
  Could you lead us in the right direction, or recommend plugins which need to be installed, ...</p>
  <ul>
  <li>Can we open the default HTTP API of Jenkins in such a Jenkins slave (<a href="https://wiki.jenkins.io/display/JENKINS/Remote+access+API" rel="nofollow noreferrer">https://wiki.jenkins.io/display/JENKINS/Remote+access+API</a>)</li>
  <li>Another approach could be to add and start NGINX in docker and point the healthcheck to NGINX. But with this approach, we are not really checking the health of the the Jenkins slave.</li>
  </ul>
  
Comments: CC BY-SA 4.0
Comments: 2018-06-19T17:51:53.740Z
Comments: I would really recommend pursuing actual monitoring further (e.g. Nagios, monit, etc.), since Jenkins is not intended to be a monitoring tool.
Comments: jayhendren
Comments: CC BY-SA 4.0
Comments: 2018-06-20T10:30:38.603Z
Comments: @jayhendren: I think the question is not clear, we are not trying to monitor our slaves with Jenkins. 
  We are using AWS Cloudwatch as a monitoring tool., But in order to do some things we need an HTTP-endpoint in our (docker) slaves where we can verify if this slave is still up and behaving correctly. At this moment, i have no idea how to do this. So any help is welcome.
Comments: Rob Van Pamel
Tags: <jenkins><amazon-web-services><jenkins-plugins>
Title: Monitor Jenkins node/slave health
UserDisplayName: Rob Van Pamel
ThreadText: # Monitor Jenkins node/slave health
  
  (Asked by: username_0 on 2018-06-19)
  
  For a project I'm working on, we need to create a Jenkins node in an AWS environment. For this task, we will work with the docker image, which is available on <https://github.com/jenkinsci/docker-ssh-slave>
  . The Jenkins node will be responsible for executing AWS commands which can only be done from inside the AWS environment (not outside).
  
  This Jenkins Master is running in our local environment. We will add the node as a permanent node in the Jenkins master. The Jenkins master is not responsible for setting up the Jenkins Node, since it has no permissions to do this ( this is managed in AWS ).
  
  However, we would like to monitor the Jenkins Slave inside AWS to see if it it still running successfully. With other docker containers, we also expose a health check. If the health check fails, the docker container is treated as unhealthy, and is restarted accordingly.
  Just like we do with the other docker containers, we would like to expose such a health port as well on the Jenkins Slave. If it is not responding anymore, AWS will restart the docker container, and we have a stable system.
  
  We already explored the Nagios monitoring, but it looks like this is exposing the health in the master, and not directly in the slave.
  
  Is it available, or how can we add such functionality?
  Could you lead us in the right direction, or recommend plugins which need to be installed, ...
  
  * Can we open the default HTTP API of Jenkins in such a Jenkins slave (<https://wiki.jenkins.io/display/JENKINS/Remote+access+API>)
  * Another approach could be to add and start NGINX in docker and point the healthcheck to NGINX. But with this approach, we are not really checking the health of the the Jenkins slave.
  
  **Tags:** jenkins, amazon-web-services, jenkins-plugins
  
  > **Comments:**
  > **username_1**: I would really recommend pursuing actual monitoring further (e.g. Nagios, monit, etc.), since Jenkins is not intended to be a monitoring tool.  
  > **username_0**: @username_1: I think the question is not clear, we are not trying to monitor our slaves with Jenkins.  We are using AWS Cloudwatch as a monitoring tool., But in order to do some things we need an HTTP-endpoint in our (docker) slaves where we can verify if this slave is still up and behaving correctly. At this moment, i have no idea how to do this. So any help is welcome.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-08-18. Score: 1
  
  To me it looks like you are trying to reinvent the wheel. As I understood you would like to restart a container if a health check fails. As you are using docker you should use a orchestration platform in my opinion like Fargate (ECS) or Kubernetes (k8s). I know from the latter that it is possible to define healthchecks, like readiness and health probes. If the health check fails, kubernetes will restart the POD (auto healing).
  
  It could be possible that you would argue that k8s is not an option. If that is the case, you could also have a look to AWS OpsWorks. Although I did not try it myself yet, it is able to perform auto healing as well.
  
  > **Comments:**
  > **username_0**: we are using ECS for the healthchecks, only problem was that Jenkins slaves do not expose a Health check on their container images. So i was wondering what the best solution would be to add such a healthcheck on a Jenkins Slave:  1) Creating a custom image, and add NGINX which exposes a healthcheck or 2) try to use that Jenkins API in a slave which doesnt seem to work.  We used option 1 for now and this is working fine.  
  > **username_3**: Could you not do something very basic such as check if a process is running or check for exceptions in a log? Historically this is how you would check for arbitrary services on *nix systems.  
  
  ---
  
  ### Answer by username_4 on 2021-03-04. Score: -1
  
  Take a look at this Jenkins Plugin: <https://plugins.jenkins.io/slave-status/>
  
  It'll expose a healthcheck endpoint + other information like memory on port 3141 (you can configure a custom port). You can then ping that healthcheck endpoint and send the data to CloudWatch.
  
  > **Comments:**
  > **username_5**: While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference.  Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/9756)  
  > **username_4**: @username_5 updated  
  
  ---
  
  