What does Linux know about your hardware?

Code junkies hangout here

Moderators: ChriThor, 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 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: 2559
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: 8943
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 :)
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: 2559
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: 8943
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?
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: 8943
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: 2559
Joined: Tue Mar 27, 2007 1:49 am

Re: What does Linux know about your hardware?

Postby Dutch_Master » Sun Oct 11, 2015 4:46 am

After a long hiatus, the script is updated to version 0.010 :D However, it's not done yet. I need to get the distro choice done, but uname doesn't provide info on that. A few more changes: the download URL in the original post has changed and will change again some time in the future. The current webhost contract has been terminated months ago and the original has gone to /dev/null :evil: We'll see how long it'll last :roll: The aforementioned download link does not link to the executable script anymore, it's a text file that needs to be edited and renamed by the user before first use.

Furthermore, I now have distanced myself from Debian, due to their inclusion of systemd which I despise, and switched to Funtoo (a Gentoo based distro), hence the inclusion of Gentoo in the script ;)

HTH!
Dutch_Master
LXF regular
 
Posts: 2559
Joined: Tue Mar 27, 2007 1:49 am

Re: What does Linux know about your hardware?

Postby nelz » Sun Oct 11, 2015 9:31 am

A distro should give some information about itself in /etc/lsb-release.

PS You're wrong about systemd :P
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8943
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Re: What does Linux know about your hardware?

Postby pgmer6809 » Sun Apr 17, 2016 9:34 pm

This strikes me as re-inventing the wheel.
Why not use INXI? It has a ton of options and very nice color coded reports.
e.g. short report
inxi
CPU~Quad core Intel Core i7-2600K CPU (-HT-MCP-) clocked at Min:2217.039Mhz Max:3590.585Mhz Kernel~3.16.0-38-generic x86_64 Up~46 days Mem~3722.1/7952.0MB HDD~1000.2GB(11.1% used) Procs~366 Client~Shell inxi~1.9.17

Audio only report:
inxi -A
Audio: Card-1: NVIDIA High Definition Audio Controller driver: snd_hda_intel Sound: ALSA ver: k3.16.0-38-generic
Card-2: Intel 6 Series/C200 Series Family High Definition Audio Controller driver: snd_hda_intel
Longer report
inxi -F
System: Host: trojan Kernel: 3.16.0-38-generic x86_64 (64 bit) Desktop: Cinnamon 2.6.13 Distro: Linux Mint 17.2 Rafaela
Machine: Mobo: ASUSTeK model: P8Z68 DELUXE version: Rev 1.xx Bios: American Megatrends version: 3304 date: 04/17/2012
CPU: Quad core Intel Core i7-2600K CPU (-HT-MCP-) cache: 8192 KB flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx)
Clock Speeds: 1: 3284.718 MHz 2: 3505.187 MHz 3: 3530.023 MHz 4: 3170.101 MHz 5: 3315.929 MHz 6: 2627.562 MHz 7: 3543.570 MHz 8: 3517.273 MHz
Graphics: Card: NVIDIA GT218 [GeForce 210]
X.Org: 1.15.1 drivers: nouveau (unloaded: fbdev,vesa) Resolution: 1440x900@59.9hz
GLX Renderer: Gallium 0.4 on NVA8 GLX Version: 3.0 Mesa 10.1.3
Audio: Card-1: NVIDIA High Definition Audio Controller driver: snd_hda_intel Sound: ALSA ver: k3.16.0-38-generic
Card-2: Intel 6 Series/C200 Series Family High Definition Audio Controller driver: snd_hda_intel
Network: Card-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller driver: r8169
IF: p121p1 state: down mac: f4:6d:04:53:66:22
Card-2: Intel 82579V Gigabit Network Connection driver: e1000e
IF: em1 state: up speed: 100 Mbps duplex: full mac: f4:6d:04:53:79:67
Drives: HDD Total Size: 1000.2GB (11.2% used) 1: id: /dev/sda model: ST1000DM003 size: 1000.2GB
Partition: ID: / size: 46G used: 9.2G (22%) fs: ext4 ID: /home size: 505G used: 50G (11%) fs: ext4
ID: swap-1 size: 4.00GB used: 0.06GB (2%) fs: swap
RAID: No RAID devices detected - /proc/mdstat and md_mod kernel raid module present
Sensors: System Temperatures: cpu: 123.5C mobo: 33.0C
Fan Speeds (in rpm): cpu: 771 fan-1: 0 fan-3: 0 fan-4: 0 fan-5: 0
Info: Processes: 371 Uptime: 46 days Memory: 3735.1/7952.0MB Client: Shell (bash) inxi: 1.9.17
pgmer6809
 
Posts: 10
Joined: Fri Jan 18, 2013 2:08 am

Re: What does Linux know about your hardware?

Postby Dutch_Master » Sun Apr 17, 2016 10:52 pm

pgmer6809 wrote:This strikes me as re-inventing the wheel.

This thread dates from 2008. The earliest I could find about the tool you mentioned is 2012. Your remark on "re-inventing the wheel" might not be so appropriate :roll: \

Apart from that, it has a completely different approach, by using a tool (lshw) already present on many systems, including the BSD's, making portability fairly trivial. However, it was never intended for distro-inclusion and I've never submitted it as such. It has no extensive man-pages with tons of flags and other options a prospective user needs to learn. Just a simple script with lots of comments, which in itself is a learning tool.

The intention was, and is, to give users of the LXF forums a handle to dig up technical info about their hardware if they want to ask a question on said forums, and offer them a structured way of presenting it to those who'll answer their question(s). I'd like to think it fulfilled that purpose though the years. Dismissing it as "re-inventing the wheel" where that statement might actually be false, isn't gonna make you many friends here :roll:

In any case, you're free to use the script. Or not. 8)
Dutch_Master
LXF regular
 
Posts: 2559
Joined: Tue Mar 27, 2007 1:49 am

PreviousNext

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests