UPC
Use upsc to get value from a UPC and show the value in a Grafana dashboard
# upcs.sh

```bash
#!/bin/sh

charge=$(upsc eaton@127.0.0.1 2>/dev/null| grep 'battery.charge:' | cut -d ' ' -f 2)
load=$(upsc eaton@127.0.0.1 2>/dev/null| grep 'ups.load:' | cut -d ' ' -f2)
power=$(upsc eaton@127.0.0.1 2>/dev/null| grep 'ups.power:' | cut -d ' ' -f2)
frequency=$(upsc eaton@127.0.0.1 2>/dev/null| grep 'output.frequency:' | cut -d ' ' -f2)
voltage=$(upsc eaton@127.0.0.1 2>/dev/null| grep 'output.voltage:' | cut -d ' ' -f2)
input_frequency=$(upsc eaton@127.0.0.1 2>/dev/null| grep 'input.frequency:' | cut -d ' ' -f2)
input_voltage=$(upsc eaton@127.0.0.1 2>/dev/null| grep 'input.voltage:' | cut -d ' ' -f2)
realpower=$(upsc eaton@127.0.0.1 2>/dev/null| grep 'ups.realpower:' | cut -d ' ' -f2)

echo "ups,ups_name=eaton,host=127.0.0.1 charge=$charge,load=$load,power=$power,frequency=$frequency,voltage=$voltage,realpower=$realpower,input_frequency=$input_frequency,input_voltage=$input_voltage"
```

# telegraf

```
[[inputs.exec]]
        interval = "60s"
        commands = [
                "/opt/ups.sh"
        ]

        data_format = "influx"
```
```
[[inputs.exec]]
        interval = "60s"
        commands = [
                "/opt/ups.sh"
        ]

        data_format = "influx"
```
{
  "__inputs": [
    {
      "name": "DS_NGINX_MEILI",
      "label": "upc",
      "description": "",
      "type": "datasource",
      "pluginId": "influxdb",
      "pluginName": "InfluxDB"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.1.6"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "influxdb",
      "name": "InfluxDB",
      "version": "1.0.0"
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 10261,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "panels": [
    {
      "datasource": "${DS_NGINX_MEILI}",
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "links": [],
      "options": {
        "maxValue": 100,
        "minValue": 0,
        "orientation": "auto",
        "showThresholdLabels": false,
        "showThresholdMarkers": true,
        "thresholds": [
          {
            "color": "green",
            "index": 0,
            "value": null
          },
          {
            "color": "red",
            "index": 1,
            "value": 80
          }
        ],
        "valueMappings": [],
        "valueOptions": {
          "decimals": null,
          "prefix": "",
          "stat": "mean",
          "suffix": "",
          "unit": "none"
        }
      },
      "pluginVersion": "6.1.6",
      "targets": [
        {
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "measurement": "ups",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "load"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Load",
      "type": "gauge"
    },
    {
      "datasource": "${DS_NGINX_MEILI}",
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 8,
        "y": 0
      },
      "id": 5,
      "links": [],
      "options": {
        "maxValue": 100,
        "minValue": 0,
        "orientation": "auto",
        "showThresholdLabels": false,
        "showThresholdMarkers": true,
        "thresholds": [
          {
            "color": "red",
            "index": 0,
            "value": null
          },
          {
            "color": "#EAB839",
            "index": 1,
            "value": 20
          },
          {
            "color": "green",
            "index": 2,
            "value": 40
          }
        ],
        "valueMappings": [],
        "valueOptions": {
          "decimals": null,
          "prefix": "",
          "stat": "mean",
          "suffix": "",
          "unit": "none"
        }
      },
      "pluginVersion": "6.1.6",
      "targets": [
        {
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "measurement": "ups",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "charge"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Batterie",
      "type": "gauge"
    },
    {
      "datasource": "${DS_NGINX_MEILI}",
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 16,
        "y": 0
      },
      "id": 6,
      "links": [],
      "options": {
        "maxValue": "650",
        "minValue": 0,
        "orientation": "auto",
        "showThresholdLabels": false,
        "showThresholdMarkers": true,
        "thresholds": [
          {
            "color": "green",
            "index": 0,
            "value": null
          },
          {
            "color": "#EAB839",
            "index": 1,
            "value": 400
          },
          {
            "color": "red",
            "index": 2,
            "value": 500
          }
        ],
        "valueMappings": [],
        "valueOptions": {
          "decimals": null,
          "prefix": "",
          "stat": "mean",
          "suffix": "",
          "unit": "none"
        }
      },
      "pluginVersion": "6.1.6",
      "targets": [
        {
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "measurement": "ups",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "realpower"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Watts",
      "type": "gauge"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_NGINX_MEILI}",
      "fill": 1,
      "gridPos": {
        "h": 10,
        "w": 24,
        "x": 0,
        "y": 8
      },
      "id": 4,
      "interval": "",
      "legend": {
        "alignAsTable": true,
        "avg": true,
        "current": false,
        "max": true,
        "min": true,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "connected",
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "alias": "power",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "measurement": "ups",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "B",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "power"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        },
        {
          "alias": "ouput voltage",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "measurement": "ups",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "voltage"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        },
        {
          "alias": "input voltage",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "measurement": "ups",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "E",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "input_voltage"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        },
        {
          "alias": "ouput frequence",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "measurement": "ups",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "C",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "frequency"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        },
        {
          "alias": "input frequence",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "measurement": "ups",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "D",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "input_frequency"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Consomation",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "schemaVersion": 18,
  "style": "dark",
  "tags": [
    "power",
    "onduleur"
  ],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-3h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "",
  "title": "UPC",
  "uid": "Lf75KjWWz",
  "version": 5,
  "description": "Use upsc to get value from a UPC and show the value in a Grafana dashboard"
}