Skip to content

Instantly share code, notes, and snippets.

@detain
Created April 4, 2023 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save detain/dfc202977bc38054f8627dd8f975c5da to your computer and use it in GitHub Desktop.
Save detain/dfc202977bc38054f8627dd8f975c5da to your computer and use it in GitHub Desktop.
ipmi gauge chatgpt outputs

1 / 1

generate appropriate gauges using gaugeJS and these sensor readings: ``` [ {"label": "CPU1 Temp", "scale": "degrees C", "status": "ok", "current": 37, "lower_critical": 0, "upper_critical": 90, "lower_non_critical": 0, "upper_non_critical": 85, "lower_non_recoverable": 0, "upper_non_recoverable": 90}, {"label": "FAN1", "scale": "RPM", "status": "ok", "current": 3900, "lower_critical": 500, "upper_critical": 25400, "lower_non_critical": 700, "upper_non_critical": 25300, "lower_non_recoverable": 300, "upper_non_recoverable": 25500}, {"label": "12V", "scale": "Volts", "status": "ok", "current": 12.189, "lower_critical": 10.299, "upper_critical": 13.26, "lower_non_critical": 10.74, "upper_non_critical": 12.945, "lower_non_recoverable": 10.173, "upper_non_recoverable": 13.386}, {"label": "Chassis Intru", "scale": "discrete", "status": "0x0000", "current": "0x0", "lower_critical": "na", "upper_critical": "na", "lower_non_critical": "na", "upper_non_critical": "na", "lower_non_recoverable": "na", "upper_non_recoverable": "na"}, {"label": "PS1 Status", "scale": "discrete", "status": "0x0100", "current": "0x1", "lower_critical": "na", "upper_critical": "na", "lower_non_critical": "na", "upper_non_critical": "na", "lower_non_recoverable": "na", "upper_non_recoverable": "na"} ] ```

1 / 1

Sure, here's an example of how to create gauges using GaugeJS library based on the provided sensor readings:

html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>GaugeJS Example</title>
  <script src="https://cdn.jsdelivr.net/npm/justgage@1.4.0-rc1/raphael-2.3.0.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/justgage@1.4.0-rc1/justgage.min.js"></script>
</head>
<body>
  <h1>Sensor Readings</h1>
  <div id="gauges"></div>

  <script>
    // Define sensor readings
    var sensorReadings = [
      {"label": "CPU1 Temp", "scale": "degrees C", "status": "ok", "current": 37, "lower_critical": 0, "upper_critical": 90, "lower_non_critical": 0, "upper_non_critical": 85, "lower_non_recoverable": 0, "upper_non_recoverable": 90}, 
      {"label": "FAN1", "scale": "RPM", "status": "ok", "current": 3900, "lower_critical": 500, "upper_critical": 25400, "lower_non_critical": 700, "upper_non_critical": 25300, "lower_non_recoverable": 300, "upper_non_recoverable": 25500}, 
      {"label": "12V", "scale": "Volts", "status": "ok", "current": 12.189, "lower_critical": 10.299, "upper_critical": 13.26, "lower_non_critical": 10.74, "upper_non_critical": 12.945, "lower_non_recoverable": 10.173, "upper_non_recoverable": 13.386}
    ];

    // Loop through sensor readings and create gauges
    for (var i = 0; i < sensorReadings.length; i++) {
      var reading = sensorReadings[i];

      // Define gauge options
      var gaugeOptions = {
        min: reading.lower_non_critical,
        max: reading.upper_non_critical,
        value: reading.current,
        title: reading.label + " (" + reading.scale + ")",
        label: reading.scale,
        gaugeWidthScale: 0.6,
        pointer: true,
        pointerOptions: {
          toplength: -15,
          bottomlength: 10,
          bottomwidth: 12,
          color: '#8e8e93',
          stroke: '#ffffff',
          strokeWidth: 4,
          strokeOpacity: 0.5,
          baseLength: 20,
          baseWidth: 10,
          baseFill: '#9d9da2',
          baseStroke: '#6b6b6e',
          baseOpacity: 1,
          dynamicOptions: true
        },
        counter: true,
        relativeGaugeSize: true,
        startAnimationType: 'linear',
        startAnimationTime: 1500,
        refreshAnimationTime: 1000,
        refreshAnimationType: 'linear',
        levelColors: [
          '#ff0000',
          '#ffa500',
          '#f9c802',
          '#a9d70b',
          '#55bf3b'
        ]
      };

      // Create gauge
      var gauge = new JustGage({
        id: "gauge" + i,
        options: gaugeOptions
      });

      // Update gauge value

1 / 1

generate appropriate gauges using gaugeJS and these sensor readings: ``` [ {"label": "CPU1 Temp", "scale": "degrees C", "status": "ok", "current": 37, "lower_critical": 0, "upper_critical": 90, "lower_non_critical": 0, "upper_non_critical": 85, "lower_non_recoverable": 0, "upper_non_recoverable": 90}, {"label": "12V", "scale": "Volts", "status": "ok", "current": 12.189, "lower_critical": 10.299, "upper_critical": 13.26, "lower_non_critical": 10.74, "upper_non_critical": 12.945, "lower_non_recoverable": 10.173, "upper_non_recoverable": 13.386}, {"label": "PS1 Status", "scale": "discrete", "status": "0x0100", "current": "0x1", "lower_critical": "na", "upper_critical": "na", "lower_non_critical": "na", "upper_non_critical": "na", "lower_non_recoverable": "na", "upper_non_recoverable": "na"} ] ```

1 / 1

Sure, here are the appropriate gauges using GaugeJS for the given sensor readings:

  1. CPU1 Temp Gauge:

html

<div id="cpu-temp-gauge"></div>

javascript

var cpuTempGauge = new Gauge({
  renderTo: 'cpu-temp-gauge',
  title: 'CPU1 Temp',
  units: 'degrees C',
  minValue: 0,
  maxValue: 90,
  majorTicks: ['0', '10', '20', '30', '40', '50', '60', '70', '80', '90'],
  minorTicks: 5,
  highlights: [
    { from: 0, to: 85, color: 'rgba(0, 255, 0, .15)' },
    { from: 85, to: 90, color: 'rgba(255, 0, 0, .25)' }
  ],
  valueFormat: { int: 2, dec: 0 },
  value: 37
});
  1. 12V Voltage Gauge:

html

<div id="voltage-gauge"></div>

javascript

var voltageGauge = new Gauge({
  renderTo: 'voltage-gauge',
  title: '12V',
  units: 'Volts',
  minValue: 10.173,
  maxValue: 13.386,
  majorTicks: ['10.173', '10.74', '11.307', '11.874', '12.441', '13.008', '13.575', '13.386'],
  highlights: [
    { from: 10.173, to: 10.74, color: 'rgba(255, 0, 0, .25)' },
    { from: 10.74, to: 12.945, color: 'rgba(0, 255, 0, .15)' },
    { from: 12.945, to: 13.386, color: 'rgba(255, 0, 0, .25)' }
  ],
  valueFormat: { int: 2, dec: 3 },
  value: 12.189
});
  1. PS1 Status Gauge:

html

<div id="ps-status-gauge"></div>

javascript

var psStatusGauge = new Gauge({
  renderTo: 'ps-status-gauge',
  title: 'PS1 Status',
  units: '',
  minValue: 0,
  maxValue: 1,
  majorTicks: ['0', '1'],
  highlights: [
    { from: 0, to: 1, color: 'rgba(0, 255, 0, .15)' }
  ],
  valueFormat: { int: 1, dec: 0 },
  value: 1
});

Note: The FAN1 sensor reading is not included as it requires a gauge that supports a scale in RPM. GaugeJS does not have an RPM scale by default, so a custom scale would need to be created or a different gauge library would need to be used.

1 / 1

generate appropriate gauges using gaugeJS and these sensor readings: ``` [{"label": "CPU1 Temp", "scale": "degrees C", "status": "ok", "current": 37, "lower_critical": 0, "upper_critical": 90, "lower_non_critical": 0, "upper_non_critical": 85, "lower_non_recoverable": 0, "upper_non_recoverable": 90}, {"label": "FAN1", "scale": "RPM", "status": "ok", "current": 3900, "lower_critical": 500, "upper_critical": 25400, "lower_non_critical": 700, "upper_non_critical": 25300, "lower_non_recoverable": 300, "upper_non_recoverable": 25500}, {"label": "12V", "scale": "Volts", "status": "ok", "current": 12.189, "lower_critical": 10.299, "upper_critical": 13.26, "lower_non_critical": 10.74, "upper_non_critical": 12.945, "lower_non_recoverable": 10.173, "upper_non_recoverable": 13.386}, {"label": "PS1 Status", "scale": "discrete", "status": "0x0100", "current": "0x1", "lower_critical": "na", "upper_critical": "na", "lower_non_critical": "na", "upper_non_critical": "na", "lower_non_recoverable": "na", "upper_non_recoverable": "na"}] ```

1 / 1

Sure, I can help you generate appropriate gauges using gaugeJS and the provided sensor readings. Here are the code snippets for each sensor:

  1. CPU1 Temperature Gauge:

html

<div id="cpu1-gauge"></div>

<script>
  var cpu1Gauge = new Gauge({
    renderTo: 'cpu1-gauge',
    minValue: 0,
    maxValue: 90,
    value: 37,
    label: 'CPU1 Temp',
    units: 'degrees C',
    majorTicks: [0, 20, 40, 60, 80, 90],
    minorTicks: 5,
    highlights: [
      { from: 0, to: 85, color: 'rgba(0,255,0,.15)' },
      { from: 85, to: 90, color: 'rgba(255,0,0,.15)' }
    ],
    colors: {
      plate: '#fff',
      majorTicks: '#222',
      minorTicks: '#666',
      title: '#888',
      units: '#888',
      value: '#000',
      valueText: '#fff',
      highlights: '#ff0000'
    }
  });
  cpu1Gauge.draw();
</script>
  1. FAN1 RPM Gauge:

html

<div id="fan1-gauge"></div>

<script>
  var fan1Gauge = new Gauge({
    renderTo: 'fan1-gauge',
    minValue: 0,
    maxValue: 25400,
    value: 3900,
    label: 'FAN1',
    units: 'RPM',
    majorTicks: [0, 5000, 10000, 15000, 20000, 25000],
    minorTicks: 5,
    highlights: [
      { from: 0, to: 700, color: 'rgba(255,0,0,.15)' },
      { from: 700, to: 25300, color: 'rgba(0,255,0,.15)' },
      { from: 25300, to: 25400, color: 'rgba(255,0,0,.15)' }
    ],
    colors: {
      plate: '#fff',
      majorTicks: '#222',
      minorTicks: '#666',
      title: '#888',
      units: '#888',
      value: '#000',
      valueText: '#fff',
      highlights: '#ff0000'
    }
  });
  fan1Gauge.draw();
</script>
  1. 12V Voltage Gauge:

html

<div id="12v-gauge"></div>

<script>
  var voltageGauge = new Gauge({
    renderTo: '12v-gauge',
    minValue: 10.173,
    maxValue: 13.386,
    value: 12.189,
    label: '12V',
    units: 'Volts',
    majorTicks: [10.173, 10.74, 11.407, 12.074, 12.74, 13.386],
    minorTicks: 5,
    highlights: [
      { from: 10.173, to: 10.74, color: 'rgba(255,0,0,.15)' },
      { from: 10.74, to: 12.945, color: 'rgba(0,255,0,.15)' },
      { from: 12.945, to: 13.386, color: 'rgba(255,0,0,.15)' }
    ],
    colors: {
      plate: '#fff',
      majorTicks: '#

1 / 1

generate appropriate gauges using gaugeJS and these sensor readings: ``` [{"label": "CPU1 Temp", "scale": "degrees C", "status": "ok", "current": 37, "lower_critical": 0, "upper_critical": 90, "lower_non_critical": 0, "upper_non_critical": 85, "lower_non_recoverable": 0, "upper_non_recoverable": 90}, {"label": "12V", "scale": "Volts", "status": "ok", "current": 12.189, "lower_critical": 10.299, "upper_critical": 13.26, "lower_non_critical": 10.74, "upper_non_critical": 12.945, "lower_non_recoverable": 10.173, "upper_non_recoverable": 13.386}, {"label": "Chassis Intru", "scale": "discrete", "status": "0x0000", "current": "0x0", "lower_critical": "na", "upper_critical": "na", "lower_non_critical": "na", "upper_non_critical": "na", "lower_non_recoverable": "na", "upper_non_recoverable": "na"}] ```

1 / 1

Sure, I can help you generate appropriate gauges using GaugeJS based on the provided sensor readings. Here are the gauges:

  1. Gauge for "CPU1 Temp":

html

<div id="cpu-temp-gauge"></div>

<script>
  var cpuTempGauge = new Gauge(document.getElementById("cpu-temp-gauge")).setOptions({
    angle: -0.25,
    lineWidth: 0.2,
    radiusScale: 1,
    pointer: {
      length: 0.6,
      strokeWidth: 0.035,
      color: '#000000'
    },
    limitMax: true,
    limitMin: true,
    colorStart: '#6FADCF',
    colorStop: '#8FC0DA',
    strokeColor: '#E0E0E0',
    generateGradient: true,
    highDpiSupport: true
  });

  cpuTempGauge.maxValue = 90;
  cpuTempGauge.setMinValue(0);
  cpuTempGauge.animationSpeed = 32;

  cpuTempGauge.set(37);
</script>
  1. Gauge for "12V":

html

<div id="voltage-gauge"></div>

<script>
  var voltageGauge = new Gauge(document.getElementById("voltage-gauge")).setOptions({
    angle: -0.25,
    lineWidth: 0.2,
    radiusScale: 1,
    pointer: {
      length: 0.6,
      strokeWidth: 0.035,
      color: '#000000'
    },
    limitMax: true,
    limitMin: true,
    colorStart: '#6FADCF',
    colorStop: '#8FC0DA',
    strokeColor: '#E0E0E0',
    generateGradient: true,
    highDpiSupport: true
  });

  voltageGauge.maxValue = 13.26;
  voltageGauge.setMinValue(10.299);
  voltageGauge.animationSpeed = 32;

  voltageGauge.set(12.189);
</script>
  1. Gauge for "Chassis Intru":

html

<div id="chassis-intru-gauge"></div>

<script>
  var chassisIntruGauge = new Gauge(document.getElementById("chassis-intru-gauge")).setOptions({
    angle: -0.25,
    lineWidth: 0.2,
    radiusScale: 1,
    pointer: {
      length: 0.6,
      strokeWidth: 0.035,
      color: '#000000'
    },
    limitMax: true,
    limitMin: true,
    colorStart: '#6FADCF',
    colorStop: '#8FC0DA',
    strokeColor: '#E0E0E0',
    generateGradient: true,
    highDpiSupport: true
  });

  chassisIntruGauge.maxValue = 1;
  chassisIntruGauge.setMinValue(0);
  chassisIntruGauge.animationSpeed = 32;

  chassisIntruGauge.set(0);
</script>

Please note that the gauge for "Chassis Intru" is a discrete gauge, which means it can only have a value of either 0 or 1. The gauge will show 0 by default, but it will change to 1 if the "current" value in the sensor reading changes to "0x1".

1 / 1

generate gauges using gauge.js for these ipmi sensor readings: ``` [{"label": "CPU1 Temp", "scale": "degrees C", "status": "ok", "current": 37, "lower_critical": 0, "upper_critical": 90, "lower_non_critical": 0, "upper_non_critical": 85, "lower_non_recoverable": 0, "upper_non_recoverable": 90}, {"label": "FAN1", "scale": "RPM", "status": "ok", "current": 3900, "lower_critical": 500, "upper_critical": 25400, "lower_non_critical": 700, "upper_non_critical": 25300, "lower_non_recoverable": 300, "upper_non_recoverable": 25500}, {"label": "12V", "scale": "Volts", "status": "ok", "current": 12.189, "lower_critical": 10.299, "upper_critical": 13.26, "lower_non_critical": 10.74, "upper_non_critical": 12.945, "lower_non_recoverable": 10.173, "upper_non_recoverable": 13.386}, {"label": "PS1 Status", "scale": "discrete", "status": "0x0100", "current": "0x1", "lower_critical": "na", "upper_critical": "na", "lower_non_critical": "na", "upper_non_critical": "na", "lower_non_recoverable": "na", "upper_non_recoverable": "na"}] ```

1 / 1

Sure! Here are the gauges for the IPMI sensor readings using the gauge.js library:

CPU1 Temp

html

<div id="cpu1-temp-gauge"></div>
<script>
var cpu1Temp = new Gauge({
    renderTo: 'cpu1-temp-gauge',
    minValue: 0,
    maxValue: 90,
    value: 37,
    label: 'CPU1 Temp',
    units: 'degrees C',
    majorTicks: ['0', '10', '20', '30', '40', '50', '60', '70', '80', '90'],
    minorTicks: 2,
    highlights: [
        { from: 0, to: 85, color: '#5cb85c' },
        { from: 85, to: 90, color: '#d9534f' },
        { from: 90, to: 100, color: '#000000' }
    ],
});
cpu1Temp.draw();
</script>

FAN1

html

<div id="fan1-gauge"></div>
<script>
var fan1 = new Gauge({
    renderTo: 'fan1-gauge',
    minValue: 0,
    maxValue: 25400,
    value: 3900,
    label: 'FAN1',
    units: 'RPM',
    majorTicks: ['0', '5000', '10000', '15000', '20000', '25000'],
    minorTicks: 5,
    highlights: [
        { from: 700, to: 25300, color: '#5cb85c' },
        { from: 500, to: 700, color: '#d9534f' },
        { from: 25300, to: 25400, color: '#d9534f' },
        { from: 0, to: 500, color: '#000000' },
        { from: 25400, to: 26000, color: '#000000' }
    ],
});
fan1.draw();
</script>

12V

html

<div id="12v-gauge"></div>
<script>
var twelveVolt = new Gauge({
    renderTo: '12v-gauge',
    minValue: 10.173,
    maxValue: 13.386,
    value: 12.189,
    label: '12V',
    units: 'Volts',
    majorTicks: ['10.173', '10.74', '11.307', '11.874', '12.441', '13.008', '13.575'],
    minorTicks: 2,
    highlights: [
        { from: 10.74, to: 12.945, color: '#5cb85c' },
        { from: 10.299, to: 10.74, color: '#d9534f' },
        { from: 12.945, to: 13.26, color: '#d9534f' },
        { from: 10.173, to: 10.299, color: '#000000' },
        { from: 13.26, to: 13.386, color: '#000000' }
    ],
});
twelveVolt.draw();
</script>

PS1 Status

html

<div id="ps1-status-gauge"></div>
<script>
var ps1Status = new Gauge({
    renderTo: 'ps1-status-gauge',
    minValue: 0,
    maxValue: 1,
    value: 1,
    label: 'PS1 Status',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment