#!/bin/sh

# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)

. /etc/profile

oe_setup_addon service.prometheus-node-exporter

DAEMON_ARGS=""

while read var opt ; do
  eval [ \"\$${var}\" = "true" ] && DAEMON_ARGS="${DAEMON_ARGS} ${opt}"
done << EOF
WebDisableExporterMetrics --web.disable-exporter-metrics
CollectorArp --collector.arp
CollectorBcache --collector.bcache
CollectorBonding --collector.bonding
CollectorBtrfs --collector.btrfs
CollectorBuddyinfo --collector.buddyinfo
CollectorConntrack --collector.conntrack
CollectorCpu --collector.cpu
CollectorCpufreq --collector.cpufreq
CollectorDiskstats --collector.diskstats
CollectorDrbd --collector.drbd
CollectorEdac --collector.edac
CollectorEntropy --collector.entropy
CollectorEthtool --collector.ethtool
CollectorFibrechannel --collector.fibrechannel
CollectorFilefd --collector.filefd
CollectorFilesystem --collector.filesystem
CollectorHwmon --collector.hwmon
CollectorInfiniband --collector.infiniband
CollectorInterrupts --collector.interrupts
CollectorIpvs --collector.ipvs
CollectorKsmd --collector.ksmd
CollectorLoadavg --collector.loadavg
CollectorLogind --collector.logind
CollectorMdadm --collector.mdadm
CollectorMeminfo --collector.meminfo
CollectorMeminfoNuma --collector.meminfo_numa
CollectorMountstats --collector.mountstats
CollectorNetclass --collector.netclass
CollectorNetdev --collector.netdev
CollectorNetstat --collector.netstat
CollectorNetworkRoute --collector.network_route
CollectorNfs --collector.nfs
CollectorNfsd --collector.nfsd
CollectorNtp --collector.ntp
CollectorNvme --collector.nvme
CollectorPerf --collector.perf
CollectorPowersupplyclass --collector.powersupplyclass
CollectorPressure --collector.pressure
CollectorProcesses --collector.processes
CollectorQdisc --collector.qdisc
CollectorRapl --collector.rapl
CollectorRunit --collector.runit
CollectorSchedstat --collector.schedstat
CollectorSockstat --collector.sockstat
CollectorSoftnet --collector.softnet
CollectorStat --collector.stat
CollectorSupervisord --collector.supervisord
CollectorSystemd --collector.systemd
CollectorTapestats --collector.tapestats
CollectorTcpstat --collector.tcpstat
CollectorTextfile --collector.textfile
CollectorThermalZone --collector.thermal_zone
CollectorTime --collector.time
CollectorTimex --collector.timex
CollectorUdpQueues --collector.udp_queues
CollectorUname --collector.uname
CollectorVmstat --collector.vmstat
CollectorWifi --collector.wifi
CollectorXfs --collector.xfs
CollectorZfs --collector.zfs
CollectorZoneinfo --collector.zoneinfo
EOF

/storage/.kodi/addons/service.prometheus-node-exporter/bin/prometheus-node-exporter --collector.disable-defaults \
  --web.listen-address=":$WebListenPort" \
  --web.telemetry-path="$WebTelemetryPath" \
  --web.max-requests=$WebMaxRequest \
  $DAEMON_ARGS
