Tool

jrecord's picture
tool
Reads:

11123

Score:
3
3
5
 
Comments:

10

Host Information at Login

Author Info

1 August 2008 - 7:27am
Submitted by: jrecord

(View Disclaimer)

download url: 
http://download.opensuse.org/repositories/Novell:/NTS/SLE_10/noarch/hostinfo-0.55-2.1.noarch.rpm
license: 
GPLv2

Download Now

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

  1. Remove the previous package
  2. rpm -e hostinfo

  3. Download the current hostinfo RPM package
  4. Install the hostinfo RPM package
  5. rpm -ivh hostinfo-0.55-2.noarch.rpm

  6. Use the "hi" alias to see the current information
  7. You can add a "Function" line by creating a single line file called /opt/hostinfo-function.txt
  8. You can add an "Owner" line with /opt/hostinfo-owner.txt

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.

Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).

It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.




User Comments

AndyDeck's picture

Slanted towards SLES as root?

Submitted by AndyDeck on 22 January 2008 - 1:46pm.

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.

mfaris01's picture

Slanted towards SLES as root?

Submitted by mfaris01 on 22 January 2008 - 3:02pm.

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.

jrecord's picture

Slanted towards SLES as root?

Submitted by jrecord on 25 January 2008 - 9:16am.

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

Anonymous's picture

Did you find a fix for

Submitted by Anonymous on 12 December 2008 - 9:29pm.

Did you find a fix for this?
Thanks in advance

-Dan Saltman

peterhine's picture

df -h

Submitted by peterhine on 28 January 2008 - 1:13am.

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

jrecord's picture

df -h

Submitted by jrecord on 28 January 2008 - 11:15am.

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

AndyDeck's picture

using /proc/partitions

Submitted by AndyDeck on 19 February 2008 - 9:43am.

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 "\"):

DISK_SIZE="$(fdisk -l 2>/dev/null 
\ | grep ^Disk | egrep 'sda|hda|xvda' 
\ | head -1 |  awk '{print $2, $3, $4}' | cut -d',' -f1)"
if [ -z $DISK_SIZE]; then
  DISK_SIZE="$(egrep 'sda|hda|xvda' /proc/partitions 
\ | head -1 |  awk '{print $3 *1024/(1000*1000*1000)}')"
  DISK_SIZE="$(egrep 'sda|hda|xvda' /proc/partitions 
\ | head -1 |  awk '{print "/dev/"$4":"}') $DISK_SIZE GB"
fi

Then, replace the print statement with this to use the new calculated values:

printf "$ROW_OUT" "Hard Disk:" "$DISK_SIZE"
jrecord's picture

Thanks for the Feedback

Submitted by jrecord on 26 February 2008 - 11:15am.

Thanks everyone for the feedback. The updated version should work out for everyone. Please let me know if you have anymore ideas for it.

keutterling's picture

partitions at a hp server

Submitted by keutterling on 7 March 2008 - 5:22pm.

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 :)

jrecord's picture

partitions on hp server

Submitted by jrecord on 10 March 2008 - 3:06pm.

Great idea, I've added it to the next release.

© 2013 Novell