#!/bin/bash #tsalsa version 0.4 #tsalsa collects PC and alsa info to assist in sound problem diagnosics ################################################################################# #Copyright (C) 2007 gnubien contact: memo gnubien at freenode.net. #This program is free software; you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by #the Free Software Foundation; either version 2 of the License, or #(at your option) any later version. #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. #You should have received a copy of the GNU General Public License #along with this program; if not, write to the Free Software #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ################################################################################## echo "TroubleShooting ALSA (tsalsa) collects PC and" echo "alsa info to assist in sound problem diagnostics;" echo "posts the info to nopaste.com or pastebin.ca and" echo "prints the url of the post for easy pasting." read -n 1 -p "run tsalsa now? [y/n]: " runit if [ "$runit" = "n" ] then echo " tsalsa script stopped" exit 0 else echo fi echo "NOTICE: answering these questions is important but if not possible just press enter" read -n 1 -p "your PC is a laptop? [y/n]: " ans if [ "$ans" = "y" ] then echo read -p " laptop make and model? [example: Fushiba Satellot P000]: " lap echo read -n 1 -p " How many plugs in the back of the soundcard? [example: 3,5,6] " plugz echo read -n 1 -p " Does the sound card have spdif output? [y/n]: " spdifz echo read -n 1 -p " tried any laptop model options when loading sound module? [y/n]: " model echo else echo read -p " motherboard or PC make and model? [example: aces p9m99-m9]: " dt fi echo read -n 1 -p " number of speakers connected to soundcard? [example: 2,6,8]: " num echo read -n 1 -p " are the speakers connected to an external amplifier? [y/n]: " ext echo prog=0 spinnr() { ( while true do if [ "$prog" -eq "0" ] then pss=`ps ax`; grp=`echo "$pss" |grep "bash ./tsalsa" |head -1 |awk '{print $1}'` [[ "$grp" = "" ]]&& exit fi; sleep .25 pss1=`ps ax`; grp1=`echo "$pss1" |grep "$grp"` [[ $(echo "$pss1" |grep -s "$grp") ]]&& echo -n ">" || exit prog=1 done ) & }; spinnr lsp="$(which lspci 2>/dev/null| sed 's|^[^/]*||' |sed 's/^/\t/' 2>/dev/null )"; crl="$(which curl 2>/dev/null| sed 's|^[^/]*||' |sed 's/^/\t/' 2>/dev/null)"; wgt="$(which wget 2>/dev/null| sed 's|^[^/]*||' |sed 's/^/\t/' 2>/dev/null)"; #codec=$(head -3 /proc/asound/card0/codec*/*[^regs] |sed 's/^/\t/' 2>/dev/null); codec=$(cat /proc/asound/card0/codec*/*[^regs] |sed -n '1,4p' 2>/dev/null); codechda=$(grep -is codec '/proc/asound/card0/codec#0' |sed 's/^/\t/'); distro=`grep -ihs "buntu\|SUSE\|Fedora\|PCLinuxOS\|MEPIS\|Mandriva\|Debian\|Damn\|Sabayon\|Slackware\|KNOP PIX\|Gentoo\|Zenwalk\|Mint\|Kubuntu\|FreeBSD\|Puppy\|Freespire\|Vector\|Dreamlinux\|CentOS\|Arch\|Xandros\ |Elive\|SLAX\|Red\|BSD\|KANOTIX\|Nexenta\|Foresight\|GeeXboX\|Frugalware\|64\|SystemRescue\|Novell\|BackTr ack\|KateOS" /etc/{issue,*release,*version}`; dist=`echo "$distro" |sed -e ':b; N; s/\n//; bb' |sed 's/) .*$/)/g'`; releas=$(ls /etc/*release |awk -F'/' '{print $3}'); opsys=$(uname -a); aver=$(cat /proc/asound/version |head -n1|awk {'print $7'} |sed 's/\.$//'); alib=$(grep -s VERSION_STR /usr/include/alsa/version.h 2>/dev/null|awk {'print $3'}|sed 's/"//g'); autil=$(amixer -v |awk {'print $3'}); afilz=$(grep -cs "options snd.*index=" /etc/* 2>/dev/null |sed -n '/[1-99]$/p' |sed 's/^/\t/'); amod=$(cat /proc/asound/modules|awk '{print $2}'); acards=$(cat /proc/asound/cards |sed 's/^/\t/'); alsp=$(lspci |grep -is "multi\|audio\|040[0-3]" |sed 's/^/\t/'); aso=$(ls -l /home/$USER/.asoundrc 2>/dev/null); asc=$(ls -l /etc/asound.conf 2>/dev/null); lso=$(lsof /dev/dsp* /dev/snd/* |sed 's/^/\t/' 2>/dev/null); amix=`amixer |sed 's/^ //' |sed -n '/^C\|^P\|^L\|^Mono:$/!p' |sed 's/Front Left: Playback \|Front Right: Playback \|Mono: Playback \|Front Left: \|Front Right: //' |sed 's/^[0-9]\+ //;s/\[\|\]//g;s/%.*dB/%/;/^S/ !s/^/ /' |sed -e :a -e '$!N;s/\n[^S]/ /;ta' -e 'P;D' |sed 's/Simple mixer control/amixer set/;s/% on /%,/; s/Capture off //;s/Capture on //'`; amxr=$(amixer); amxc=$(amixer contents |grep -B 3 "Item #" |sed -n '/.*ENUMERATED/!p' |sed -e ':b; N; s/\n//; bb' |sed 's/ numid/\nnumid/g' |sed 's/numid.*name=//' |sed 's/| dBscale.*$//g'); venid=`lspci -vn |grep 040[1-3] | awk -F':' '{print $3}'|awk {'print substr($0, 2)}'`; devid=`lspci -vn |grep 040[1-3] | awk -F':' '{print $4}'|awk {'print $1'}`; lspvn=$(lspci -vn 2>/dev/null); testvinid=$(echo "$venid" |awk '{print NR}'); if [ "$testvinid" -eq "1" ] then fcard=$(grep "pci:v0000"$venid"d0000"$devid"" /lib/modules/$(uname -r)/modules.alias); else fcard="multiple cards listed in lspci" fi if [ "$lap" != "" ] then echo -n ".....laptop............... " > /tmp/tsalsa.txt; echo "$lap" >> /tmp/tsalsa.txt; echo " plugs: $plugz" >> /tmp/tsalsa.txt; echo " spdif: $spdifz" >> /tmp/tsalsa.txt; echo " model options: $model" >> /tmp/tsalsa.txt; else if [ "$dt" != "" ] then echo -n ".....motheboard/desktop...... " > /tmp/tsalsa.txt; echo " $dt" >> /tmp/tsalsa.txt; else echo "..why no laptop/desktop info?.." > /tmp/tsalsa.txt; fi fi echo " number of speakers... $num " >> /tmp/tsalsa.txt; if [ "$ext" = "y" ] then echo " external amplifier... $ext " >> /tmp/tsalsa.txt; fi echo -n ".....distro............... " >> /tmp/tsalsa.txt; echo "$dist" >> /tmp/tsalsa.txt; echo -n ".....release.............. " >> /tmp/tsalsa.txt; echo "$releas" >> /tmp/tsalsa.txt; echo -n ".....System.............. " >> /tmp/tsalsa.txt; echo "$opsys" >> /tmp/tsalsa.txt; echo ".....vendor/dev id......." >> /tmp/tsalsa.txt; echo " $venid $devid" >> /tmp/tsalsa.txt; echo ".....vendor/dev module..." >> /tmp/tsalsa.txt; echo " $fcard" >> /tmp/tsalsa.txt; if [ "$testvinid" -eq "1" ] then vendev=$(lspci -vn |grep 040[1-3] |awk '{print $3}'); echo -n ".....vendor/device: $vendev" >> /tmp/tsalsa.txt; lspci -v -d "$vendev" |grep Subsystem: |sed 's/\t/ /' >> /tmp/tsalsa.txt; fi echo ".....lspci info........." >> /tmp/tsalsa.txt; echo "$alsp" >> /tmp/tsalsa.txt; echo -n ".....alsa driver........ " >> /tmp/tsalsa.txt; echo "$aver" >> /tmp/tsalsa.txt; echo -n ".....alsa lib........... " >> /tmp/tsalsa.txt; echo "$alib" >> /tmp/tsalsa.txt; echo -n ".....alsa utils......... " >> /tmp/tsalsa.txt; echo "$autil" >> /tmp/tsalsa.txt; echo ".....alsa modules......." >> /tmp/tsalsa.txt; echo " $amod" >> /tmp/tsalsa.txt; echo ".....alsa cards........." >> /tmp/tsalsa.txt; echo "$acards" >> /tmp/tsalsa.txt; echo ".....codec.............." >> /tmp/tsalsa.txt; echo "$codec" >> /tmp/tsalsa.txt; echo "$codechda" >> /tmp/tsalsa.txt; if [ "$asc" != "" ] then echo -n "...../etc/asound.conf.. " >> /tmp/tsalsa.txt; echo "$asc" >> /tmp/tsalsa.txt; fi if [ "$afilz" != "" ] then echo ".....alsa options files:number of entrys" >> /tmp/tsalsa.txt; echo "$afilz" >> /tmp/tsalsa.txt; fi if [ "$aso" != "" ] then echo ".....asoundrc........." >> /tmp/tsalsa.txt; echo "$aso" >> /tmp/tsalsa.txt; fi echo ".....lsof output...... " >> /tmp/tsalsa.txt; echo "$lso" >> /tmp/tsalsa.txt; echo "" >> /tmp/tsalsa.txt; echo ".....amixer contents...." >> /tmp/tsalsa.txt; echo "$amxc" >> /tmp/tsalsa.txt; echo "" >> /tmp/tsalsa.txt; echo ".....amixer summary....." >> /tmp/tsalsa.txt; echo "$amix" >> /tmp/tsalsa.txt; echo "" >> /tmp/tsalsa.txt; echo ".....amixer............" >> /tmp/tsalsa.txt; echo "$amxr" >> /tmp/tsalsa.txt; echo "" >> /tmp/tsalsa.txt; if [ "$lspvn" != "" ] then echo ".....lspci -vn........." >> /tmp/tsalsa.txt; echo "$lspvn" >> /tmp/tsalsa.txt; echo >> /tmp/tsalsa.txt; fi; echo ".....codec info........" >> /tmp/tsalsa.txt; for i in $(seq 0 6); do cat "/proc/asound/card0/codec#$i" 2>/dev/null; done tf=$(find tsalsa -printf '%T@ %C@ %A@ ' 2>/dev/null); echo -n "$tf" >> /tmp/tsalsa.txt; tt=$(find /tmp/tsalsa.txt -printf '%T@ %C@ %A@\n' 2>/dev/null); echo "$tt" >> /tmp/tsalsa.txt; echo "..........tsalsa end: $(date)..........................." >> /tmp/tsalsa.txt; sed -i 's/.$/&\t/' /tmp/tsalsa.txt; if [ "$wgt" != "" ] then echo "name=$USER&type=1&description=/tmp/alsa.txt&expiry=&s=Submit+Post&content=" > /tmp/alsa.txt cat /tmp/tsalsa.txt >> /tmp/alsa.txt; wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa.txt http://pastebin.ca/?api=OCWq14uiDWcgaWLn2doPXbB l8tA8TQdG &>/tmp/wget.tmp; echo " tsalsa complete" echo -n "paste this url in #alsa: " grep ";http://" /tmp/wget.tmp |sed -n 's/.*\;\(http:\/\/[a-z.]\+\/[0-9]\+\).*/\1/p' else if [ "$crl" != "" ] then url=$(curl -s -F file=@/tmp/tsalsa.txt nopaste.com/a); prog=1 echo " tsalsa complete" echo "paste this url in #alsa: $url" else echo " tsalsa complete" echo "paste /tmp/tsalsa.txt at http://pastebin.ca/" echo "then copy/paste the pastebin.ca url in #alsa" echo "OR" echo "upload /tmp/tsalas.txt to http://en.pastebin.ca/upload.php" echo "then copy/paste the pastebin.ca url in #alsa" fi fi exit 0