summaryrefslogtreecommitdiff
path: root/src/pmdas/hotproc/Install
blob: e1cc8b1f3695688510f799c717c6a4162ea5404b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/sh
#
# Copyright (c) 1997-2001 Silicon Graphics, Inc.  All Rights Reserved.
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# 
# Install the hotproc PMDA and/or PMNS
#
# XXX these values are overwritten by pmdaproc.sh!
tmp=`mktemp -d /tmp/pcp.XXXXXXXXX` || exit 1
status=1	# failure is the default!
trap "cd /; rm -rf $tmp; exit \$status" 0 1 2 3 15

. $PCP_DIR/etc/pcp.env
. $PCP_SHARE_DIR/lib/pmdaproc.sh

iam=hotproc
pmda_interface=2
forced_restart=false

pmdaSetup

daemon_opt=true		# can install as daemon
dso_opt=false
pipe_opt=true		# supports pipe IPC
socket_opt=false	# no socket IPC

# be careful that mortals cannot write any configuration files, as
# these would present a security problem
#
umask 022

# PMDA variables
#
configfile=""
refresh=60
debug=0
storable="n"

do_debug=false

_parsedefaults()
{
    echo "Extracting options from current installation ..."
    while getopts D:d:h:i:l:p:st:u: c
    do
    	case $c in
	    \?)		echo "Warning: Unrecognized option in $PCP_PMCDCONF_PATH"
			echo "	       Remove line for the $iam PMDA in $PCP_PMCDCONF_PATH and re-run ./Install"
	    		exit 2;;
	    D )		debug=$OPTARG;;
	    t )		refresh=$OPTARG;;
	    s )		storable="n";;
	    * )		;;
	esac
    done
    eval configfile='$'$OPTIND
}

if $do_pmda
then

    # set options from $PCP_PMCDCONF_PATH, if possible
    #
    ans=`$PCP_AWK_PROG <$PCP_PMCDCONF_PATH '
$1 == "'$iam'"	{ printf "%s",$6
		  for (i=7;i<=NF;i++) printf " %s",$i
		  print ""
	        }'`
    if [ ! -z "$ans" ]
    then
	_parsedefaults $ans
    fi

    # go figure out which configuration file to use ...
    #
    default_configfile=./sample.conf
    pmdaChooseConfigFile
    if [ -z "$configfile" ]
    then
	echo ""
	echo "Error: Abandoning installation as no configuration file was specified."
	exit 1
    fi

    # make sure that the chosen configuration file parses ok
    #    
    $pmda_dir/$pmda_name -C $configfile >$tmp/err 2>&1
    if [ $? -eq 1 ]
    then
	echo ""
	echo "Error: Abandoning installation due to errors in configuration file:"
	cat $tmp/err
	exit 1
    fi

    echo
    echo "Enter the refresh interval (in seconds) [$refresh] \c"
    read ans
    if  [ ! -z "$ans" ]
    then
    	refresh=$ans
    fi

    echo
    echo "Do you want to modify the configuration predicate or refresh interval"
    echo "at run time [$storable]? \c"
    read ans
    if [ ! -z "$ans" ]
    then
	case $ans in
	    N|n|NO|No|no) storable=n;;
	    Y|y|YES|Yes|yes) storable=y;;
	esac
    fi
    if [ $storable = y ]
    then
	store_opt=""
    else
	store_opt="-s"
    fi

    if [ "$do_debug" = true ]
    then
	echo
	echo "Enter the debugging flag (see pmdbg(1)) [$debug] \c"
	read ans
	if [ ! -z "$ans" ]
	then
	    debug=$ans
	fi
    fi

    args="$store_opt -t $refresh -D $debug $configfile"
fi

pmdaInstall
echo "Please note that instance related metrics will not be available"
echo "until after the initial refresh of $refresh seconds."

status=0
exit 0