Skip to content

Instantly share code, notes, and snippets.

@NULLx76
Created June 5, 2020 17:52
Show Gist options
  • Save NULLx76/bb749fa43c4ccf0a574777e90c7bf188 to your computer and use it in GitHub Desktop.
Save NULLx76/bb749fa43c4ccf0a574777e90c7bf188 to your computer and use it in GitHub Desktop.
c0 = from(bucket: "r710")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "sensors")
|> filter(fn: (r) => r["_field"] == "temp_input")
|> filter(fn: (r) => r["chip"] == "coretemp-isa-0000")
|> filter(fn: (r) => r["feature"] == "core_0")
c1 = from(bucket: "r710")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "sensors")
|> filter(fn: (r) => r["_field"] == "temp_input")
|> filter(fn: (r) => r["chip"] == "coretemp-isa-0000")
|> filter(fn: (r) => r["feature"] == "core_1")
c10 = from(bucket: "r710")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "sensors")
|> filter(fn: (r) => r["_field"] == "temp_input")
|> filter(fn: (r) => r["chip"] == "coretemp-isa-0000")
|> filter(fn: (r) => r["feature"] == "core_10")
c2 = from(bucket: "r710")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "sensors")
|> filter(fn: (r) => r["_field"] == "temp_input")
|> filter(fn: (r) => r["chip"] == "coretemp-isa-0000")
|> filter(fn: (r) => r["feature"] == "core_2")
c8 = from(bucket: "r710")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "sensors")
|> filter(fn: (r) => r["_field"] == "temp_input")
|> filter(fn: (r) => r["chip"] == "coretemp-isa-0000")
|> filter(fn: (r) => r["feature"] == "core_8")
c9 = from(bucket: "r710")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "sensors")
|> filter(fn: (r) => r["_field"] == "temp_input")
|> filter(fn: (r) => r["chip"] == "coretemp-isa-0000")
|> filter(fn: (r) => r["feature"] == "core_9")
c0c1 = join(tables: {c0:c0, c1:c1,}, on: ["_time", "_field"])
|> map(fn: (r) => ({ r with _value: (r._value_c0 + r._value_c1) / 2.0 }))
c8c9 = join(tables: {c0:c8, c1:c9,}, on: ["_time", "_field"])
|> map(fn: (r) => ({ r with _value: (r._value_c0 + r._value_c1) / 2.0 }))
c10c2 = join(tables: {c0:c10, c1:c2,}, on: ["_time", "_field"])
|> map(fn: (r) => ({ r with _value: (r._value_c0 + r._value_c1) / 2.0 }))
c0c1c8c9 = join(tables: {c0:c0c1, c1:c8c9,}, on: ["_time", "_field"])
|> map(fn: (r) => ({ r with _value: (r._value_c0 + r._value_c1) / 2.0 }))
soc0 = join(tables: {c0:c10c2, c1:c0c1c8c9,}, on: ["_time", "_field"])
|> map(fn: (r) => ({ r with _value: (r._value_c0 + r._value_c1) / 2.0 }))
|> yield(name: "soc0")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment