Skip to content

Commit

Permalink
fixes cpu percent for 1.x and 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Menezes committed May 9, 2016
1 parent 256b849 commit f9f98e8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/models/overview/ClusterOverview.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package models.overview

import elastic.ElasticClient._
import play.api.libs.json._

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

class ClusterOverview(clusterState: JsValue, nodesStats: JsValue, indicesStats: JsValue,
clusterSettings: JsValue, aliases: JsValue, clusterHealth: JsValue,
nodes: JsValue, main: JsValue) {
Expand Down Expand Up @@ -51,9 +47,12 @@ object Nodes {
val client = (info \ "attributes" \ "client").asOpt[String].getOrElse("false").equals("true")

val stats = (nodesStats \ "nodes" \ nodeId).as[JsObject]
val totalInBytes = (stats \ "fs" \ "total" \ "total_in_bytes").asOpt[Long].getOrElse(0l) // FIXME: 1.X
val diskFreeInBytes = (stats \ "fs" \ "total" \ "free_in_bytes").asOpt[Long].getOrElse(0l) // FIXME: 1.X
val cpuPercent = (stats \ "process" \ "cpu" \ "percent").asOpt[JsNumber].getOrElse((stats \ "os" \ "user").as[JsNumber])
// FIXME: 1.X
val totalInBytes = (stats \ "fs" \ "total" \ "total_in_bytes").asOpt[Long].getOrElse(0l)
// FIXME: 1.X
val diskFreeInBytes = (stats \ "fs" \ "total" \ "free_in_bytes").asOpt[Long].getOrElse(0l)
// FIXME 1.X
val cpuPercent = (stats \ "os" \ "cpu" \ "user").asOpt[JsNumber].getOrElse((stats \ "process" \ "cpu" \ "percent").as[JsNumber])
Json.obj(
"id" -> JsString(nodeId),
"current_master" -> JsBoolean(nodeId.equals(currentMaster)),
Expand Down

0 comments on commit f9f98e8

Please sign in to comment.