#!/bin/sh # systeminfo.sh: external data collection script # This file belongs to the VDR plugin systeminfo # # See the main source file 'systeminfo.c' for copyright information and # how to reach the author. # # $Id$ # # possible output formats: # (blanks around tabs only for better reading) # 1) Name \t Value displays Name and Value # 2) Name \t Value1 \t Value2 displays Name, Value1 and Value2 # 3) Name \t total used displays an additional progress bar (percentage) after the values # 4) s \t Name \t ... defines a static value, this line is only requested during the first cycle # # special keywords (they are replaced by the plugin with the actual value): # CPU% CPU usage in percent # # test with: for i in $(seq 1 16); do systeminfo.sh $i;echo;done # . /etc/init.d/rc.functions case "$1" in 1) # kernel version (static) KERNEL=$(uname -rm) echo -ne "s\tLinux Kernel:\t"$KERNEL ;; 2) # distribution release (static) echo -ne "s\tDistribution:\t"$SYSTEM_NAME $SYSTEM_VERSION ;; 3) # CPU type (static) CPUTYPE=$(grep 'model name' /proc/cpuinfo | cut -d':' -f 2 | cut -d' ' -f2- | uniq) echo -ne "s\tCPU Type:\t"$CPUTYPE ;; 4) # current CPU speed VAR=$(grep 'cpu MHz' /proc/cpuinfo | sed 's/.*: *\([0-9]*\)\.[0-9]*/\1 MHz/') echo -ne "CPU speed:\t"$VAR ;; 5) # hostname and IP (static) hostname=$(hostname) dnsname=$(dnsdomainname) IP=$(ifconfig eth0 | grep inet | cut -d: -f2 | cut -d' ' -f1) echo -ne "s\tHostname:\t"${hostname:-}"."${dnsname:-}"\tIP: "${IP:-N/A} ;; 6) # fan speeds CPU=$( sensors | grep -i 'fan1\|cpu fan' | head -n1 | sed 's/.* //') CASE=$(sensors | grep -i 'fan2\|system fan' | head -n1 | sed 's/.* //') echo -ne "Fans:\tCPU: "$CPU" rpm\tCase: "$CASE" rpm" ;; 7) # temperature of CPU and mainboard CPU=$(sensors | grep -i 'temp1\|cpu temp\|cpu0 temp\|core0 temp' | head -n1 | sed 's/.* //') MB=$( sensors | grep -i 'temp2\|m/b temp\|system temp' | head -n1 | sed 's/.* //') echo -ne "Temperatures:\tCPU: "$CPU"\tMB: "$MB ;; 8) # temperature of hard disks DISK1=$(hddtemp /dev/$(ls -l /mnt/system | sed "s/.*\/mnt\/\(...\).*/\\1/") | cut -d: -f1,3) DISK2=$(hddtemp /dev/${DATA_DIR#/mnt/} | cut -d: -f1,3) echo -ne "\t"$DISK1"\t"$DISK2 ;; 9) # CPU usage echo -e "CPU time:\tCPU%" ;; 10) # header (static) echo -ne "s\t\ttotal / free" ;; 11) # system disk usage VAR=$(df -P /mnt/system | tail -n 1 | /usr/bin/tr -s ' ' | cut -d' ' -f 2,4) echo -ne "System Disk:\t"$VAR ;; 12) # video disk usage VAR=$(df -P /data/tv | tail -n 1 | /usr/bin/tr -s ' ' | cut -d' ' -f 2,4) echo -ne "Video Disk:\t"$VAR ;; 13) # memory usage VAR=$( grep -E 'MemTotal|MemFree' /proc/meminfo | cut -d: -f2 | /usr/bin/tr -d ' ') echo -ne "Memory:\t"$VAR ;; 14) # battery BAT=$(sensors | grep -i 'VBat' | /usr/bin/tr -s ' ' | cut -d' ' -f 2) echo -ne "CMOS-Batterie:\t"$BAT V ;; test) echo "" echo "Usage: systeminfo.sh {1|2|3|4|...}" echo "" exit 1 ;; esac exit