Ich schrieb ein kleines Skript, um den Energiezustand (Standby, Actice) meiner Festplatte zu sammeln. Es ist auf diesem Skript basiert: https://github.com/collectd/collectd/blob/master/contrib/exec-smartctlWie Debug exec Skript für Collectd
/usr/share/collectd/exec_hddpwrmode.sh
#!/bin/bash
HOSTNAME="${COLLECTD_HOSTNAME:-$(hostname -f)}"
INTERVAL="${COLLECTD_INTERVAL:-60}"
while sleep "$INTERVAL"
do
for disk in sda sdb sdc sdd sde sdf
do
STATE=$(sudo smartctl -i -n standby /dev/$disk | grep -e "Device is in STANDBY mode" -e "Power mode is: ACTIVE or IDLE" 2>/dev/null)
if [ "$STATE" = "Device is in STANDBY mode, exit(2)" ]
then
# STANBY
VALUE="0"
else
if [ "$STATE" = "Power mode is: ACTIVE or IDLE" ]
then
# ACTIVE or IDLE
VALUE="1"
else
# ERROR
VALUE="U"
fi
fi
echo "PUTVAL $HOSTNAME/disk-$disk/disk-state interval=$INTERVAL N:$VALUE" | tee -a /tmp/hddpwrstate.log
done
done
Der Ausgang in /tmp/hddpwrstate.log
sieht gut aus.
Das bedeutet, ich habe kein Berechtigungsproblem (das Skript muss von einem Benutzer ausgeführt werden, der Sudo verwenden kann). Und es wird von Collectd ausgeführt
Aber ich bekomme keine neuen RRD-Dateien in /var/lib/collectd/rrd/<hostname>
oder neue Messungen in meinem InfluxDB.
> show measurements
name: measurements
name
----
cpu_value
df_value
disk_io_time
disk_read
disk_value
disk_weighted_io_time
disk_write
entropy_value
interface_rx
interface_tx
irq_value
load_longterm
load_midterm
load_shortterm
memory_value
processes_value
rrdcached_value
swap_value
uptime_value
users_value
Ich habe versucht, Debug zu aktivieren.
<Plugin syslog>
LogLevel debug
</Plugin>
Aber es hilft nicht.
Nov 19 12:13:12 magneto collectd[30028]: Exiting normally.
Nov 19 12:13:12 magneto collectd[30028]: collectd: Stopping 5 read threads.
Nov 19 12:13:12 magneto collectd[30028]: exec plugin: Sent SIGTERM to 30042
Nov 19 12:13:12 magneto collectd[30028]: collectd: Stopping 5 write threads.
Nov 19 12:13:13 magneto collectd[31752]: Stopping statistics collection and monitoring daemon: collectd.
Nov 19 12:13:13 magneto collectd[31767]: syslog: invalid loglevel [debug] defaulting to 'info'
Nov 19 12:13:13 magneto collectd[31768]: syslog: invalid loglevel [debug] defaulting to 'info'
Nov 19 12:13:13 magneto collectd[31769]: Initialization complete, entering read-loop.
Nov 19 12:13:13 magneto collectd[31764]: Starting statistics collection and monitoring daemon: collectd.
Also, warum funktioniert mein Skript nicht? Ist etwas nicht in Ordnung? Oder wie kann ich debuggen, um das Problem selbst zu finden?
Mein System: Debian 8 mit OpenMediaVault.
Bitte nehmen Sie sich einen Blick: http://www.shellcheck.net/ – Cyrus
Danke. Ich kannte diese Seite nicht. Keine Probleme mehr im Skript. Aber es funktioniert immer noch nicht mit Collectd. –