Initial add of defaria.com
[clearscm.git] / defaria.com / Computers / code / adm / bin / machine_info
1 #!/bin/bash
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:-//sonscentral/Corporate/Software/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   echo "$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 -i "^$machine:" $machines 2> /dev/null)
38
39   if [ "_$line" = "_" ]; then
40     echo "No information on machine $machine"
41   else
42     machine=$(echo $line | cut -f1 -d:)
43     ip_address=$(echo $line | cut -f2 -d:)
44     model=$(echo $line | cut -f3 -d:)
45     osversion=$(echo $line | cut -f4 -d:)
46     ccversion=$(echo $line | cut -f5 -d:)
47     owner=$(echo $line | cut -f6 -d:)
48     phone=$(echo $line | cut -f7 -d:)
49     usage=$(echo $line | cut -f8 -d:)
50     class=$(echo $line | cut -f9 -d:)
51     location=$(echo $line | cut -f10 -d:)
52     eclipseid=$(echo $line | cut -f11 -d:)
53     echo -e "Machine:\t\t$machine"
54     echo -e "IP Address:\t\t$ip_address"
55     echo -e "Model:\t\t\t$model"
56     echo -e "OS Version:\t\t$osversion"
57     echo -e "ClearCase Version:\t$ccversion"
58     echo -e "Owner:\t\t\t$owner" | tr -s "(" "<" | tr -s ")" ">"
59     echo -e "Phone:\t\t\t$phone"
60     echo -e "Usage:\t\t\t$usage"
61     echo -e "Class:\t\t\t$class"
62     echo -e "Location:\t\t$location"
63   fi
64 } # display_machine_info
65
66 function dump_all_machines {
67   grep -v "^#" $machines | cut -f1 -d: | while read machine; do
68     echo -
69 --------------------------------------------------------------------------------
70     display_machine_info $machine
71   done
72 } # dump_all_machines
73 if [ $# -eq 0 ]; then
74   display_machine_info $(uname -n)
75 else
76   if [ "$1" = "-all" ]; then
77     dump_all_machines
78   else
79     for i in $@; do
80       display_machine_info $i
81     done
82   fi
83 fi