Commit c4e2d8a1 authored by mengxue's avatar mengxue
Browse files

Add number of ready pods in pod list

parent 72ef68a0
......@@ -60,9 +60,9 @@ object ListDeployments extends App{
age = diffSecond + "s"
} else if (2*minute <= diffSecond && diffSecond < 10*minute) {
age = diffSecond / minute + "m" + diffSecond % minute + "s"
} else if (10*minute <= diffSecond && diffSecond < hour) {
} else if (10*minute <= diffSecond && diffSecond < 2*hour) {
age = diffSecond / minute + "m"
} else if (hour <= diffSecond && diffSecond < 2*day) {
} else if (2*hour <= diffSecond && diffSecond < 2*day) {
age = diffSecond / hour + "h"
} else {
age = diffSecond / day + "d"
......
......@@ -56,9 +56,9 @@ object ListNodes extends App {
age = diffSecond + "s"
} else if (2*minute <= diffSecond && diffSecond < 10*minute) {
age = diffSecond / minute + "m" + diffSecond % minute + "s"
} else if (10*minute <= diffSecond && diffSecond < hour) {
} else if (10*minute <= diffSecond && diffSecond < 2*hour) {
age = diffSecond / minute + "m"
} else if (hour <= diffSecond && diffSecond < 2*day) {
} else if (2*hour <= diffSecond && diffSecond < 2*day) {
age = diffSecond / hour + "h"
} else {
age = diffSecond / day + "d"
......
......@@ -30,8 +30,8 @@ object ListPods extends App{
private def listPods(pods: List[Pod]) = {
System.out.println("")
System.out.println("POD NAME NAMESPACE STATUS RESTARTS AGE")
System.out.println("======== ========= ====== ======== ===")
System.out.println("POD NAME NAMESPACE READY STATUS RESTARTS AGE")
System.out.println("======== ========= ===== ====== ======== ===")
pods.map { pod: Pod =>
val name = pod.name
......@@ -50,6 +50,24 @@ object ListPods extends App{
}).headOption
//val createTimeString = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX").parse(podInfo.map{_.createTime}.getOrElse("None").toString())
def nbReadyPod():String = {
val statusInfo = for {
stat <- pod.status.toList
condit <- stat.conditions
} yield {
condit.status
}
var nbReady = ""
val readyStatus = statusInfo.slice(1,2).head
if (readyStatus == "True") {
nbReady = "1/1"
} else {
nbReady = "0/1"
}
(nbReady)
}
def getAge():String = {
import java.time._
......@@ -64,9 +82,9 @@ object ListPods extends App{
age = diffSecond + "s"
} else if (2*minute <= diffSecond && diffSecond < 10*minute) {
age = diffSecond / minute + "m" + diffSecond % minute + "s"
} else if (10*minute <= diffSecond && diffSecond < hour) {
} else if (10*minute <= diffSecond && diffSecond < 2*hour) {
age = diffSecond / minute + "m"
} else if (hour <= diffSecond && diffSecond < 2*day) {
} else if (2*hour <= diffSecond && diffSecond < 2*day) {
age = diffSecond / hour + "h"
} else {
age = diffSecond / day + "d"
......@@ -75,9 +93,16 @@ object ListPods extends App{
}
System.out.println(f"${name}%-50s${ns}%-20s" +
f"${nbReadyPod()}%-20s" +
f"${podInfo.map{_.status}.getOrElse("None")}%-20s" +
f"${podInfo.map{_.restarts}.getOrElse("None")}%-20s" +
f"${getAge()}")
// println("STATUS " +pod.status)
//List(Condition(Initialized,True,None,None,None,Some(2019-06-18T16:35:31Z)), Condition(Ready,False,Some(ContainersNotReady),Some(containers with unready status: [skuber-nginx-ing-ctrlr]),None,Some(2019-06-19T15:41:12Z)), Condition(ContainersReady,False,Some(ContainersNotReady),Some(containers with unready status: [skuber-nginx-ing-ctrlr]),None,Some(2019-06-19T15:41:12Z)), Condition(PodScheduled,True,None,None,None,Some(2019-06-18T16:35:31Z))),None,None,Some(192.168.1.136)
// println("META" + pod.metadata)
// println("spec " + pod.spec)
}
}
......
......@@ -68,9 +68,9 @@ object ListServices extends App{
age = diffSecond + "s"
} else if (2*minute <= diffSecond && diffSecond < 10*minute) {
age = diffSecond / minute + "m" + diffSecond % minute + "s"
} else if (10*minute <= diffSecond && diffSecond < hour) {
} else if (10*minute <= diffSecond && diffSecond < 2*hour) {
age = diffSecond / minute + "m"
} else if (hour <= diffSecond && diffSecond < 2*day) {
} else if (2*hour <= diffSecond && diffSecond < 2*day) {
age = diffSecond / hour + "h"
} else {
age = diffSecond / day + "d"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment