Shell script to display general FreeBSD and Linux System information such as, Hostname, OS version, Kernel version, Processor/CPU, Total RAM, System load, network interface, total logged in users, Hard disks, Runlevel etc in neat format.
How do I use the script?
You need to download following two files for FreeBSD operating systems:
- File # 1 Save this file as /usr/local/etc/bashmonscripts
- File # 2 : Save this file as /usr/local/etc/defaults.conf
For Linux system, you need to update /usr/local/etc/defaults.conf to point out exact binary path location. /usr/local/etc/bashmonscripts is nothing but functions library used by this script. bashmonscripts works under both Linux and FreeBSD.
#!/bin/bash # Shell script to General FreeBSD and Linux System information such as: # Hostname, OS version, Kernel version, Processor/CPU, Total RAM, # System load, network interface, total logged in users, Hard disks, # Runlevel etc. I will write separate scripts for detailed system # information :D # Copyright (c) 2005 nixCraft project # This script is licensed under GNU GPL version 2.0 or above # For more info, please visit: # http://cyberciti.biz/shell_scripting/bmsinstall.php # ------------------------------------------------------------------------- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # ------------------------------------------------------------------------- SPATH="/usr/local/etc/bashmonscripts" INITBMS="$SPATH/defaults.conf" [ ! -f $INITBMS ] && exit 1 || . $INITBMS echo "Hostname:" $(getHostName) echo "OS Name:" $($UNAME) echo "OS Version:" $($UNAME -mr) echo "Processor:" $(getCpuInfo) echo "Total Physical Memory (RAM):" $(getRealRamInfo) echo "System Load:" $(getSystemLoad) echo "Date & Time:" $($DATE) echo "Network interface:" $(getNumberOfInterfaces) echo "Total logged in users:" $(getNumberOfLoggedInUsers) echo "Total running process:" $(getNumberOfRunningProcess) echo "Total SCSI/IDE disks:" $(getDiskDrives) echo "Mounted partitions:" $(getNumberOfParittions) echo "Loaded dynamic kernel modules/drivers:" $(getNumberOfKernelModules) echo "OS Rulevel:" $(getOsRunLevel)
- Download Script
- Email this to a friend
- Rss Feed
- Last Updated: 02/26/09
{ 4 comments… read them below or add one }
hi can someone tell me how to use this script.
I have done chmod + secript
and bash script.sh
its still doesnt work can someone enlighten me?
you probably dont have the path specified in the above script /usr/local/etc/bashmonscript.
This page has been updated. Download other two files and you should able to run script.
This doesn’t seem to work and I can not figure out why.. well I don’t ever see where SPATH is used..
15
16 SPATH=”/root/blah/bashmonscripts”
17 INITBMS=”/root/blah/defaults.conf”
18 [ ! -f $INITBMS ] && exit 1 || . $INITBMS
19
saving the above script as ’script’ and then making it 755.. and saving the other two files and naming them correctly..
and adding -x to the ’script’..
[~/blah]# 79 > ./script
+ SPATH=/root/blah/bashmonscripts
+ INITBMS=/root/blah/defaults.conf
+ ‘[' '!' -f /root/blah/defaults.conf ']‘
+ . /root/blah/defaults.conf
++ SHADOW_FILE=/etc/master.passwd
++ PASSWD_FILE=/etc/passwd
++ DF=/bin/df
++ DATE=/bin/date
++ HOSTNAME=/bin/hostname
++ CAT=/bin/cat
++ PS=/bin/ps
++ AWK=/usr/bin/awk
++ GREP=/usr/bin/grep
++ LASTLOG=/usr/bin/lastlog
++ ID=/usr/bin/id
++ UNAME=/usr/bin/uname
++ BASENAME=/usr/bin/basename
++ LAST=/usr/bin/last
++ LASTLOGIN=/usr/sbin/lastlogin
++ FIND=/usr/bin/find
++ UPTIME=/usr/bin/uptime
++ HEAD=/usr/bin/head
++ CUT=/usr/bin/cut
++ W=/usr/bin/w
++ WC=/usr/bin/wc
++ IFCONFIG=/sbin/ifconfig
++ DMESG=/sbin/dmesg
++ KLDSTAT=/sbin/kldstat
++ SYSCTL=/sbin/sysctl
++ IOSTAT=/usr/sbin/iostat
++ getHostName
./script: line 20: getHostName: command not found
+ echo Hostname:
Hostname:
++ /usr/bin/uname
+ echo ‘OS Name:’ FreeBSD
OS Name: FreeBSD
++ /usr/bin/uname -mr
+ echo ‘OS Version:’ 7.1-RELEASE-p2 i386
OS Version: 7.1-RELEASE-p2 i386
++ getCpuInfo
./script: line 23: getCpuInfo: command not found
+ echo Processor:
… etc
Where does it ever get/use/need SPATH?