Git Product home page Git Product logo

openshift-tips's Introduction

openshift-tips

Checking Health Checks of all projects in openshift at once

I've got to verify health checks (liveness and readiness times) from all projects. It'll take too much time on the web interface so CLI comes to save the day.

After log in, eval the following code:

for i in `oc get projects | cut -f 1 -d ' '`; do
    echo $i ;
    oc get dc -o yaml -n $i  2> /dev/null | \
	egrep "(livenessProbe|readinessProbe)" -A 10 |  \
	egrep "(livenessProbe|readinessProbe|initialDelaySeconds|name)" | \
	sed -n -e '/Delay/!h' -e '/Delay/{x;G;s/\n//;p}' -e '/name/p' | \
	sed -n '/liveness/{h}; /name/{G;p}; /readiness/{p}'
done 

which will result in:

project1
          name: app1
          livenessProbe:            initialDelaySeconds: 420
          readinessProbe:            initialDelaySeconds: 3
project2
          name: app2
          livenessProbe:            initialDelaySeconds: 420
          readinessProbe:            initialDelaySeconds: 3

if you have jq (https://stedolan.github.io/jq/) you can do:

for i in `oc get projects | cut -f 1 -d ' '`; do
    echo $i ;
    oc get dc -o json -n $i | jq ' .items[].spec.template.spec.containers[] | {"app": .name, "liveness": .livenessProbe.initialDelaySeconds, "readiness": .readinessProbe.initialDelaySeconds}  '
done

resulting in a formatted output:

NAME
(...)
project
{
  "app": "appname",
  "liveness": 140,
  "readiness": 140
}
project2
{
  "app": "appname2",
  "liveness": 126,
  "readiness": 120
}

openshift-tips's People

Contributors

watter avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.