#/bin/sh # simple script to give a summary of system information # License: LGPLv2 # Author: # http://www.pixelbeat.org/ # Notes: # Unless you run as root, disk info can't be shown # Changes: # V0.1, 16 Nov 2005, Initial release # V0.s, 22 Oct 2007, Tweak to ensure cdrom info shown. # Comment out partition info as a bit noisy. proc find_sbin_cmd { for base in [/ /usr/ /usr/local] { if test -e $base/sbin/$1 { echo $base/sbin/$1 exit } } } global FDISK := $[which fdisk !2 >/dev/null] global LSUSB := $[which lsusb !2 >/dev/null] global LSPCI := $[which lspci !2 >/dev/null] test -z $FDISK && global FDISK := $[find_sbin_cmd fdisk] test -z $LSUSB && global LSUSB := $[find_sbin_cmd lsusb] test -z $LSPCI && global LSPCI := $[find_sbin_cmd lspci] echo "============= Drives =============" shell { sed -n 's/.* \([hs]d[a-f]$\)/\1/p' < /proc/partitions test -e /dev/cdrom && readlink -f /dev/cdrom | cut -d/ -f3 } | sort | uniq | while read disk { echo -n "/dev/$disk: " if test ! -r /dev/$disk { echo "permission denied" #could parse /proc for all but } else { global size := $[$FDISK -l /dev/$disk | grep Disk | cut -d' ' -f3-4 | tr -d ,] global rest := $[/sbin/hdparm -i /dev/$disk !2 >/dev/null | grep Model] global rest := $[echo $rest] #strip spaces echo -n $rest if test ! -z $size { echo ", Size=$size" } else { echo } } } #if [ `id -u` == "0" ]; then #echo "========== Partitions ==========" #$FDISK -l 2>/dev/null #fi echo "============= CPUs =============" grep "model name" /proc/cpuinfo #show CPU(s) info echo "============= MEM =============" global KiB := $[grep MemTotal /proc/meminfo | tr -s ' ' | cut -d' ' -f2] global MiB := $[expr $KiB / 1024] #note various mem not accounted for, so round to appropriate size #on my 384MiB system over 8MiB was unaccounted for #on my 1024MiB system over 20MiB was unaccounted for so round to next highest power of 2 global round := '32' echo "$[expr '(' '(' $MiB / $round ')' + 1 ')' '*' $round] MiB" echo "============= PCI =============" $LSPCI -tv echo "============= USB =============" $LSUSB (CommandList children: [ (FuncDef name: find_sbin_cmd body: (BraceGroup children: [ (ForEach iter_name: base iter_words: [{(/)} {(/usr/)} {(/usr/local)}] do_arg_iter: False body: (DoGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-e)} {($ VSub_Name "$base") (/sbin/) ($ VSub_Number "$1")} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {($ VSub_Name "$base") (/sbin/) ($ VSub_Number "$1")}) (C {(exit)}) ] spids: [-1 73] ) ] spids: [-1 86] ) ] spids: [57 89] ) spids: [49 55] ) ] spids: [41] ) spids: [37 40] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:FDISK) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [{(which)} {(fdisk)}] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[99])] ) ] ) left_token: spids: [94 101] ) } spids: [93] ) ] spids: [93] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LSUSB) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [{(which)} {(lsusb)}] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[109])] ) ] ) left_token: spids: [104 111] ) } spids: [103] ) ] spids: [103] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LSPCI) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [{(which)} {(lspci)}] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[119])] ) ] ) left_token: spids: [114 121] ) } spids: [113] ) ] spids: [113] ) (AndOr children: [ (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$FDISK"))} {(Lit_Other "]")}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:FDISK) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(find_sbin_cmd)} {(fdisk)})]) left_token: spids: [136 140] ) } spids: [135] ) ] spids: [135] ) ] op_id: Op_DAmp ) (AndOr children: [ (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$LSUSB"))} {(Lit_Other "]")}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LSUSB) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(find_sbin_cmd)} {(lsusb)})]) left_token: spids: [155 159] ) } spids: [154] ) ] spids: [154] ) ] op_id: Op_DAmp ) (AndOr children: [ (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$LSPCI"))} {(Lit_Other "]")}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LSPCI) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(find_sbin_cmd)} {(lspci)})]) left_token: spids: [174 178] ) } spids: [173] ) ] spids: [173] ) ] op_id: Op_DAmp ) (C {(echo)} {(DQ ("============= Drives ============="))}) (Pipeline children: [ (Subshell child: (CommandList children: [ (SimpleCommand words: [{(sed)} {(-n)} {(SQ <"s/.* \\([hs]d[a-f]$\\)/\\1/p">)}] redirects: [ (Redir op_id: Redir_Less fd: -1 arg_word: {(/proc/partitions)} spids: [197] ) ] ) (AndOr children: [ (C {(Lit_Other "[")} {(-e)} {(/dev/cdrom)} {(Lit_Other "]")}) (Pipeline children: [(C {(readlink)} {(-f)} {(/dev/cdrom)}) (C {(cut)} {(-d/)} {(-f3)})] negated: False ) ] op_id: Op_DAmp ) ] ) spids: [187 225] ) (C {(sort)}) (C {(uniq)}) (While cond: [(Sentence child:(C {(read)} {(disk)}) terminator:)] body: (DoGroup children: [ (C {(echo)} {(-n)} {(DQ (/dev/) ($ VSub_Name "$disk") (": "))}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-r)} {(/dev/) ($ VSub_Name "$disk")} {(Lit_Other "]")} ) terminator: ) ] action: [(C {(echo)} {(DQ ("permission denied"))})] spids: [-1 272] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:size) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {($ VSub_Name "$FDISK")} {(-l)} {(/dev/) ($ VSub_Name "$disk")} ) (C {(grep)} {(Disk)}) (C {(cut)} {(-d) (SQ <" ">)} {(-f3-4)}) (C {(tr)} {(-d)} {(Lit_Comma ",")}) ] negated: False ) ] ) left_token: spids: [289 321] ) } spids: [288] ) ] spids: [288] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rest) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (SimpleCommand words: [ {(/sbin/hdparm)} {(-i)} {(/dev/) ($ VSub_Name "$disk")} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [333] ) ] ) (C {(grep)} {(Model)}) ] negated: False ) ] ) left_token: spids: [325 341] ) } spids: [324] ) ] spids: [324] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rest) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(echo)} {($ VSub_Name "$rest")})] ) left_token: spids: [345 349] ) } spids: [344] ) ] spids: [344] ) (C {(echo)} {(-n)} {(DQ ($ VSub_Name "$rest"))}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-z)} {(DQ ($ VSub_Name "$size"))} {(Lit_Other "]")} ) terminator: ) ] action: [(C {(echo)} {(DQ (", Size=") ($ VSub_Name "$size"))})] spids: [-1 379] ) ] else_action: [(C {(echo)})] spids: [390 396] ) ] spids: [285 399] ) ] spids: [244 401] ) ) ] negated: False ) (C {(echo)} {(DQ ("============= CPUs ============="))}) (C {(grep)} {(DQ ("model name"))} {(/proc/cpuinfo)}) (C {(echo)} {(DQ ("============= MEM ============="))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KiB) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(grep)} {(MemTotal)} {(/proc/meminfo)}) (C {(tr)} {(-s)} {(SQ <" ">)}) (C {(cut)} {(-d) (SQ <" ">)} {(-f2)}) ] negated: False ) ] ) left_token: spids: [442 469] ) } spids: [441] ) ] spids: [441] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:MiB) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(expr)} {($ VSub_Name "$KiB")} {(/)} {(1024)})] ) left_token: spids: [472 480] ) } spids: [471] ) ] spids: [471] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:round) op:Equal rhs:{(32)} spids:[491])] spids: [491] ) (C {(echo)} { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(expr)} {(EscapedLiteralPart token:)} {(EscapedLiteralPart token:)} {($ VSub_Name "$MiB")} {(/)} {($ VSub_Name "$round")} {(EscapedLiteralPart token:)} {(Lit_Other "+")} {(1)} {(EscapedLiteralPart token:)} {(EscapedLiteralPart token:)} {($ VSub_Name "$round")} ) ] ) left_token: spids: [497 521] ) (" MiB") ) } ) (C {(echo)} {(DQ ("============= PCI ============="))}) (C {($ VSub_Name "$LSPCI")} {(-tv)}) (C {(echo)} {(DQ ("============= USB ============="))}) (C {($ VSub_Name "$LSUSB")}) ] )