What does Linux know about your hardware?

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

Postby Dutch_Master » Wed Oct 15, 2008 1:13 am

Update 3: I managed to get Mandriva 2009 running and lo-and-behold, it has the lshw package as well :) Ran the latest version (0.003 as per the link) w/o any problems. Good, even 1sf (troll) can use it now :P Can somebody confirm that Fedora and Suse has the lshw package in their repo's as well? If that's the case it's safe to assume (IMO!) that the lshw package is generally available for Linux and the script doesn't need tweaking in that respect.

Suggestions and contributions are still welcome! (and properly credited if you put your real name in your message!)
Dutch_Master
LXF regular
 
Posts: 2471
Joined: Tue Mar 27, 2007 1:49 am

Postby nelz » Wed Oct 15, 2008 8:23 am

lshw is pretty standard, but if you use something like the code in my first reply you're covered either way.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8579
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Postby AdamW » Thu Oct 23, 2008 3:48 am

Mandriva also provides lspcidrake , which will give you the Mandriva driver mappings, device description, and (with -v) the USB or PCI ID in a fairly concise and parseable form.
Adam Williamson
Mandriva
Community manager | Newsletter editor | Bugmaster | Proofreader | Translator | Packager
AdamW
 
Posts: 51
Joined: Wed Apr 16, 2008 11:45 pm

Postby ollie » Fri Oct 24, 2008 1:30 am

Hi Dutch_Master,

I've been playing around with your script :D and realised I may have introduced a slight error with the code snippet I introduced. :( :oops:

The out put of the script is much more useful if it is continually appended to the "mysystem.txt" file. I missed a ">" with my code when setting the date/time the script was run. The full script should be:
Code: Select all
#! /bin/bash
#
# script to collect hardware and software data on your system
# you'll need to be root to get proper results
# currently only works in Debian based systems, with the lshw package installed
# with contributions by Nelz and Ollie from the LXF forums

# when did you last run this script?
echo ========= >> mysystem.txt
echo "System info at:" `date` >> mysystem.txt
echo ========= >> mysystem.txt
# what kernel are you running?
echo "uname -a:" >> mysystem.txt
uname -a >> mysystem.txt
echo ========= >> mysystem.txt
# check if lshw is installed, then find out all you want from your hardware with lshw
if which lshw &>/dev/null; then
   lshw >> mysystem.txt
else
   echo "You need to install lshw to use this script!"
fi
echo ========= >> mysystem.txt
chmod 644 mysystem.txt
echo "done! read the file mysystem.txt in the current directory"
echo "use the cat and grep commands to select sections of interest if you're on the commandline"

exit 0


PS - I also recommend adding a version number to the comments at the top of the script :)
User avatar
ollie
Moderator
 
Posts: 2749
Joined: Mon Jul 25, 2005 11:26 am
Location: Bathurst NSW Australia

Postby Dutch_Master » Fri Oct 24, 2008 2:42 am

Ah, I see your change. Well, it works w/o the extra > which really is only cosmetic, isn't it? Version inclusion makes sense: it's in. I'll add the extra > though ;)

Version 0.004 is available on the link in my original post on page 1 :)

@AdamW: good to know, but that wasn't the intention of my script. This one is purely for gathering info on one's hardware as sometimes we get questions that require a bit more knowledge on the questionaire's hardware. I'm sure you, as a Mandriva dev, has experience with similar situations too, so feel free to use the script in Mandriva. Not yet decided on a licence, but it's free now and in the future. Hmm, given it relies on GPL software, there's an obvious choice here I guess? GPL then it is :)
Dutch_Master
LXF regular
 
Posts: 2471
Joined: Tue Mar 27, 2007 1:49 am

Postby nelz » Fri Oct 24, 2008 7:55 am

It's more than cosmetic, if you use > and the file already exists, it will be overwritten, unless you have the noclobber option set in your shell. In which case the script will bomb out with an error.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8579
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Postby AdamW » Fri Oct 24, 2008 7:59 pm

Dutch: yep, I was just adding it for information. Your script is neat, but I'm used to just using the output of lspcidrake -v. It provides everything I need to know for most issues - a vague idea of what the hardware actually is, its PCI / USB ID (always the most important thing, and the reason I hate lspci - neither lspci nor lspci -v lists the PCI ID by default, only lspci -n does...I mean, sheesh), and its default driver mapping. Of course, for a cross-distro effort, something generic like your script is needed.
Adam Williamson
Mandriva
Community manager | Newsletter editor | Bugmaster | Proofreader | Translator | Packager
AdamW
 
Posts: 51
Joined: Wed Apr 16, 2008 11:45 pm

Postby SMcE » Tue Jan 06, 2009 4:21 pm

Thanks Dutch_Master&friends for a very useful script. Now, if it just told me what version of Ubuntu I am using, it would be just perfect (at least I think it's Ubuntu, should never have changed that desktop wallpaper...)

A quick&dirty google gives me:
$ cat /etc/issue
Ubuntu 8.04 \n \l

Which is pretty much what I needed to know, apart from the annoying formatting characters. lsb-release goes a bit futher for me:
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04"

(so it's Hardy!!) but funnily running lsb_release gives me:
$ lsb_release -v
No LSB modules are available.

Can anybody improve on these??
User avatar
SMcE
 
Posts: 10
Joined: Sun Jul 31, 2005 7:23 am

Postby ollie » Sun Mar 08, 2009 5:46 am

I was starting to play around with getting more distro details as well SMcE and looked at "cat /etc/issue" and "cat /proc/version" instead of "uname -a" and "cat/lsb-release" provides more detail that is useful. So I have changed the script to:
Code: Select all
#! /bin/bash
#
# script to collect hardware and software data on your system
# you'll need to be root to get proper results
# tested on Debian based systems, with the required lshw package
# installed and Mandriva 2009, who has the lshw package as well
# other distributions may work, if the lshw package is avalable and installed
# with contributions by Nelz and Ollie from the LXF forums
# see http://www.linuxformat.co.uk/index.php?name=PNphpBB2&file=viewtopic&t=8332
# this script is released under the GPL: http://www.gnu.org/copyleft/gpl.html
# current version: 0.005

# when did you last run this script?
echo ========= >> mysystem.txt
echo "System info at:" `date` >> mysystem.txt
echo ========= >> mysystem.txt
# what kernel are you running?
echo "Kernel details:" >> mysystem.txt
cat /proc/version >>mysystem.txt
echo "Distro LSB details:" >> mysystem.txt
cat /etc/lsb-release >> mysystem.txt
echo ========= >> mysystem.txt
# check if lshw is installed, then find out all you want from your hardware with lshw
if which lshw &>/dev/null; then
   lshw >> mysystem.txt
else
   echo "You need to install lshw to use this script!"
fi
echo ========= >> mysystem.txt
chmod 644 mysystem.txt
echo "Done! Read the file mysystem.txt in the current directory"
echo "Use the cat and grep commands to select sections of interest if you're on the commandline"
echo "Or open this file in a graphical editor like Kwrite or Gedit. Please, do not use Notepad!!"

exit 0


Do you think this is a useful update DM?
User avatar
ollie
Moderator
 
Posts: 2749
Joined: Mon Jul 25, 2005 11:26 am
Location: Bathurst NSW Australia

Postby nelz » Sun Mar 08, 2009 10:34 am

/etc/lsb-release isn't always there. Some distros install the LSB stuff as a separate, optional, package and for other distros it is just not relevant. To avoid the script aborting when the file isn't found, use

Code: Select all
[[ -f /etc/lsb-release ]] && cat /etc/lsb-release >> mysystem.txt
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8579
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Postby Dutch_Master » Sat Oct 09, 2010 3:58 am

Admittedly "a tad" :roll: late, but version 0.006 as per Ollie and Nelz's suggestions can be found on the link in the original post on page 1. Unless some-one has a serious issue with it, it might be worth putting a Sticky on this thread for future (pun intended) visitors. (Mike, that's a hint ;)) And moving it to the Help section might improve its usage too :P
Dutch_Master
LXF regular
 
Posts: 2471
Joined: Tue Mar 27, 2007 1:49 am

Previous

Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests