head	1.6;
access;
symbols
	REL_0_07:1.3
	arelease:1.1.1.2
	avendor:1.1.1;
locks; strict;
comment	@# @;


1.6
date	2005.02.04.06.15.21;	author chaeya;	state Exp;
branches;
next	1.5;

1.5
date	2005.02.02.05.38.28;	author chaeya;	state Exp;
branches;
next	1.4;

1.4
date	2005.02.02.05.25.11;	author chaeya;	state Exp;
branches;
next	1.3;

1.3
date	2005.01.12.02.27.50;	author chaeya;	state Exp;
branches;
next	1.2;

1.2
date	2005.01.05.02.36.24;	author chaeya;	state Exp;
branches;
next	1.1;

1.1
date	2004.12.26.05.48.29;	author chaeya;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2004.12.26.05.48.29;	author chaeya;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2005.01.05.02.01.49;	author chaeya;	state Exp;
branches;
next	;


desc
@@


1.6
log
@white console message patch
@
text
@#!/bin/bash
#Copyright (c) 2004, OSTSC(http://help.oss.or.kr)
#All rights reserved.

#This software is provide to find your system infomation.
#2004.12.22 
#eful@@superuser.co.kr

PVER="sysinfo v0.08 (http://help.oss.or.kr)";
# ANSI COLORS
NORMAL="\033[0;39m"
# RED
RED="\033[1;31m"
# GREEN
GREEN="\033[1;32m"
# YELLOW
YELLOW="\033[1;33m"
# BLUE
BLUE="\033[1;34m"
# LCYAN
LCYAN="\033[1;36m"
# CYAN
CYAN="\033[0;36m"
# BOLD NORMAL
WHITE="\033[1;37m"

######### Print help message #####
print_help () {
	echo -e ${NORMAL}
	echo "Usage: sysinfo -h | --help | -v | --version | -e | --export | -a | --all"
	echo
	echo "    -h,--help       Print this help message and exit"
	echo "    -v,--version    Print version and exit"
	echo "    -e,--export     Make report file - result.txt "
	echo "    -a,--all        Show system infomation and Make report file"
	echo ""
	echo "Report bugs to <eful@@superuser.co.kr>."
	echo -e ${NORMAL}
}

######## Print Program Version ###
print_version () {
	echo -e ${NORMAL}
	echo "sysinfo version ${PVER}"
	echo -e ${NORMAL}
}

######## root user check #######
check_root () {
	# user id check
	[ `id -u` -ne 0 ] && {
		echo -e "${RED}This program must be run by the root user${NORMAL}"
		exit 0
	}
}
	

####### Starting System Detect #######
print_info () {
	########### Print User Message ############
	#clear
	echo ""
	echo -e "${YELLOW}$PVER"
	echo -e "${LCYAN}Starting System Detect...${NORMAL}  :"
	echo "-----------------------------------------------------------"

	########## Print OS, architecture , Kernel , hostname , date ####
	ARCHTYPE=`/bin/uname -m`
	SYSTEMHOSTNAME=`hostname`
	TIMEOFREPORT=`date`
	OSNAME=`cat /proc/version | cut -d "#" -f 1|cut -d "(" -f 4| sed 's/))//g'`
	SYSINFO=`uname -a`
	KVER=`uname -r`
	echo -e "${BLUE}OS NAME : ${NORMAL}$OSNAME"
	echo -e "${BLUE}Release Info : ${NORMAL}"
	echo -e "$(cat /etc/*-release)"
	echo -e "${BLUE}Kernel Version : ${NORMAL}$KVER${NORMAL}";
	echo -e "${BLUE}Architecture : ${NORMAL}$ARCHTYPE"
	echo -e "${BLUE}System Hostname : ${NORMAL}$SYSTEMHOSTNAME"
	echo -e "${BLUE}Time of Report : ${NORMAL}$TIMEOFREPORT"
	echo -e "${BLUE}System Info : ${NORMAL}$SYSINFO"

	######## Print gcc version #############
	if [ -f /usr/bin/gcc ]; then
		GCCVER=$(gcc --version | grep gcc);
		echo -en "${BLUE}GCC Version :${NORMAL}"
		echo -e " ${GCCVER}"
	else 
		echo -en "${BLUE}GCC Version :${NORMAL}"
		echo -e " can not find gcc"
	fi

	######## Print glibc version #############
	if [ -f /usr/bin/ldd ]; then
		GLVER=$(ldd --version | grep ldd);
		echo -en "${BLUE}Glibc Version :${NORMAL}"
		echo -e " ${GLVER}"
	else 
		echo -en "${BLUE}Glibc Version :${NORMAL}"
		echo -e "can not find ldd"
	fi

	########### Print CPU info ##########################
	echo -e "${BLUE}CPU & Cache${NORMAL} : ${NORMAL}";
	if [ ! -f /proc/cpuinfo ]; then
		echo "*** Can't find /proc/cpuinfo! This means that /proc isn't mounted. ***"
		echo "*** Mount /proc and try again. ***"
	else
		awk -F: '/^processor/{printf "Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf " vendor"$2};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>/dev/null
	fi
	echo -en "${NORMAL}"
	echo ""

	#### Print memory infomation #####################
	set `cat /proc/meminfo`
	NDIR=$(pwd)
	cd /tmp
	grep MemTotal /proc/meminfo >sch1.tmp
	awk '{ print $2 }' sch1.tmp >sch2.tmp
	MemTot="$(cat sch2.tmp)"
	rm *.tmp

	grep MemFree /proc/meminfo >sch1.tmp
	awk '{ print $2 }' sch1.tmp >sch2.tmp
	MemFree="$(cat sch2.tmp)"
	rm *.tmp

	Memunused=$[($MemTot - $MemFree) * 100 / $MemTot]

	grep SwapTotal /proc/meminfo >sch1.tmp
	awk '{ print $2 }' sch1.tmp >sch2.tmp
	SwapTot="$(cat sch2.tmp)"
	rm *.tmp

	grep SwapFree /proc/meminfo >sch1.tmp
	awk '{ print $2 }' sch1.tmp >sch2.tmp
	SwapFree="$(cat sch2.tmp)"
	rm *.tmp

	if [ ! "${SwapTot}" = 0 ]; then
		Swapunused=$[($SwapTot - $SwapFree) * 100 / $SwapTot]
	else
		Swapunused=$[$SwapTot]
	fi

	# Write memory, swap, shared, buffer
	echo -e "${BLUE}Memory info      Size(MB) Free(MB) Full %"
	echo -en " Memory        : ${NORMAL}"
	echo -n $[$MemTot / 1024] "     "
	echo -n $[$MemFree / 1024] "        "
	echo "$Memunused%"

	echo -en "${BLUE} Swap          : ${NORMAL}"
	echo -n $[$SwapTot / 1024] "     "
	echo -n $[$SwapFree / 1024] "      "
	echo "  $Swapunused%"

	# print df 
	echo ""
	echo -e "${BLUE}MountPoint	  Usage		Size(MB)	${GREEN}Free(MB)${NORMAL}	${YELLOW}Full(%)${NORMAL}" 

	df | awk -v lngth="10"\
 	'BEGIN {getline;l=lngth;}
 			{
 				tot=$3*l/$2+1; 
 				printf("%s%-14s%s", " ", $6, ": ");

				for (i=1; i<l+1; i++) {
  					if ( i < tot ) { printf("%s%s", "\033[32;41m" , " ") }
  					else { printf("%s%s", "\033[32;42m" , " ") }
  				} 
 			printf("%s%-5s%-16s%-15s%6.2f %s","\033[m"," ", $2 / 1024 , $4 / 1024 , ($2 - $4) * 100 / $2, "%");
 			print("");
 			}
 	END{printf(normal)}'
	cd $NDIR

	############### Print pci device infomation #########################
	############### lspci util and pcitable file dependence #############
	
	if [ -f /etc/sysinfo/pcitable ]; then
		if [ -f /sbin/lspci ]; then
			echo ""
			echo -e "${BLUE}PCI DEVICE${NORMAL}"
			lspci -n > lspci.list
			awk '{print $4}' lspci.list | sed 's|:| |g' | awk '{print "0x" $1}' > id.tmp
			awk '{print $4}' lspci.list | sed 's|:| |g' | awk '{print "0x" $2}' > vd.tmp
			grep --file=id.tmp /etc/sysinfo/pcitable > sch2.tmp
			grep --file=vd.tmp  sch2.tmp > pci1.tmp
			sed 's|0x||g' pci1.tmp > pci2.tmp
			echo -e "${BLUE}VendID  DevID   Module          Description${NORMAL}"
			cat pci2.tmp
			rm -f *.tmp lspci.list
		else 
			echo -e "can not find /sbin/lspci"
			echo -e "pciutils from http://atrey.karlin.mff.cuni.cz/~mj/pciutils.shtml or your Linux vendor."
		fi
	else
		echo -e "can not find pcitable file"
		echo -e "pcitable from http://cvs.mandrakesoft.com/cgi-bin/cvsweb.cgi/soft/ldetect-lst/lst/pcitable"
	fi

}

####### print output file
print_file () {
        ARCHTYPE=`/bin/uname -m`
        SYSTEMHOSTNAME=`hostname`
        TIMEOFREPORT=`date`
	OSNAME=`cat /proc/version | cut -d "#" -f 1|cut -d "(" -f 4| sed 's/))//g'`
        SYSINFO=`uname -a`
        KVER=`uname -r`
	MYIFS="="
        echo -e "$PVER" > /tmp/result.txt
        echo -e "$TIMEOFREPORT" >> /tmp/result.txt
        echo "-----------------------------------------------------------" >> /tmp/result.txt
        echo -e "OS NAME ${MYIFS} $OSNAME" >> /tmp/result.txt
        echo -e "Kernel Version ${MYIFS} $KVER" >> /tmp/result.txt
        echo -e "Architecture ${MYIFS} $ARCHTYPE" >> /tmp/result.txt
        echo -e "System Hostname ${MYIFS} $SYSTEMHOSTNAME" >> /tmp/result.txt
        echo -e "Time of Report ${MYIFS} $TIMEOFREPORT" >> /tmp/result.txt
        echo -e "System Info ${MYIFS} $SYSINFO" >> /tmp/result.txt
        if [ -f /usr/bin/gcc ]; then
                GCCVER=$(gcc --version | grep gcc);
                echo -e "GCC Version ${MYIFS} $GCCVER" >> /tmp/result.txt
        else echo -e "GCC Version ${MYIFS} can not find gcc" >> /tmp/result.txt
        fi
        if [ -f /usr/bin/ldd ]; then
                GLVER=$(ldd --version | grep ldd);
                echo -e "Glibc Version ${MYIFS} $GLVER" >> /tmp/result.txt
        else echo -e "Glibc Version ${MYIFS} can not find ldd" >> /tmp/result.txt
        fi
	mv -f /tmp/result.txt .
	echo -e "${NORMAL}"
	echo -e "Created ${RED}result.txt${NORMAL} file${NORMAL}"
}

### main process
case $1 in
 -h|--help) print_help ;;
 -v|--version) print_version ;;
 -e|--export) print_file ;;
 -a|--all)  check_root;print_info;print_file ;;
 *) check_root;print_info;print_file
  exit 0
  ;;

esac
@


1.5
log
@change report file string
@
text
@d24 1
a24 1
# BOLD WHITE
d29 1
a29 1
	echo -e ${WHITE}
d43 1
a43 1
	echo -e ${WHITE}
d74 2
a75 2
	echo -e "${BLUE}OS NAME : ${WHITE}$OSNAME"
	echo -e "${BLUE}Release Info : ${WHITE}"
d77 5
a81 5
	echo -e "${BLUE}Kernel Version : ${WHITE}$KVER${NORMAL}";
	echo -e "${BLUE}Architecture : ${WHITE}$ARCHTYPE"
	echo -e "${BLUE}System Hostname : ${WHITE}$SYSTEMHOSTNAME"
	echo -e "${BLUE}Time of Report : ${WHITE}$TIMEOFREPORT"
	echo -e "${BLUE}System Info : ${WHITE}$SYSINFO"
d86 1
a86 1
		echo -en "${BLUE}GCC Version :${WHITE}"
d89 1
a89 1
		echo -en "${BLUE}GCC Version :${WHITE}"
d96 1
a96 1
		echo -en "${BLUE}Glibc Version :${WHITE}"
d99 1
a99 1
		echo -en "${BLUE}Glibc Version :${WHITE}"
d104 1
a104 1
	echo -e "${BLUE}CPU & Cache${NORMAL} : ${WHITE}";
d148 1
a148 1
	echo -en " Memory        : ${WHITE}"
d153 1
a153 1
	echo -en "${BLUE} Swap          : ${WHITE}"
d160 1
a160 1
	echo -e "${BLUE}MountPoint	  Usage		Size(MB)	${GREEN}Free(MB)${WHITE}	${YELLOW}Full(%)${WHITE}" 
d184 1
a184 1
			echo -e "${BLUE}PCI DEVICE${WHITE}"
d191 1
a191 1
			echo -e "${BLUE}VendID  DevID   Module          Description${WHITE}"
@


1.4
log
@Change report file name
@
text
@d234 2
a235 1
	echo -e "Created result.txt file${NORMAL}"
@


1.3
log
@default option change
@
text
@d9 1
a9 1
PVER="sysinfo v0.07 (http://help.oss.or.kr)";
d34 1
a34 1
	echo "    -e,--export     Make report file - sysinfo.txt "
d214 9
a222 9
        echo -e "$PVER" > /tmp/sysinfo.txt
        echo -e "$TIMEOFREPORT" >> /tmp/sysinfo.txt
        echo "-----------------------------------------------------------" >> /tmp/sysinfo.txt
        echo -e "OS NAME ${MYIFS} $OSNAME" >> /tmp/sysinfo.txt
        echo -e "Kernel Version ${MYIFS} $KVER" >> /tmp/sysinfo.txt
        echo -e "Architecture ${MYIFS} $ARCHTYPE" >> /tmp/sysinfo.txt
        echo -e "System Hostname ${MYIFS} $SYSTEMHOSTNAME" >> /tmp/sysinfo.txt
        echo -e "Time of Report ${MYIFS} $TIMEOFREPORT" >> /tmp/sysinfo.txt
        echo -e "System Info ${MYIFS} $SYSINFO" >> /tmp/sysinfo.txt
d225 2
a226 2
                echo -e "GCC Version ${MYIFS} $GCCVER" >> /tmp/sysinfo.txt
        else echo -e "GCC Version ${MYIFS} can not find gcc" >> /tmp/sysinfo.txt
d230 2
a231 2
                echo -e "Glibc Version ${MYIFS} $GLVER" >> /tmp/sysinfo.txt
        else echo -e "Glibc Version ${MYIFS} can not find ldd" >> /tmp/sysinfo.txt
d233 2
a234 2
	mv -f /tmp/sysinfo.txt .
	echo -e "Created sysinfo.txt file${NORMAL}"
d247 1
a247 1
esac@


1.2
log
@*** empty log message ***
@
text
@d35 1
a35 1
	echo "    -a,--all        Print all system infomation and exit"
d243 1
a243 1
 *) print_help
d247 1
a247 1
esac
@


1.1
log
@Initial revision
@
text
@d9 1
a9 1
PVER="sysinfo v0.06 (http://help.oss.or.kr)";
d109 1
a109 1
		awk -F: '/^processor/{printf "Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>/dev/null
a144 1
		
@


1.1.1.1
log
@no message
@
text
@@


1.1.1.2
log
@no message
@
text
@d9 1
a9 1
PVER="sysinfo v0.07 (http://help.oss.or.kr)";
d109 1
a109 1
		awk -F: '/^processor/{printf "Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf "vendor" $2};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>/dev/null
d145 1
@

