Added client work scripts
[clearscm.git] / clients / HP / bin / machine_info
1 #!/bin/ksh
2 ################################################################################
3 #
4 # File:         machine_info
5 # Description:  Displays information about a machine
6 # Author:       Andrew@DeFaria.com
7 # Created:      Fri Apr 30 14:13:56 PDT 1999
8 # Language:     Korn Shell
9 #
10 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
11 #
12 ################################################################################
13 # Set me to command name
14 me=$(basename $0)
15
16 # Set adm_base
17 adm_base=${adm_base:-$HOME/adm}
18
19 # Set adm_fpath
20 adm_fpath=${adm_fpath:-$adm_base/functions}
21
22 # Source functions
23 . $adm_fpath/common
24
25 # Set machines
26 machines=${machines:-$adm_base/data/machines}
27
28 if [ ! -f $machines ]; then
29   print -u2 "$me: Error: Unable to find $machines file!"
30   exit 1
31 fi
32
33 function display_machine_info {
34   machine=$1
35
36   ISF=" "
37   line=$(grep "^$machine:" $machines 2> /dev/null)
38
39   if [ "_$line" = "_" ]; then
40     print -u2 "No information on machine $machine"
41   else
42     machine=$(print $line | cut -f1 -d:)
43     ip_address=$(print $line | cut -f2 -d:)
44     model=$(print $line | cut -f3 -d:)
45     osversion=$(print $line | cut -f4 -d:)
46     ccversion=$(print $line | cut -f5 -d:)
47     owner=$(print $line | cut -f6 -d:)
48     phone=$(print $line | cut -f7 -d:)
49     usage=$(print $line | cut -f8 -d:)
50     class=$(print $line | cut -f9 -d:)
51     location=$(print $line | cut -f10 -d:)
52     eclipseid=$(print $line | cut -f11 -d:)
53     print "Machine:\t\t$machine"
54     print "IP Address:\t\t$ip_address"
55     print "Model:\t\t\t$model"
56     print "OS Version:\t\t$osversion"
57     print "ClearCase Version:\t$ccversion"
58     print "Owner:\t\t\t$owner" | tr -s "(" "<" | tr -s ")" ">"
59     print "Phone:\t\t\t$phone"
60     print "Usage:\t\t\t$usage"
61     print "Class:\t\t\t$class"
62     print "Location:\t\t$location"
63     print "Eclipse ID:\t\t$eclipseid"
64   fi
65 } # display_machine_info
66
67 function dump_all_machines {
68   grep -v "^#" $machines | cut -f1 -d: | while read machine; do
69     print -
70 --------------------------------------------------------------------------------
71     display_machine_info $machine
72   done
73 } # dump_all_machines
74 if [ $# -eq 0 ]; then
75   display_machine_info $(uname -n)
76 else
77   if [ "$1" = "-all" ]; then
78     dump_all_machines
79   else
80     for i in $@; do
81       display_machine_info $i
82     done
83   fi
84 fi