Chinaunix

标题: [原创] shell script查看sun机器系统信息 [打印本页]

作者: 陈小奚    时间: 2004-01-08 18:00
标题: [原创] shell script查看sun机器系统信息
一个好简单的shell script,给大家查看sun机器系统信息的时候偷懒一会儿,:)\r\n最低在sun4m sparcstation5/sunos 5.8上测试通过,系统版本低的会看不全,权限不够也会看不全。呵呵~\r\n请大家指教拉~\r\n\r\n
  1. \r\n#!/bin/sh\r\n\r\n#############################################################\r\n# This script gives basic sysinfo\r\n# Run in Sun Solaris 8\r\n# Illusion Chen\r\n############################################################\r\n\r\ntmp_file=/tmp/sysinfo.tmp`date +%h%d`\r\n\r\n# test user permission\r\n\r\n#if [ `whoami` != root ]; then\r\nif [ ! `/usr/xpg4/bin/id -u` -eq 0 ]; then\r\n        echo \"Super-user permission is needed.\"\r\n        echo \"Otherwise maybe you can not view all info\"\r\nfi\r\n\r\n# Main program\r\n\r\necho \"====================================================\"\r\necho \" Sysinfo in Host: `hostname`\"\r\necho \" System-Uptime: `uptime|awk \'{ print $3,$4,$5 }\'`\"\r\necho \"====================================================\"\r\nsm1=`uname -m`\r\nsm2=`/usr/sbin/prtconf -pv|/usr/bin/grep banner-name|awk -F\"\'\" \'{ print $2 }\'`\r\necho \"System-make: $sm1 $sm2\"\r\n#ps=`psrinfo|grep on-line|wc -l`\r\nps=`/usr/sbin/psrinfo -v|/usr/bin/grep MHz|awk \'{print $6}\'|uniq -c`\r\necho \"Process-count: $ps MHz\"\r\nmm=`/usr/sbin/prtconf -pv|/usr/bin/grep Mem|awk \' { print $3,$4 }\'`\r\necho \"System-memory: $mm\"\r\nobp_version=`/usr/sbin/prtconf -V`\r\necho \"OBP-version: $obp_version\"\r\nos_version=`uname -sr`\r\necho \"System-version: $os_version\"\r\nbt=`/usr/bin/isainfo -kv`\r\necho \"System-kernel-type: $bt\"\r\nmc=`/usr/sbin/ifconfig -a|awk \'/ether/ { print $2 }\'`\r\necho \"System-MacAddress: $mc\"\r\nhost=`hostname`\r\nip=`/usr/bin/grep -w $host /etc/hosts|awk \'{ print $1 }\'`\r\necho \"System-IPAddress: $ip\"\r\n#grep -w `hostname` /etc/hosts|awk \'{ print $1 }\'\r\necho \"\"\r\n\r\necho \"====================================================\"\r\necho \" Memory Usage\"\r\necho \"====================================================\"\r\n/usr/ucb/vmstat\r\necho \"\"\r\necho \"====================================================\"\r\necho \" Swap Usage\"\r\necho \"====================================================\"\r\n/usr/sbin/swap -s\r\necho \"\"\r\necho \"====================================================\"\r\necho \" HDD Configuration\"\r\n(\r\n/usr/bin/iostat -E | grep -v sd | grep -v st | grep -v \"Media Error\" | grep -v \"\r\nIllegal Request\" | grep -i \'[a-z]\' ) 1>;$tmp_file  2>;/dev/null\r\nHDD_number=`grep -v \"<-\" $tmp_file | grep -c \"Size\"`\r\necho \" Total Disk Number: $HDD_number ?\"\r\necho \" * Use Format to confirm it\"\r\necho \"====================================================\"\r\n#/usr/bin/sed \'/18446744073.71GB/ a\\\r\n/usr/bin/sed \'/<-/ a\\\r\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\\r\n=>; THIS DISK MAYBE WAS UNAVAILABLE\' $tmp_file\r\n#cat $tmp_file\r\necho \"\"\r\necho \"====================================================\"\r\necho \" Disk Usage\"\r\necho \" Notice: Serval unmounted partitions maybe were used by a DB server\"\r\necho \"====================================================\"\r\n(/usr/sbin/df -k /dev/dsk/*) 1>;$tmp_file 2>;/dev/null\r\n/usr/bin/grep -w \'Filesystem\' $tmp_file |sort -u\r\n/usr/bin/grep -vw \'Filesystem\' $tmp_file\r\n\'rm\' $tmp_file\r\necho \"\"\r\necho \"====================================================\"\r\necho \" System File System\"\r\necho \"====================================================\"\r\n/usr/sbin/df -k\r\necho \"\"\r\necho \"====================================================\"\r\necho \" System Patch\"\r\necho \"====================================================\"\r\nshowrev -p\r\necho \"\"\r\necho \"====================================================\"\r\necho \" Printers Status\"\r\necho \"====================================================\"\r\n#/usr/ucb/lpc status\r\n/usr/bin/lpstat -p all\r\necho \"\"\r\n
复制代码

作者: 陈小奚    时间: 2004-01-08 18:03
标题: [原创] shell script查看sun机器系统信息
显示的系统信息范例:\r\n\r\n
  1. \r\n====================================================\r\n Sysinfo in Host: ufszx01\r\n System-Uptime: 58 day(s), 8\r\n====================================================\r\nSystem-make: sun4m SPARCstation 5\r\nProcess-count:    1 110 MHz\r\nSystem-memory: 64 Megabytes\r\nOBP-version: OpenBoot 2.24\r\nSystem-version: SunOS 5.8\r\nSystem-kernel-type: 32-bit sparc kernel modules\r\nSystem-MacAddress: 8:0:20:72:26:2\r\nSystem-IPAddress: 192.168.19.1\r\n\r\n====================================================\r\n Memory Usage\r\n====================================================\r\n procs     memory            page            disk          faults      cpu\r\n r b w   swap  free  re  mf pi po fr de sr s1 s3 s6 --   in   sy   cs us sy id\r\n 0 0 0 172796 14636  12  69  0  0  0  0  0  1  1  0  0  121  152   36  3  5 93\r\n\r\n====================================================\r\n Swap Usage\r\n====================================================\r\ntotal: 66816k bytes allocated + 16836k reserved = 83652k used, 142792k available\r\n\r\n====================================================\r\n HDD Configuration\r\n Total Disk Number: 2 ?\r\n * Use Format to confirm it\r\n====================================================\r\nVendor: SEAGATE  Product: ST34371W SUN4.2G Revision: 7462 Serial No: JDM7165508T\r\nKN3\r\nSize: 4.29GB <4292075520 bytes>;\r\nVendor: CONNER   Product: CFP1080E SUN1.05 Revision: 5150 Serial No: EX9L44H\r\nSize: 1.05GB <1051287552 bytes>;\r\nVendor: TOSHIBA  Product: XM-4101TASUNSLCD Revision: 3424 Serial No: 12/08/94\r\nSize: 18446744073.71GB <-1 bytes>;\r\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n=>; THIS DISK MAYBE WAS UNAVAILABLE\r\n\r\n====================================================\r\n Disk Usage\r\n Notice: Serval unmounted partitions maybe were used by a DB server\r\n====================================================\r\nFilesystem            kbytes    used   avail capacity  Mounted on\r\n/dev/dsk/c0t1d0s0    1925934  660128 1073182    38%\r\n/dev/dsk/c0t1d0s2    1925934  660128 1073182    38%\r\n/dev/dsk/c0t1d0s1     984631  304467  581701    35%    /opt\r\n/dev/dsk/c0t1d0s3     241543  161559   55830    75%    /var\r\n/dev/dsk/c0t3d0s0     783350  668889   59627    92%    /\r\n/dev/dsk/c0t3d0s2     783350  668889   59580    92%\r\n/dev/dsk/c0t1d0s1     984631  304467  581701    35%    /opt\r\n/dev/dsk/c0t1d0s3     241543  161559   55830    75%    /var\r\n/dev/dsk/c0t3d0s0     783350  668889   59627    92%    /\r\n\r\n====================================================\r\n System File System\r\n====================================================\r\nFilesystem            kbytes    used   avail capacity  Mounted on\r\n/dev/dsk/c0t3d0s0     783350  668889   59627    92%    /\r\n/proc                      0       0       0     0%    /proc\r\nfd                         0       0       0     0%    /dev/fd\r\nmnttab                     0       0       0     0%    /etc/mnttab\r\n/dev/dsk/c0t1d0s3     241543  161559   55830    75%    /var\r\nswap                  140728       0  140728     0%    /var/run\r\nswap                  141728    1000  140728     1%    /tmp\r\n/dev/dsk/c0t1d0s1     984631  304467  581701    35%    /opt\r\n\r\n====================================================\r\n System Patch\r\n====================================================\r\nNo patches are installed\r\n\r\n====================================================\r\n Printers Status\r\n====================================================\r\nprinter hawbs is idle. enabled since Wed Nov 19 10:47:51 CST 2003. available.\r\nprinter exp_inv is idle. enabled since Fri Sep  5 15:30:53 CST 2003. available.\r\nprinter HP is idle. enabled since Fri Dec  5 15:22:26 CST 2003. available.\r\nprinter hawbc is idle. enabled since Fri Sep  5 15:04:13 CST 2003. available.\r\nprinter hkg_hawbs disabled since Fri Sep  5 14:51:47 CST 2003. available.\r\n        new printer\r\nprinter hawb2 is idle. enabled since Fri Sep  5 15:01:25 CST 2003. available.\r\nprinter HP2 is idle. enabled since Tue Jan  6 11:15:56 CST 2004. available.\r\nprinter rjnszx_cnee is idle. enabled since Jan 08 17:59 2004. available.
复制代码
[/code]
作者: 南非蜘蛛    时间: 2004-01-08 18:09
标题: [原创] shell script查看sun机器系统信息
==================================================== \r\nMemory Usage \r\n==================================================== \r\nprocs     memory            page            disk          faults      cpu \r\nr b w   swap  free  re  mf pi po fr de sr s1 s3 s6 --   in   sy   cs us sy id \r\n0 0 0 172796 14636  12  69  0  0  0  0  0  1  1  0  0  121  152   36  3  5 93 \r\n\r\n\r\n第一行一般没用,不用看\r\n有用的数据从第二行开始
作者: 陈小奚    时间: 2004-01-08 18:11
标题: [原创] shell script查看sun机器系统信息
谢谢蜘蛛MM提醒,偶会改进的。
作者: 南非蜘蛛    时间: 2004-01-08 18:14
标题: [原创] shell script查看sun机器系统信息
[quote]原帖由 \"陈小奚\"]谢谢蜘蛛MM提醒,偶会改进的。[/quote 发表:\n\r\n\r\n     
作者: 陈小奚    时间: 2004-01-08 18:20
标题: [原创] shell script查看sun机器系统信息
对了,刚巧想问你个问题了:\r\n偶要看网卡的目前速率,但是在dmesg里看不到了(比如up时间很长了,删了),想用ndd看,但是好象对/dev/le就不行。想看/etc/hostname.*来决定,但是这个又不是当前运行速率,郁闷的很~这里就缺这个。\r\n蜘蛛MM想出个办法没有啊?
作者: 南非蜘蛛    时间: 2004-01-08 18:30
标题: [原创] shell script查看sun机器系统信息
NDD什么结果,贴出来看看\r\nifconfig -a应该也可以看到\r\n你试试,我手边没有机器
作者: 陈小奚    时间: 2004-01-08 18:37
标题: [原创] shell script查看sun机器系统信息
ufszx01:root /tmp  102 >; ndd /dev/le link_speed\r\noperation failed, Invalid argument\r\n\r\nifconfig是可以看到,偶也想过这么看的,但是这里有哪个是对应linkspeed的呢?\r\nufszx01:root /tmp  103 >; ifconfig -a\r\nlo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4>; mtu 8232 index 1\r\n        inet 127.0.0.1 netmask ff000000\r\nle0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4>; mtu 1500 index 2\r\n        inet 192.168.19.1 netmask ffffff00 broadcast 192.168.19.255\r\n        ether 8:0:20:72:26:2
作者: zhangr    时间: 2004-01-08 19:04
标题: [原创] shell script查看sun机器系统信息
这个中不? 8-)\r\n\r\n
  1. \r\nbash-2.03# ndd /dev/dmfe0 \\?\r\n?                             (read only)\r\nlink_status                   (read only)\r\nlink_speed                    (read only)\r\nlink_mode                     (read only)\r\nadv_autoneg_cap               (read and write)\r\nadv_100fdx_cap                (read and write)\r\nadv_100hdx_cap                (read and write)\r\nadv_10fdx_cap                 (read and write)\r\nadv_10hdx_cap                 (read and write)\r\nbash-2.03# ndd /dev/dmfe0 link_speed link_status link_mode\r\n100\r\n\r\n1\r\n\r\n1\r\nbash-2.03# \r\n
复制代码

作者: 陈小奚    时间: 2004-01-08 19:08
标题: [原创] shell script查看sun机器系统信息
如果你用的是le就知道了,不行的,也是“operation failed, Invalid argument”,郁闷。\r\n偶相信肯定有办法行的,只是没找到~
作者: 陈小奚    时间: 2004-01-09 12:07
标题: [原创] shell script查看sun机器系统信息
蜘蛛,蜘蛛在么? \r\n帮忙再看看呢,偶都贴了~
作者: starwang    时间: 2004-01-10 18:24
标题: [原创] shell script查看sun机器系统信息
原帖由 \"南非蜘蛛\" 发表:\n==================================================== \r\nMemory Usage \r\n==================================================== \r\nprocs     memory            page            disk          faults      cpu \r\n..........
\r\n\r\n同意,第一行是开机后的累计数据




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2