I need ATOP to install on EC2 the instances when the machines deploy from Beanstalk. AWS support only had the link below to follow, but it doesn't show how to deploy in the ebextensions config files. Has someone already done this and have a config file already made? Thanks! --> https://www.tecmint.com/how-to-install-atop-to-monitor-logging-activity-of-linux-system-processes/
BTW using Amazon Linux
{{Edit 3/23/18}}
Working through this on my own so far, this is what I have. It doesn't fully work, but still working on it.
packages:
rpm:
epel: https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
container_commands:
1_rpm_atop:
command: "sudo /bin/rpm -i --replacepkgs
https://www.atoptool.nl/download/atop-2.3.0-1.el6.x86_64.rpm"
2_add_atop:
command: "/sbin/chkconfig --add atop"
leader_only: true
3_add_atop:
command: "/sbin/chkconfig atop on --level 235"
leader_only: true
4_config_atop:
command: "/bin/sed 's/600/60/' /usr/share/atop/atop.daily -i"
leader_only: true
5_link:
command: "/bin/ln -sfn /var/log/atop /var/app/current/wp-content/uploads/atop"
leader_only: true
6_start:
command: "/etc/init.d/atop start"
leader_only: true
With the help of the amazing Yao from AWS Beanstalk tech support, we have been able to create a file that installs ATOP on all instances. As well, it writes individual instance logs to my already existing sym-linked EFS file directory so that the logs will persist through scaling and machine deployments. This is working now in my dev deployment. If you hear nothing else, it will mean that it is working in production as well in about a week. Here's the contents tweaked for my Wordpress deployment. Enjoy!
container_commands:
1_install_config_atop:
command: /tmp/installatop.sh
files:
"/tmp/installatop.sh":
mode: "000755"
content : |
#!/bin/bash
#############################################
ATOPLOGDEST=/var/app/current/wp-content/uploads/atop/ #where to persist the atop log
LOGFILE=/tmp/atopinstall.log #installaton log
##############################################
INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id/)
exec 1>&- # close stdout
exec 2>&- # close stderr
echo "========" >> $LOGFILE
date >> $LOGFILE
echo "starting" >> $LOGFILE
echo "---- Step 1, install atop" >> $LOGFILE
echo "check if atop is installed" >> $LOGFILE
rpm -q atop >> $LOGFILE
if [ $? -ne 0 ]
then
echo "atop not installed yet" >> $LOGFILE
rpm -i https://www.atoptool.nl/download/atop-2.3.0-1.el6.x86_64.rpm
rpm -q atop >> $LOGFILE
echo "now installed" >> $LOGFILE
fi
echo "---- step 2, config atop in chkconfig" >> $LOGFILE
/sbin/chkconfig --add atop
/sbin/chkconfig atop on --level 235
echo "this is the output of chkconfig" >> $LOGFILE
/sbin/chkconfig | grep atop >> $LOGFILE
echo "---- setp 3, config atop's schedule to 60 seconds" >> $LOGFILE
/bin/sed 's/600/60/' /usr/share/atop/atop.daily -i
cat /usr/share/atop/atop.daily | grep "INTERVAL=" >> $LOGFILE
echo "---- step 4, presistent it in EFS" >> $LOGFILE
mkdir -p $ATOPLOGDEST$INSTANCEID
/bin/sed "s|/var/log/atop|$ATOPLOGDEST$INSTANCEID|" /usr/share/atop/atop.daily -i
cat /usr/share/atop/atop.daily | grep "LOGPATH=" >> $LOGFILE
stat $ATOPLOGDEST$INSTANCEID >> $LOGFILE
echo "---- step 5, restart atop" >> $LOGFILE
/etc/init.d/atop restart
sleep 5
ps aux | grep atop >> $LOGFILE
echo "---- finished!" >> $LOGFILE
date >> $LOGFILE
echo "========" >> $LOGFILE
Try this
container_commands:
1_add_epel:
command: sudo sed -i "6s,enabled=0,enabled=1,g" /etc/yum.repos.d/epel.repo
2_install_atop:
command: sudo yum update && sudo yum install atop -y
Related
I have seen this (and I upvoted it), but it falls a bit short from my needs because:
I have to I need to give on-terminal feedback (that is easy, just | tee /dev/tty)
I have to get input from users in several ways:
read -p 'prompt: ' var
select yn in "Yes" "No"; do ...
git clone from private repository asking user/pass
How can I do this (especially the select stuff)?
My current test setup (cut down to size) is:
#/bin/bash
set -e
set -x
{
if lxc list | grep container
then
:
else
lxc launch images:ubuntu/20.04 container
echo 'waiting for networking to be up-and-running...' | tee /dev/tty
sleep 5
echo 'installing base system...' | tee /dev/tty
lxc exec container -- apt update
lxc exec container -- apt install -y git
echo "install documentation processor? " | tee /dev/tty
select yn in "Yes" "No"
do
if [ $yn == "Yes" ]
then
echo 'installing documentation processor...' | tee /dev/tty
lxc exec container -- apt install -y wget
lxc exec container -- wget https://github.com/plantuml/plantuml/releases/download/v1.2022.12/plantuml-1.2022.12.jar -O /usr/local/bin/plantuml.jar
fi
break
done
read -p 'enter your EMAIL address: ' email | tee /dev/tty
lxc exec container --user 1000 --group 1000 --cwd /home/ubuntu --env HOME=/home/ubuntu -- git config --global user.email "$email"
read -p 'enter your FULL NAME: ' name | tee /dev/tty
lxc exec container --user 1000 --group 1000 --cwd /home/ubuntu --env HOME=/home/ubuntu -- git config --global user.name "$name"
lxc exec container --user 1000 --group 1000 --cwd /home/ubuntu --env HOME=/home/ubuntu -- git config --global credential.helper store
echo 'cloning repository...' | tee /dev/tty
lxc exec container --user 1000 --group 1000 --cwd /home/ubuntu --env HOME=/home/ubuntu -- git clone git#github.com:gabime/spdlog.git
echo "enable audio in container? " | tee /dev/tty
select yn in "Yes" "No"
do
if [ $yn == "Yes" ]
then
for dev in $(find /dev/snd -type c)
do
lxc config device add container snd_$(basename $dev) unix-char source=$dev path=$dev gid=1000
lxc exec container -- apt install -y alsa-utils
done
fi
break
done
fi
} >lxd_build.log 2>&1
This has all said defects:
read -p prompts are not seen on terminal (but are in log file)
select yn in "Yes" "No" prompts are not seen on terminal (but are in log file); this is unsurprising as select doesn't accept redirection.
git clone prompt for user/pass are not seen on terminal.
How can I fix this?
read -p and select both output their prompts to standard error. Make sure you're capturing the right stream if you want to copy their prompts to both the terminal and a file. For example:
read -p 'enter your EMAIL address: ' email | tee /dev/tty # prompt doesn't get duplicated
read -p 'enter your EMAIL address: ' email 2>&1 | tee /dev/tty # prompt does get duplicated
###
# Note: These cases might get a bit annoying because the redirection
# applies to both the prompt and everything inside the select statement
# You may have to do some additional redirection inside the select
# statement to make everything work exactly the way you want
###
select yn in "Yes" "No" ; do
break
done | tee /dev/tty # prompt does not get duplicated
select yn in "Yes" "No" ; do
break
done 2>&1 | tee /dev/tty # prompt does get duplicated
git clone might be more complicated. If it's using something like OpenSSH under the covers to perform ssh operations then it could be writing directly to the TTY so you can't redirect its prompts just by redirecting standard out or standard error. You may have to dive into tools like expect to capture the password prompts and write them somewhere else.
I have this function on my bash script:
sudo tshark -i eth0 -T fields -e ip.src -e dns.qry.name -Y "dns.qry.name~." -q 1>>log.txt 2>/dev/null &
while true
do
cat log.txt
done
it is capturing ips and domain names in live mode and save them into log file.
how can configure this live mode to be terminated by pressing a key?
Using tee to watch log and send the command to background, then read input to terminate script
tshark -i eth0 -T fields -e ip.src -e dns.qry.name -Y "ip" -q 2>/dev/null | tee log.txt &
read -n1 c && echo "Got key $c"
exit
Note: running the command in a console will terminate it :-p
We use our local repo in sources.list, and for 20.04 it required to add in apt.conf.d
Acquire::https::local_repo.local_host.com::Verify-Peer "false";
With Bash it works, as using,
sudo tee -a /etc/apt/apt.conf.d/80ssl-exceptions > /dev/null <<'EOF'
Acquire::https::local_repo.local_host.com::Verify-Peer "false";
EOF
But I don't find a solution to do it for Dockerfile.
I've tried it with different escape character/new line and so on, but always unsuccessful.
For example,
sudo tee -a /etc/apt/apt.conf.d/80ssl-exceptions > /dev/null <<'EOF' \
Acquire::https::local_repo.local_host.com::Verify-Peer "false"; \
EOF
Results - /bin/sh: 1: EOF: not found
To note that cat or echo is not an option, also adding those 3 line in a script is also not preferable.
If you only have one line to append then I wouldn't use a heredoc. It's simpler to use echo:
RUN echo 'Acquire::https::local_repo.local_host.com::Verify-Peer "false";' | \
sudo tee -a /etc/apt/apt.conf.d/80ssl-exceptions > /dev/null
Or cat:
RUN cat <<< 'Acquire::https::local_repo.local_host.com::Verify-Peer "false";' | \
sudo tee -a /etc/apt/apt.conf.d/80ssl-exceptions > /dev/null
Or send the string directly to sudo tee:
RUN sudo tee -a /etc/apt/apt.conf.d/80ssl-exceptions > /dev/null \
<<< 'Acquire::https::local_repo.local_host.com::Verify-Peer "false";'
Note that the latter two options may require you to also set SHELL /bin/bash since <<< is a bash-ism not available in plain sh.
I am working on Jmeter, that I have to install in a Virtual Machine. To install applications, we usually use Docker. Thus, I'd like to know if it's possible to install in my Virtual Machine the Jmeter application.
I have tried to run a lot of Docker Images but I can't understand anything about it... I tried to run and pull with docker this image : https://hub.docker.com/r/justb4/jmeter/ but when I tried to run it, I can't on GUI mode...
The thing is that I have a test plan test.jmx that I worked on in my PC, and I would like to create it in my VM (with the GUI Jmeter mode) or to export it in my VM so that I could launch it.
I don't know if anyone could help me!
Thank you in advance. Have a nice day.
To install applications, we usually use Docker.
this is very weird use case for Docker.
If you want to use Docker for running JMeter in GUI mode for tests development I doubt that you will be able to find a suitable image in the DockerHub, most probably you will need to build one yourself, an example Dockerfile would be something like:
FROM alpine:edge
ENV DISPLAY :99
ENV RESOLUTION 1366x768x24
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk add --no-cache curl xfce4-terminal xvfb x11vnc xfce4 openjdk8-jre bash xrdp \
&& curl -L https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.2.1.tgz > /tmp/jmeter.tgz \
&& tar -xvf /tmp/jmeter.tgz -C /opt \
&& rm /tmp/jmeter.tgz \
&& curl -L https://jmeter-plugins.org/get/ > /opt/apache-jmeter-5.2.1/lib/ext/jmeter-plugins-manager.jar \
&& echo "[Globals]" > /etc/xrdp/xrdp.ini \
&& echo "bitmap_cache=true" >> /etc/xrdp/xrdp.ini \
&& echo "bitmap_compression=true" >> /etc/xrdp/xrdp.ini \
&& echo "autorun=jmeter" >> /etc/xrdp/xrdp.ini \
&& echo "[jmeter]" >> /etc/xrdp/xrdp.ini \
&& echo "name=jmeter" >> /etc/xrdp/xrdp.ini \
&& echo "lib=libvnc.so" >> /etc/xrdp/xrdp.ini \
&& echo "ip=localhost" >> /etc/xrdp/xrdp.ini \
&& echo "port=5900" >> /etc/xrdp/xrdp.ini \
&& echo "username=jmeter" >> /etc/xrdp/xrdp.ini \
&& echo "password=" >> /etc/xrdp/xrdp.ini
EXPOSE 5900
EXPOSE 3389
CMD ["bash", "-c", "rm -f /tmp/.X99-lock && rm -f /var/run/xrdp.pid\
&& nohup bash -c \"/usr/bin/Xvfb :99 -screen 0 ${RESOLUTION} -ac +extension GLX +render -noreset && export DISPLAY=99 > /dev/null 2>&1 &\"\
&& nohup bash -c \"startxfce4 > /dev/null 2>&1 &\"\
&& nohup bash -c \"x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :99 -forever -bg -nopw -rfbport 5900 > /dev/null 2>&1\"\
&& nohup bash -c \"xrdp -p 3389 > /dev/null 2>&1\"\
&& nohup bash -c \"/opt/apache-jmeter-5.2.1/bin/./jmeter -Jjmeter.laf=CrossPlatform > /dev/null 2>&1 &\"\
&& tail -f /dev/null"]
Save the above Dockerfile somewhere on your local drive
Build the image like:
docker build -t jmeter:gui .
Run the image like:
docker run -d -p 3389:3389 -p 5900:5900 jmeter:gui
You should be able to connect to the GUI of the running image using RDP or VNC client
For running your JMeter tests in Docker refer to Make Use of Docker with JMeter - Learn How article
I want to deploy Spring boot App on openshift
I've
.openshift/action_hooks/deploy file as
#!/bin/bash
set -x
if [ ! -d $OPENSHIFT_DATA_DIR/m2/repository ]
then
mkdir -p $OPENSHIFT_DATA_DIR/m2/repository
fi
if [ ! -d $OPENSHIFT_DATA_DIR/logs ]
then
mkdir -p $OPENSHIFT_DATA_DIR/logs
fi
if [ ! -d $OPENSHIFT_DATA_DIR/apache-maven-3.3.9 ]
then
wget -P $OPENSHIFT_DATA_DIR http://mirror.cc.columbia.edu/pub/software/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
tar xvf $OPENSHIFT_DATA_DIR/apache-maven*.tar.gz --directory $OPENSHIFT_DATA_DIR
rm -f $OPENSHIFT_DATA_DIR/apache-maven*.tar.gz
fi
export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0
export M2=$OPENSHIFT_DATA_DIR/apache-maven-3.3.9/bin
export MAVEN_OPTS="-Xms384m -Xmx412m"
export PATH=$JAVA_HOME/bin:$PATH
cd $OPENSHIFT_REPO_DIR
$M2/mvn --version
$M2/mvn -s settings.xml clean install
# if you get error then un comment the following line
#$M2/mvn -s settings.xml package
nohup java -Xms384m -Xmx412m -jar target/*.jar --server.port=${OPENSHIFT_DIY_PORT} --server.address=${OPENSHIFT_DIY_IP} --spring.profiles.active=openshift &
and .openshift/action_hooks/start file as
#!/bin/bash
source $OPENSHIFT_CARTRIDGE_SDK_BASH
set -x
export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0
export PATH=$JAVA_HOME/bin:$PATH
cd $OPENSHIFT_REPO_DIR
nohup java -Xms384m -Xmx412m -jar target/*.jar --server.port=${OPENSHIFT_DIY_PORT} --server.address=${OPENSHIFT_DIY_IP} --spring.profiles.active=openshift &
and .openshift/action_hooks/stop file as
#!/bin/bash
source $OPENSHIFT_CARTRIDGE_SDK_BASH
# The logic to stop your application should be put in this script.
if [ -z "$(ps -ef | grep testrubyserver.rb | grep -v grep)" ]
then
client_result "Application is already stopped"
else
kill `ps -ef | grep testrubyserver.rb | grep -v grep | awk '{ print $2 }'` > /dev/null 2>&1
fi
after deploying to openshift I get
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache/2.2.15 (Red Hat) Server at myapp-mydomain.rhcloud.com Port 80
how to resolve this problem???