]> git.sur5r.net Git - bacula/rescue/blob - rescue/solaris/SysAudit
Tweak version
[bacula/rescue] / rescue / solaris / SysAudit
1 #!/bin/sh -- # -*- shell-script -*-
2 #
3 #    SysAudit/SysConfig -- Capture UNIX machine information
4 #    Copyright (C) 1997  David J. Young <davidy@pencom.com>
5 #
6 #    This program is free software; you can redistribute it and/or modify
7 #    it under the terms of the GNU General Public License as published by
8 #    the Free Software Foundation; either version 2 of the License, or
9 #    (at your option) any later version.
10 #
11 #    This program is distributed in the hope that it will be useful,
12 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #    GNU General Public License for more details.
15 #
16 #    You should have received a copy of the GNU General Public License
17 #    along with this program; if not, write to the Free Software
18 #    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #
20 # $Author$
21 VERSION='$Revision$'
22 #
23 # Modification History
24 # 1.0  ??-???-96       Robert Ess <ress@spdmail.spd.dsccc.com> - Created.
25 # 2.0  15-Aug-96       David J. Young <davidy@psa.pencom.com>  - Modified.
26 #      Added/modified code in the Solaris section:
27 #      - Extracted IP address, MacAddr, C compiler and other information
28 #           from more reliable sources.
29 #      - Added dump of information for the Veritas Volume Manager.
30 #      - Calculate and report total swap space
31 #      - Report if the machine is acting as a NFS and/or NIS Server or Client
32 #      - Added counters for number of patches, printers and packages
33 #      - Fix a small bug you had with the previous file (*.bl).
34 # 3.0   4-Sep-96       David E. Nelson <dnelson@psa.pencom.com> - Modified.
35 #      Added/modified code in the SunOS section:
36 #      - Added code operate in either an "audit" or "check" mode.
37 #      - Added SWAPSPACE and KERNEL info.
38 #      - Also added MACADDR, since you must be root to obtain this info using ifconfig.
39 #      - Made sure the script would work on an Auspex
40 # 3.1  10-Sep-96       David J. Young <davidy@psa.pencom.com> - Modified.
41 #      Added/modified code to complete the HPUX section.
42 #      Added Modification History and Description.
43 #
44 # 3.2  12-Sep-96       David E. Nelson <dnelson@psa.pencom.com> - Modified.
45 #      The vast majority of the changed/additons are for SunOS 4.1.x/3.5 and 
46 #        auspex.
47 #      Added support for SunOs 3.5.  Yes, 3.5! That's NOT a typo!
48 #      Modified Auspex and added auspex specific commands
49 #      Added Notification of vars that didn't get set.
50 #      Added exported filesystems in output.
51 #      Fixed bug in SysConfig|SysAudit name determination.
52 #      Added gated detection.
53 # 3.3  10-Oct-96        David E. Nelson <dnelson@psa.pencom.com> - Modified.
54 #       Added support for Solaris 2.5.1
55 # 3.4  09-Jan-97        David J. Young  <davidy@Psa.pencom.com> - Modified.
56 #       Fixed small problems when running on HP-UX.
57 #      
58 # Description:
59 #       The original philosophy of the script that Robert Ess wrote was to run
60 #       every day as a cron job.  If there were *any* machine configuration
61 #       changes, those changes (differences) would be mailed back to the
62 #       administrator to make him aware that something changed.
63 #       
64 #       David Young took the original script and modified it to perform a
65 #       "snapshot" report of a system it was run on.  His goal at the time was
66 #       to perform an audit and needed a report that was a "baseline" for each
67 #       system he ran it on.  The script was modified to collect as much
68 #       information about the machine as possible.
69 #
70 #       These two goals were then merged by David J. Young & David E. Nelson.
71 #       Small changes here and there made it so that the script can perform
72 #       either function.  This file should be name "SysAudit" or "SysConfig".
73 #       If the name is SysConfig, it can be run out of cron and will send
74 #       E-mail to "SysConfigReport".  If the script is called SysAudit, it will
75 #       collect information and send it to standard output as a report.
76 #
77 #       Most sites will problably want to hard link SysConfig and SysAudit, so
78 #       that the script can be executed either way.
79 #       
80 # set -x
81 #
82 # Usage
83 #
84 Usage(){
85         echo "Usage: SysConfig|SysAudit"
86         echo "  SysConfig: Generates system info that is static."
87         echo "  SysAudit:  Generates system info that is dynamic."
88         exit 0
89 }
90
91 #
92 # Parse the command line args
93 #
94 NOPRINTER=0; export NOPRINTER
95 NOPATCHES=0; export NOPATCHES
96 NOPKGS=0;    export NOPKGS
97 TMPFILE=/tmp/SysAudit.$$
98 trap 'rm -f $TMPFILE 2>/dev/null' EXIT
99 loop=true
100 while ($loop); do
101    case $1 in
102         -h*)            Usage;;
103         -lp)            NOPRINTER=1
104                         shift
105                         ;;
106         -pkg)           NOPKGS=1
107                         shift
108                         ;;
109         -patch)         NOPATCHES=1
110                         shift
111                         ;;
112         *)              loop=false
113                         ;;
114    esac
115 done
116
117
118 # =============================================================================
119 #                     BEGIN FUNCTION DEFINITIONS
120 # =============================================================================
121
122 #
123 #
124 #
125 Get_Prog_Name(){
126   case $0 in
127     *SysAudit)          AUDIT=1;;
128     *SysConfig)         AUDIT=0;;
129     *)                  AUDIT=1;; # The default behavior is to do an audit.
130   esac
131 return
132 }
133
134 #
135 # Are we root?
136 #
137 Check_User(){
138 UID=`id | cut -d'(' -f1 | cut -d'=' -f2`
139 if [ "$UID" -ne "0" ]; then
140         echo ""
141         echo "***************************************************"
142         echo "** WARNING: You are not root.                    **"
143         echo "** Running as root will give you better results. **"
144 #       echo "** Especially for the remark command:  rm -rf .* **"
145         echo "***************************************************"
146         echo ""
147         NOTROOT=1 
148         sleep 3
149 else
150         NOTROOT=0
151 fi
152
153 return
154 }
155
156
157
158 # Determine system type
159 #
160 Get_Arch(){
161 #set -x
162 if [ -f /bin/arch ]; then
163         if [ `/bin/arch -k` = "sun3" ]; then
164                 ARCH='sun3'
165         else
166                 ARCH=`uname`
167         fi
168 else
169         ARCH=`uname`
170 fi
171
172 case $ARCH in
173         HP-UX)          REV=`uname -r|cut -d. -f2`
174                         if   [ $REV = "09" ]; then
175                                 SYSTYPE=HPUX09
176                         elif [ $REV = "10" ]; then
177                                 SYSTYPE=HPUX10
178                         fi;;
179
180         SunOS)          REV=`uname -r|cut -d. -f1`
181                         if   [ $REV = 5 ]; then
182                                 SYSTYPE=Solaris
183                         elif [ $REV = 4 ]; then
184                                 SYSTYPE=SunOS
185                         fi;;
186
187         sun3)           SYSTYPE=SunOS3;;
188
189         IRIX)           REV=`uname -r|cut -d. -f1`
190                         if   [ $REV = 6 ]; then
191                                 SYSTYPE=IRIX6
192                         elif [ $REV = 5 ]; then
193                                 SYSTYPE=IRIX5
194                         fi;;
195
196         *)              echo "System type unsupported"
197                         exit 1;;
198 esac
199 return
200 }
201
202 #
203 # Setup variables for system specific syntax of common commands
204 #
205 Define_Vars(){
206 #set -x
207 HOSTNAME=`hostname`
208
209 case $SYSTYPE in
210
211         HPUX*)  PATH=/bin:/usr/bin:/sbin:/usr/sbin:/etc
212                 if [ $NOTROOT -eq "0" ]; then
213                         SWAPFILE=`swapinfo | egrep "dsk|lvol" | awk '{print $9}'`
214                         DEVSWAP=`swapinfo | grep dev | awk '{print $2}'`
215                         FILESWAP=`swapinfo | grep fs | awk '{print $2}'`
216                         SWAPSPACE=`swapinfo -t | grep tot | awk '{print $2}'`
217                 else
218                         SWAPFILE="<Must run swapinfo(1) as root>"
219                         DEVSWAP=$SWAPFILE
220                         FILESWAP=$SWAPFILE
221                         SWAPSPACE=$SWAPFILE
222                 fi
223                 MACADDR=`lanscan | grep x | awk '{print $2}'`
224                 KERNEL="<Unknown>"
225                 HOSTID=`uname -i`
226                 MODEL=`model`
227                 MEMORY=`dmesg | grep Phys | awk '{print $2}'`K
228                 if [ $MEMORY = 'K' ]; then
229                         if [ $NOTROOT -eq "1" ]; then
230                                 MEMORY="<Must be root to read /dev/mem>"
231                         else
232                                 MEMORY=`wc /dev/mem`
233                         fi
234                 fi
235                 DISKCMD='bdf -t hfs'
236                 CCOMP=`what /bin/cc | grep HP | cut -d' ' -f2`
237                 ETHERIF=lan0
238                 MAILCMD=mailx
239                 PRTCMD=lp
240                 PSCMD='ps -ef'
241                 ;;
242         
243         Solar*) PATH=/bin:/sbin:/usr/sbin:/usr/ucb
244                 PATH=$PATH:/usr/ccs/bin:/usr/bin
245                 SWAPFILE=`swap -l | grep dsk | awk '{print $1}'`
246                 DEVSWAP=`swap -l | grep dsk | awk '{print $4}'`
247                 MODEL=`prtconf -vp | grep banner-name | awk -F\' '{print $2}'`
248 #               MEMORY=`dmesg | grep '^mem' | tail -1 | awk '{print $3}'`     #'
249                 MEMORY=`prtconf | grep '^Memory size' | sed 's/Memory size: //'`
250                 KERNEL=`sysdef | grep Generic | awk '{print $1}'`
251                 DISKCMD='df -tkFufs'
252                 NFSFS='df -tkFnfs'
253                 EXPORTFS='showmount -e '$HOSTNAME
254                 HOSTID=`sysdef -h | tail -1 | awk '{print $1}'`
255                 if [ -x /usr/ccs/bin/what ]; then
256                   if [ -d /opt/SUNWspro ]; then
257                     CCOMP=`what /opt/SUNWspro/bin/cc | grep RELEASE | \
258                     sed 's/.*RELEASE VERSION //'`
259                   else
260                     CCOMP=`what /usr/ucb/cc | grep SMI | awk '{print $2}'`
261                     CCOMP="$CCOMP (bundled)"
262                   fi
263                 else
264                   CCOMP="<No Compiler>"
265                 fi
266 #               ETHERIF=le0
267                 ETHERIF=`ifconfig -a|grep BROADCAST | awk -F: '{print $1}'| head -1 `
268                 IPADDR=`ifconfig $ETHERIF | grep inet | awk '{print $2}'`
269 #               MACADDR=`dmesg | grep Ether | tail -1 | awk '{print $4}'`
270 #               MACADDR=`arp -a | grep $HOSTNAME | sed 's/.*\(08:00.*\) .*/\1/'` 
271                 MACADDR=`arp $IPADDR | awk '{print $4}'`
272                 MAILCMD=mailx
273                 PRTCMD=lp
274                 PSCMD='ps -ef'
275                 SWAPSPACE=`swap -s | awk '
276                         {
277                            swapused  = $9
278                            swapavail = $11
279                            swapusedlen = length(swapused) - 1
280                            swapavailen = length(swapavail) - 1
281                            usedk       = substr(swapused,1,swapusedlen)
282                            availk      = substr(swapavail,1,swapavailen)
283                            total       = (availk + usedk)/1000
284                            printf("%2.0f Megabytes\n", total)
285                         }'`
286                 ;;
287
288         SunOS)  PATH=/bin:/usr/bin:/usr/ucb:/etc:/usr/etc
289                 SWAPFILE='/dev/'`dmesg | grep swap | tail -1 | awk '{print $3}'`
290                 DEVSWAP=`pstat -T | grep swap | awk '{print $1}' \
291                 | cut -d'/' -f2`
292
293                 if [ `arch -k` = "aushp" ]; then
294                   AUSPEX=1
295                   ETHERIF=ae0
296                 else
297                   ETHERIF=le0
298                 fi
299
300                 if [ "$NOTROOT" = "1" ]; then 
301                   MACADDR=`dmesg | grep -i "ethernet address" | awk '{ print $4 }' | tail -1`
302                 else
303                   MACADDR=`ifconfig $ETHERIF | grep ether | tail -1 | awk '{print $2}'` 
304                 fi
305                 if [ -z "$MACADDR" ]; then
306                   MACADDR="Root access required."
307                 fi
308
309                 MODEL=`dmesg | egrep "LX|SPARC|4/75|4/50"| tail -1 \
310                 | awk '{print $3, $4}'`
311
312                 if [ -z "$MODEL" ]; then
313                   MODEL=`mach`
314                 fi
315
316                 MEMORY=`dmesg | grep '^mem' | tail -1 | awk '{print $3}'`
317
318                 if [ -z "$MEMORY" ]; then
319                   MEMORY="Unknown"
320                 fi
321
322                 DISKCMD='df -t 4.2'
323                 CCOMP="Unknown"
324                 MAILCMD=/bin/mail
325                 PRTCMD=lpr
326                 PSCMD='ps aux'
327                 SWAPSPACE=`pstat -T | grep "swap" | awk '{print $1}' | \
328                 awk -F/ '{print $2}'`'K'
329                 KERNEL=`uname -v`
330                 HOSTID=`hostid`
331                 EXPORTFS='showmount -e '$HOSTNAME
332                 ;;
333
334         SunOS3) PATH=/bin:/usr/bin:/usr/ucb:/etc:/usr/etc:/usr/5bin
335                 SWAPFILE='/dev/'`dmesg | grep swap | tail -1 | awk '{print $3}'`
336                 DEVSWAP=`pstat -T | grep swap | awk '{print $1}' \
337                 | cut -d'/' -f2`
338                 if [ "$NOTROOT" = "1" ]; then 
339                   MACADDR=`dmesg | grep -i "ethernet address" | awk '{ print $4 }' | tail -1`
340                 else
341                   MACADDR=`ifconfig ie0 | grep ether | tail -1 | awk '{print $2}'`      
342                 fi
343
344                 if [ -z "$MACADDR" ]; then
345                   MACADDR="Root access required."
346                 fi
347
348                 MODEL=`dmesg | egrep "LX|SPARC|4/75|4/50"| tail -1 \
349                 | awk '{print $3, $4}'`
350
351                 if [ -z "$MODEL" ]; then
352                   MODEL=`mach`
353                 fi
354
355                 MEMORY=`dmesg | grep '^mem' | tail -1 | awk '{print $3}'`
356
357                 if [ -z "$MEMORY" ]; then
358                   MEMORY="Unknown"
359                 fi
360
361                 DISKCMD='df -t 4.2'
362                 CCOMP="Unknown"
363                 ETHERIF=ie0
364                 MAILCMD=/bin/mail
365                 PRTCMD=lpr
366                 PSCMD='ps aux'
367                 SWAPSPACE=`pstat -T | grep "swap" | awk '{print $1}' | \
368                 awk -F/ '{print $2}'`'K'
369                 KERNEL=`strings /vmunix | grep UNIX | awk '{ print $7 }' | \
370                   sed 's/#//; s/://'`
371                 HOSTID=`hostid`
372                 EXPORTFS='showmount -e '$HOSTNAME
373                 ;;
374 esac
375
376 UPTIME=`uptime | sed 's/.*\(up.*\)/\1/' | sed 's/\(.*user[s]*\),.*/\1/'`
377 LOADNOW=`uptime | sed 's/.*load average: \(.*\)/\1/'`
378 ADMIN=`whoami`
379 TIMESTAMP=`date +%m%d%y`
380
381 SNFILE=/usr/tmp/`hostname`.sn
382 if [ -f "$SNFILE" ]; then
383         SERIALNO=`cat $SNFILE`
384 else
385         SERIALNO="Unknown"
386 fi
387
388 return
389 }
390
391
392 #
393 # To keep from identifying server machines as
394 # belonging to an individual, the 'case' statement
395 # makes a check and changes LASTLOGIN to "Server"
396 # Otherwise, check the first non-root|daemon|lp|UID
397 # user of the box. Not failsafe, but as close as
398 # I can get.
399 #
400 Machine_Data(){
401 #set -x
402 MACHINE=`uname -m`
403 OSREV=`uname -r`
404
405 case `hostname` in
406         serv01|serv02|serv03|serv04)    LASTLOGIN="Server";;
407         *) LASTLOGIN=`$PSCMD | egrep -v "lp|daemon|root|UID" | \
408            awk '{print $1}' | head -1`;;
409 esac
410
411 #
412 # If no one is logged in, check wtmp
413 #
414 if [ -z "$LASTLOGIN" ]; then
415         LASTLOGIN=`last | grep console | \
416         grep -v "root" | head -1 | awk '{print $1}'`
417 fi
418
419 #
420 # If that fails, see if we have recorded it before
421 #
422 if [ -z "$LASTLOGIN" ]; then
423         LASTLOGIN=`grep Login /usr/tmp/*.bl | awk '{print $4}'`
424 fi
425
426 #
427 # Alas, we are clueless...
428 #
429 if [ -z "$LASTLOGIN" ]; then
430         LASTLOGIN="Unknown.."
431 fi
432
433 if [ "$AUDIT" -eq "1" ]; then
434   DATE=`date`
435 else
436   DATE="Dynamic parameter not reported."
437   UPTIME="Dynamic parameter not reported."
438   LOADNOW="Dynamic parameter not reported."
439 fi
440
441 cat << __EOF__
442
443 =======================================
444 System Configuration report for `hostname`
445 =======================================
446
447 Report data
448 ===========
449 Date                 :  $DATE
450 Version              :  $VERSION
451
452 Machine data
453 ============
454 Uptime               :  $UPTIME
455 Current load avg     :  $LOADNOW
456 Machine              :  $MACHINE
457 Serial number        :  $SERIALNO
458 HostID               :  $HOSTID
459 Model                :  $MODEL
460 O.S. revision        :  $OSREV
461 Kernel               :  $KERNEL
462 C Compiler revision  :  $CCOMP
463 Memory               :  $MEMORY
464 Swap space           :  $SWAPSPACE
465 Last Login           :  $LASTLOGIN
466
467 __EOF__
468 return
469 }
470
471
472 #
473 # NetworkData
474 #
475 Network_Data(){
476 if [ "$AUSPEX" -eq "1" ]; then
477   NOETHERIF=`ax_netstat -i | egrep -v "127.0.0.1|Address|localhost|ni.\*" | \
478     wc | awk '{print $1}'`
479 else
480   NOETHERIF=`netstat -i | egrep -v "127.0.0.1|Address|localhost|ni.\*" | wc | \
481     awk '{print $1}'`
482 fi
483
484 if [ "$SYSTYPE" = "SunOS3" ]; then
485   IPADDR=`ifconfig $ETHERIF | awk '{print $2}'`
486   NETMASK=`ifconfig $ETHERIF | grep inet | awk '{print $4}'`
487   BROADCAST=`ifconfig $ETHERIF | grep broad | awk '{print $6}'`
488   NETMASKCK="255.255.255.0"
489   BROADCASTCK="255"
490
491 else
492   IPADDR=`ifconfig $ETHERIF | grep inet | awk '{print $2}'`
493   NETMASK=`ifconfig $ETHERIF | grep inet | awk '{print $4}'`
494   BROADCAST=`ifconfig $ETHERIF | grep broad | awk '{print $6}'`
495   NETMASKCK="255.255.255.0"
496   BROADCASTCK="255"
497 fi
498
499 $PSCMD | egrep "routed|gated" | grep -v grep > /dev/null
500 if [ "$?" -eq "0" ]; then
501         DEFROUTER='<routed|gated running>'
502 else
503         DEFROUTER=`netstat -rn | grep default | awk '{print $2}'`
504 fi
505 $PSCMD | grep ypbind | grep -v grep > /dev/null
506 if [ "$?" -eq "0" ]; then
507         YPCLIENT="True"
508 else
509         YPCLIENT="False"
510 fi
511
512 $PSCMD | grep ypserv | grep -v grep > /dev/null
513 if [ "$?" -eq "0" ]; then
514         YPSERVER="True"
515 else
516         YPSERVER="False"
517 fi
518
519 NFSMNTS=`$NFSFS | wc | awk '{print $1}'`
520 if [ "$NFSMNTS" -gt "0" ]; then
521         NFSCLIENT="True"
522 else
523         NFSCLIENT="False"
524 fi
525
526 EXPORTCNT=`$EXPORTFS 2>&1 | grep -v RPC | wc | awk '{print $1}'`
527 if [ "$EXPORTCNT" -gt "0" ]; then
528         NFSSERVER="True"
529 else
530         NFSSERVER="False"
531 fi
532
533 cat << __EOF__
534 Network data
535 ============
536 NIS domain           :  `domainname`
537 NIS client           :  $YPCLIENT
538 NIS server           :  $YPSERVER
539
540 NFS client           :  $NFSCLIENT
541 NFS server           :  $NFSSERVER
542
543 ethernet interfaces  :  $NOETHERIF
544 __EOF__
545
546 if [ "$NOETHERIF" -gt "1" ]; then
547
548         echo "Name    Address       Broadcast       Netmask"  
549         echo "=============================================" 
550
551         if [ `arch -k` = "aushp" ]; then
552           NSTATCMD='ax_netstat -i'
553         else
554           NSTATCMD='netstat -i'
555         fi
556
557         eval $NSTATCMD | egrep -v "lo0|ni|Ipkts" | while read line
558         do 
559           set -f $line
560           IFNAME=`echo $1`
561           IFHOST=`echo $4`
562
563           if [ "$IFHOST" = "none" ]; then
564             IFIPAD="Not_Set"
565             IFMSK="Not_Set"
566             IFBRD="Not_Set"
567           else
568             IFIPAD=`ifconfig $1 | grep inet | awk '{print $2}'`
569             IFMSK=`ifconfig $IFNAME | grep inet | awk '{print $4}'`
570             IFBRD=`ifconfig $IFNAME | grep inet | awk '{print $6}'`
571           fi
572
573           [ -z "$IFIPAD" ] && IFIPAD="Unknown"
574           [ -z "$IFMSK" ] && IFMSK="Unknown"
575           [ -z "$IFBRD" ] && IFBRD="Unknown"
576
577           echo $IFNAME $IFIPAD $IFBRD $IFMSK | \
578             awk '{printf"%-6s %-15s %-15s %-15s\n",$1,$2,$3,$4}'
579         done    
580 else
581         echo "IP Address           : " $IPADDR
582         echo "MAC Address          : " $MACADDR
583         echo "Netmask              : " $NETMASK 
584         echo "Broadcast            : " $BROADCAST
585         echo "Default router       : " $DEFROUTER 
586 fi
587 echo ""
588
589 if [ "$NFSSERVER" = "True" ]; then
590   echo ""
591   echo "=============================================" 
592   echo "Exported Filesystems"
593   echo "=============================================" 
594   eval $EXPORTFS
595   echo ""
596 fi
597
598 return
599 }
600
601
602 #
603 # DiskData
604 #
605 Disk_Data(){
606
607 echo "Disk data:" 
608
609 echo "================================================================" 
610
611 if [ "$AUDIT" -eq "1" ]; then
612   echo "Filesystem            kbytes    used   avail capacity  Mounted on" 
613 else
614   echo "Device-File" "Cap." "Mount-Point" | \
615   awk '{printf"%-20s %35s  %-20s\n", $1,$2,$3}' 
616 fi
617
618 echo "================================================================" 
619
620 #
621 # Setup a special case for Journal File Systems at HP-UX 10.10
622 #
623 case $SYSTYPE in
624         HPUX10) bdf -t hfs | grep -v Mounted | \
625                 awk '{printf"%-40s %14d  %-20s\n", $1,$2,$6}' 
626                 bdf -t vxfs | grep -v Mounted | \
627                 awk '{printf"%-40s %14d  %-20s\n", $1,$2,$6}';;
628         *)      if [ "$AUDIT" = "1" ]; then
629                   $DISKCMD | grep -v Mounted 
630                 else
631                   $DISKCMD | grep -v Mounted | \
632                   awk '{printf"%-40s %14d  %-20s\n", $1,$2,$6}' 
633                 fi;;
634 esac
635
636 case $SYSTYPE in
637         HPUX*)  if [ $NOTROOT -eq 0 ]; then 
638                         swapinfo | grep dev | while [ 1 ]; do
639                                 read line
640                                 RC=$?
641                                 if [ "$RC" != "0" ]; then
642                                         break
643                                 fi
644                            SWAPFILE=`echo $line | egrep "dsk|lvol" | awk '{print $9}'`
645                            DEVSWAP=`echo $line | grep dev | awk '{print $2}'`   
646                            echo $SWAPFILE $DEVSWAP "swap" | \
647                            awk '{printf"%-40s %14s  %-20s\n", $1,$2,$3}' 
648                         done
649                 else
650                         SWAPFILE="<Must run swapinfo(1) as root>"
651                         DEVSWAP=$SWAPFILE
652                 fi
653                 ;;
654
655         Solar*) swap -l | grep -v swapfile |
656                 while [ 1 ];
657                 do
658                         read line
659                         RC=$?
660                         if [ "$RC" != "0" ]; then
661                                 break
662                         fi
663                 SWAPFILE=`echo $line| grep dsk| awk '{print $1}'`
664                 DEVSWAP=`echo $line | grep dev| awk '{print $4}'`
665                 echo $SWAPFILE $DEVSWAP "swap" | \
666                         awk '{printf"%-40s %14s  %-20s\n", $1,$2,$3}' 
667                 done;;
668
669         SunOS*) echo $SWAPFILE $DEVSWAP "swap" | \
670                 awk '{printf"%-40s %14s  %-20s\n", $1,$2,$3}';; 
671
672         *);;
673 esac
674 return
675 }
676
677 #
678 # HPUX09_Func
679 #
680 HPUX09_Func(){
681 cat << __EOF__
682
683 IOSCAN output data
684 ==================
685 __EOF__
686
687 /etc/ioscan -f -b 
688 patchnum=`ls -1d /system/PH* | wc -l`
689
690 cat << __EOF__
691
692 Patch Data
693 ====================================================
694 $patchnum Installed patches (from /system/PH*/index)
695 ====================================================
696 __EOF__
697
698
699 cd /system
700 for PATCH in `ls -1d PH* 2>/dev/null`; do
701         DESC=`grep "fd:" $PATCH/index | cut -d':' -f2`
702         echo $PATCH ":" $DESC 
703 done
704
705 printers=`lpstat -a | grep "accepting" | sort | uniq | wc -l`
706
707 cat << __EOF__
708
709 ==================================================
710 $printers Installed printers (from lpstat)
711 ==================================================
712 __EOF__
713
714 lpstat -a | grep "accepting" | sort | uniq | awk '{print $1}' 
715
716 filesets=`ls /etc/filesets | wc -l`
717
718 cat << __EOF__
719
720 ==================================================
721 $filesets Installed filesets (from /etc/filesets)
722 ==================================================
723 __EOF__
724 ls -C /etc/filesets 
725
726 echo 
727 return
728 }
729
730
731 #
732 # HPUX10_Func
733 #
734 HPUX10_Func(){
735 cat << __EOF__
736
737 IOSCAN output data
738 ==================
739 __EOF__
740
741 /etc/ioscan -f 
742
743 printers=`lpstat -a | grep "accepting" | sort | uniq | wc -l`
744 cat << __EOF__
745
746 ==================================================
747 $printers Installed printers (from lpstat)
748 ==================================================
749
750 __EOF__
751
752 lpstat -a | grep "accepting" | sort | uniq | awk '{print $1}' 
753
754 filesets=`swlist -x one_liner="name revision title" -l product | grep -v "#" | wc -l`
755
756 cat << __EOF__
757
758
759 ==================================================
760 $filesets Installed filesets (from swlist -l product )
761 ==================================================
762 __EOF__
763 swlist -x one_liner="name revision title" -l product | \
764 grep -v "#" | cut -c1-60 
765
766 return
767 }
768
769
770 #
771 # SOLARIS_Func
772 #
773 SOLARIS_Func(){
774
775 SARSTAT="<NOT Running>"
776 if [ -d /var/sadm/sa ]; then
777         logs=`find /var/sadm/sa -mtime -1 -print | wc | awk '{print $1}'`
778         if [ "$logs" -gt "0" ]; then
779                 SARSTAT="<Running>"
780         fi
781 fi
782 VXSTAT="<NOT Running>"
783 PSOUT=`$PSCMD | grep vxconfigd | grep -v grep | wc | awk '{print $1}'`
784 if [ "$PSOUT" -gt "0" ]; then
785         VXSTAT="<Running>"
786 fi
787
788
789 cat << __EOF__
790
791 Solaris data
792 ============
793 sar(1M) status       :  $SARSTAT
794 Veritas Volume Mgr   :  $VXSTAT
795
796 __EOF__
797
798 if [ -x /usr/sbin/vxdg ]; then
799         echo "List Disk Groups"                
800         echo "================"               
801         vxdg list                              2>&1 
802 fi
803 if [ -x /usr/sbin/vxprint ]; then
804         echo                                   
805         echo "Display Configuration Summary"   
806         echo "============================="   
807         vxprint -S                             2>&1
808 fi
809 if [ -x /usr/sbin/vxstat ]; then
810         echo                                   
811         echo "Volume Statistics"               
812         echo "================="               
813         vxstat 2>&1 | tail +3 | awk '
814             BEGIN { 
815                 printf ("                                OPERATIONS             BLOCKS       AVG TIME(ms)\n");
816                 printf ("TYP NAME                      READ     WRITE       READ      WRITE  READ  WRITE\n");
817              }
818                 {
819                     v  = $1
820                     n  = $2
821                     or = $3
822                     ow = $4
823                     br = $5
824                     bw = $6
825                     ar = $7
826                     aw = $8
827                     printf ("%s %-20s %9s %9s %10s %10s %5.1f  %5.1f\n", v,n,or,ow,br,bw,ar,aw)
828                 }'                             
829 fi
830 if [ -x /usr/sbin/vxprint ]; then
831         echo                                   
832         echo "Configuration Details"           
833         echo "====================="           
834         vxprint -tvh                           2>&1
835 fi
836
837 showrev -p 2>&1 | grep -v 'No patches' | awk '{print $2}' >$TMPFILE
838 patchnum=`cat $TMPFILE | wc | awk '{print $1}'`
839
840 cat << __EOF__
841
842 ==================================================
843 $patchnum Installed patches (from 'showrev -p')
844 ==================================================
845 __EOF__
846
847 if [ $NOPATCHES -eq 0 ]; then
848         cat $TMPFILE
849 fi
850
851 lpstat -a | grep "accepting" | sort | uniq | awk '{print $1}' >$TMPFILE
852 lpnum=`cat $TMPFILE | wc | awk '{print $1}'`
853
854 cat << __EOF__
855
856 ==================================================
857 $lpnum Installed printers (from lpstat)
858 ==================================================
859 __EOF__
860
861 if [ $NOPRINTER -eq 0 ]; then
862         cat $TMPFILE
863 fi
864
865
866 pkginfo | sort -b +1 >$TMPFILE
867 pkgnum=`cat $TMPFILE | wc | awk '{print $1}'`
868
869 cat << __EOF__
870
871 ==================================================
872 $pkgnum Installed packages (from pkginfo)
873 ==================================================
874 __EOF__
875
876 if [ $NOPKGS -eq 0 ]; then
877         cat $TMPFILE
878 fi
879 return
880 }
881
882
883 #
884 # SUNOS_Func
885 #
886 SUNOS_Func() {
887 cat << __EOF__
888
889 ==================================================
890 Installed printers (from lpc stat)
891 ==================================================
892 __EOF__
893
894 lpc stat | grep : | cut -d':' -f1 
895 return 
896 }
897
898
899 # =============================================================================
900 #                     END OF FUNCTION DEFINITIONS
901 # =============================================================================
902
903 #
904 # system-independant functions
905 #
906 Get_Prog_Name
907
908 if [ "$AUDIT" = "0" ]; then
909   exec > /usr/tmp/`hostname`.SysConfig
910 fi
911
912 Check_User
913 Get_Arch
914 Define_Vars
915 Machine_Data
916 Network_Data
917 Disk_Data
918
919
920 #
921 # system-dependant functions
922 #
923 case $SYSTYPE in
924         HPUX09)         HPUX09_Func;;
925         HPUX10)         HPUX10_Func;;
926         Solaris)        SOLARIS_Func;;
927         SunOS)          SUNOS_Func;;
928         SunOS3)         SUNOS_Func;;
929         *)              ;;
930 esac
931