Host Information at Login
The hostinfo command creates a quick summary of the server at login time. It is especially useful in environments with a lot of servers at different OS levels. The summary looks like this:
--[ hostinfo v0.55-2 ]------------------------------------ Hostname: jrecord4 Current As Of: 08/01/08 09:35:56 Distribution: SUSE Linux Enterprise Server 10 Service Pack: 1 Kernel Version: 2.6.16.46-0.12-default Architecture: i386 IPv4 Address: 137.65.55.73 eth0 (static) IPv4 Address: 192.168.20.20 eth1 (static) Total/Free Memory: 504/8 MB Hard Disk: /dev/sda 8 GB Hard Disk: /dev/sdb 8 GB Hard Disk: /dev/sdc 3 GB User Logged In: uid=0(root) gid=0(root) on pts0 Owner: Jason Record Function: Test Server -----------------------------------------------------------
You can also create an html page with the same information, by running hostinfo -w > info.html.
Installation Instructions
- Remove the previous package
- Download the current hostinfo RPM package
- Install the hostinfo RPM package
- Use the “hi” alias to see the current information
- You can add a “Function” line by creating a single line file called /opt/hostinfo-function.txt
- You can add an “Owner” line with /opt/hostinfo-owner.txt
rpm -e hostinfo
rpm -ivh hostinfo-0.55-2.noarch.rpm
Version 0.55-2
- Added the tty for login
- Added the -i switch for hostinfo to replace the /etc/issue file
- Added free memory
- Added -f to include free disk space. However this only works if the df output includes the same devices as the /proc/partitions.
Version 0.51-8
- Added hostinfo(5)
- Includes all ethernet addresses found
- Added -t and -T sec switches for a timer. The default is 30 seconds with -t.
- Added -f to include free disk space, but this only works for mounted partitions found in /proc/partitions.
- Free memory is not reported along with total memory.
Version 0.30-5
- Added cciss support
- Added a <title> tag to the -w output
- If the network is not configured, an error displayed. The error no longer displays.
(Visited 1 times, 1 visits today)
Related Articles
Oct 01st, 2024
SUSE Documentation redefined — Meet the new doc portal
Sep 26th, 2024
Comments
The app as written appears slanted towards running on SLES as root:for example, the Service Pack entry is blank on OpenSuSE 10.1, and the Hard Disk info from fdisk cannot be filled in by a regular user. There’s also a conflict with NoMachine’s NX software, apparently – I get errors from NX when hostinfo is set to run in /etc/profile.local that go away when hostinfo is removed.
If you look in the example jrecord submitted, you’ll see that the user is root. His note of a redirect to an HTML page could be run in a script with sudo and the “regular” users could still get the data.
Yes, it is slanted a bit toward SLES and root. The disk information comes from the fdisk command, which is root only. The service pack is correct on OpenSuSE 10.1, because it does not have a service pack. OpenSuSE 10.3 for example is a different product without any service packs. I am considering a way to get the disk information as a non root user though. Using /proc/partitions for example. Thanks for the feedback!
-jason
You could use ‘df -h’. it is available to everyone.
eg:
admin@server:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 97G 17G 80G 18% /
tmpfs 2.0G 56K 2.0G 1% /dev/shm
/dev/sda1 99M 11M 84M 12% /boot
/dev/evms/DATA 450G 264G 186G 59% /opt/novell/nss/mnt/.pools/DATA
admin 4.0M 0 4.0M 0% /_admin
DATA 118G 87G 31G 75% /media/nss/DATA
SOFTWARE 157G 125G 32G 80% /media/nss/SOFTWARE
MASTER 98G 51G 48G 52% /media/nss/MASTER
Yes it would work. Currently I only pick one disk, and the first disk the OS detects. Really I need to determine what the “Hard Disk” label is going to mean. The intent is to show the size of disk in the server available for use. However, I currently only show the first disk detected by fdisk. What I probably need to do is enhance the script to show all disks and their sizes. If I use /proc/partitions in association with df output, I could probably get what I want. I could also get the information from /proc/parititons, once I figure out how to calculate the number given in the output. I just haven’t taken the time yet.
-jason
This was nagging at me too, so I figured out a method that comes pretty close to producing identical output for non-root users (un-wrap the lines at the “”):
Then, replace the print statement with this to use the new calculated values:
Thanks everyone for the feedback. The updated version should work out for everyone. Please let me know if you have anymore ideas for it.
Could you change the partions matching regexp to:
‘[s,h,xv,c][0-9]?d[a-z,0-9]$’
# cat /proc/partitions
major minor #blocks name
104 0 35561280 cciss/c0d0
104 1 1052226 cciss/c0d0p1
104 2 34507620 cciss/c0d0p2
7 0 4460422 loop0
thx 🙂
Great idea, I’ve added it to the next release.
Did you find a fix for this?
Thanks in advance
-Dan Saltman