Server IP : 184.154.167.98 / Your IP : 3.14.128.200 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/libexec/pcp/lib/ |
Upload File : |
#!/bin/sh # # Copyright (c) 2012-2015,2020-2022 Red Hat. # Copyright (c) 2000 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. # # The following is for chkconfig on RedHat based systems # chkconfig: - 95 05 # description: pmie is a performance inference engine for the Performance Co-Pilot (PCP) # # The following is for insserv(1) based systems, # e.g. SuSE, where chkconfig is a perl script. ### BEGIN INIT INFO # Provides: pmie # Required-Start: $remote_fs # Should-Start: $local_fs $network $syslog $time $pmcd # Required-Stop: $remote_fs # Should-Stop: $local_fs $network $syslog $pmcd # Default-Start: # Default-Stop: 0 1 6 # Short-Description: Control pmie (performance inference engine for PCP) # Description: Configure and control pmie (the performance inference engine for the Performance Co-Pilot) ### END INIT INFO # # For FreeBSD # PROVIDE: pmie # REQUIRE: NETWORKING FILESYSTEMS pmcd # KEYWORD: shutdown # And add the following lines to /etc/rc.conf to run pmcd: # pmie_enable="YES" # . $PCP_DIR/etc/pcp.env . $PCP_SHARE_DIR/lib/rc-proc.sh # for chasing arguments we're passed from init/systemd/... # #debug# echo "$*: `date`" >>$PCP_LOG_DIR/rc_pmie.log #debug# env >>$PCP_LOG_DIR/rc_pmie.log PMIECTRL=$PCP_PMIECONTROL_PATH rcprog=$PCP_DIR/etc/init.d/pmie pmprog=$PCP_RC_DIR/pmie prog=$PCP_RC_DIR/`basename $0` tmp=`mktemp -d "$PCP_TMPFILE_DIR/pmie_rc.XXXXXXXXX"` || exit 1 status=1 trap "rm -rf $tmp; exit \$status" 0 1 2 3 15 # optional begin logging to $PCP_LOG_DIR/NOTICES # if $PCP_LOG_RC_SCRIPTS then logmsg="begin pid:$$ $prog args:$*" if which pstree >/dev/null 2>&1 then logmsg="$logmsg [`pstree -lps $$`]" logmsg="`echo "$logmsg" | sed -e 's/---pstree([^)]*)//'`" fi $PCP_BINADM_DIR/pmpost "$logmsg" fi if [ $pmprog = $prog -o $rcprog = $prog ] then VERBOSE_CTL=on else VERBOSE_CTL=off fi id=`id | sed -e "s/(.*//" -e "s/.*=//"` if [ "$id" != 0 -a "$1" != "status" ] then if [ -n "$PCP_DIR" ] then : running in a non-default installation, do not need to be root else echo "$prog:"' Error: You must be root (uid 0) to start or stop pmie.' exit fi fi _usage() { echo "Usage: $pmprog [-v] {start|start-systemd|restart|condrestart|stop|stop-systemd|status|reload|force-reload}" } _reboot_setup() { # base directories and house-keeping for pmie instances # if [ ! -d "$PCP_TMP_DIR/pmie" ] then mkdir -p -m 0775 "$PCP_TMP_DIR/pmie" chown $PCP_USER:$PCP_GROUP "$PCP_TMP_DIR/pmie" if which restorecon >/dev/null 2>&1 then restorecon -r "$PCP_TMP_DIR" fi else rm -rf $tmp/ent $tmp/pid here=`pwd` cd "$PCP_TMP_DIR/pmie" _get_pids_by_name pmie | sort >$tmp/pid ls [0-9]* 2>&1 | sed -e '/\[0-9]\*/d' \ | sed -e 's/[ ][ ]*//g' | sort >$tmp/ent # remove entries without a pmie process rm -f `comm -23 $tmp/ent $tmp/pid` rm -f $tmp/ent $tmp/pid cd "$here" fi } # Note: _start_pmcheck() starts some or all pmies configured in the # control file(s), subject to $PMIE_CHECK_PARAMS if set. The environment # may restrict this to just the primary pmie with --only-primary, or to # all pmies except the primary with the --skip-primary flag. If neither # are set, then all configured pmies will be started. _start_pmcheck() { bgstatus=0 bgtmp=`mktemp -d "$PCP_TMPFILE_DIR/pmie_rc_start.XXXXXXXXX"` || exit 1 trap "rm -rf $tmp $bgtmp; exit \$bgstatus" 0 1 2 3 15 pmie_check $VFLAG $PMIE_CHECK_PARAMS >$bgtmp/pmcheck.out 2>$bgtmp/pmcheck bgstatus=$? if [ -s $bgtmp/pmcheck ] then logfile="$PCP_LOG_DIR/pmie/pmie_check.log" mv -f $bgtmp/pmcheck $logfile message="pmie_check start failed in $prog, see $logfile" $PCP_SYSLOG_PROG -p daemon.warning "$message" $PCP_BINADM_DIR/pmpost "$message" fi return $bgstatus # pmie_check is now complete } _start_pmie() { if which pmie_check >/dev/null 2>&1 then # pmie_check uses $PMIECTRL to start everything that is needed if [ ! -f $PMIECTRL ] then echo "$prog:"' Error: PCP inference engine control file '$PMIECTRL' is missing! Cannot start any Performance Co-Pilot inference engine(s).' # failure estatus=false else [ "$1" = "start-systemd" ] ||\ $ECHO $PCP_ECHO_N "Starting pmie ..." "$PCP_ECHO_C" # start all pmie services configured in the control file(s) _start_pmcheck # success estatus=true fi else echo "$prog:"' Warning: Performance Co-Pilot installation is incomplete (at least the script "pmie_check" is missing) and the PCP inference engine(s) cannot be started.' # failure estatus=false fi if [ "$1" = start-systemd ]; then $estatus $RC_STATUS else $estatus $RC_STATUS -v fi } _shutdown() { _get_pids_by_name pmie >$tmp/pmies 2>&1 if [ ! -s $tmp/pmies ] then [ "$1" = verbose ] && echo "$pmprog: pmie not running" rm -f $PCP_RUN_DIR/pmie.pid return 0 fi [ "$1" = quietly ] || \ $ECHO $PCP_ECHO_N "Waiting for pmie process(es) to terminate ..." "$PCP_ECHO_C" pmie_check -s >$tmp/pmie 2>&1 if [ -s $tmp/pmie ] then logfile=$PCP_LOG_DIR/pmie/pmie_check.log mv -f $tmp/pmie $logfile message="pmie_check stop failed in $prog, see $logfile" $PCP_SYSLOG_PROG -p daemon.warning "$message" $PCP_BINADM_DIR/pmpost "$message" fi if [ "$1" = quietly ] then true && $RC_STATUS else true && $RC_STATUS -v fi rm -f $PCP_RUN_DIR/pmie.pid rm -fr "$tmp/pmie" "$PCP_TMP_DIR"/pmie/* $PCP_BINADM_DIR/pmpost "stop pmie from $pmprog" } while getopts v c do case $c in v) # force verbose VERBOSE_CTL=on ;; *) _usage exit 1 ;; esac done shift `expr $OPTIND - 1` if [ $VERBOSE_CTL = on ] then # For a verbose startup and shutdown ECHO=$PCP_ECHO_PROG VFLAG='-V' else # For a quiet startup and shutdown ECHO=: VFLAG= fi case "$1" in start|start-systemd|faststart|restart|condrestart|reload|force-reload) if [ "$1" = "condrestart" ] && ! is_chkconfig_on pmie then status=0 exit fi _shutdown quietly # messages should go to stderr, not the GUI notifiers # unset PCP_STDERR _reboot_setup if which pmie >/dev/null 2>&1 then # issue a warning if there's no chkconfig/crontab support if is_chkconfig_on pmie then : elif [ "$0" = "$pmprog" -o "$0" = "$rcprog" ] then echo "$prog: Warning: Performance Co-Pilot Inference Engine (pmie) not permanently enabled." chkconfig_on_msg pmie fi _start_pmie $1 fi status=0 ;; stop) _shutdown verbose status=0 ;; stop-systemd) _shutdown quietly status=0 ;; status) # NOTE: $RC_CHECKPROC returns LSB compliant status values. $ECHO $PCP_ECHO_N "Checking for pmie:" "$PCP_ECHO_C" if [ -r /etc/rc.status ] then # SuSE $RC_CHECKPROC pmie $RC_STATUS -v status=$? else # not SuSE $RC_CHECKPROC pmie status=$? if [ $status -eq 0 ] then $ECHO running else $ECHO stopped fi fi ;; *) _usage ;; esac # optional end logging to $PCP_LOG_DIR/NOTICES # if $PCP_LOG_RC_SCRIPTS then $PCP_BINADM_DIR/pmpost "end pid:$$ $prog status=$status" fi exit