Host Information at Login

Share

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.
(Visited 1 times, 1 visits today)

Comments

  • Avatar photo AndyDeck says:

    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.

  • Avatar photo mfaris01 says:

    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.

  • Avatar photo jrecord says:

    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

  • Avatar photo peterhine says:

    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

  • Avatar photo jrecord says:

    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

  • Avatar photo AndyDeck says:

    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"
  • Avatar photo jrecord says:

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

  • Avatar photo keutterling says:

    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 🙂

  • Avatar photo jrecord says:

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

  • Avatar photo Anonymous says:

    Did you find a fix for this?
    Thanks in advance

    -Dan Saltman

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    Avatar photo
    6,650 views