diff --git a/jsk_fetch_robot/jsk_fetch_startup/config/install_supervisor.sh b/jsk_fetch_robot/jsk_fetch_startup/config/install_supervisor.sh index d07fbfb529..9448bd5b83 100755 --- a/jsk_fetch_robot/jsk_fetch_startup/config/install_supervisor.sh +++ b/jsk_fetch_robot/jsk_fetch_startup/config/install_supervisor.sh @@ -15,6 +15,9 @@ for file in $(ls ./*.conf); do echo "copied $file to /etc/supervisor/conf.d" done +# Enable jsk_dstat job to save the csv log under /var/log +ln -s /home/fetch/Documents/jsk_dstat.csv /var/log/ros/jsk-dstat.csv + # copy config.bash to /var/lib/robo if not exists if [ ! -e /var/lib/robot/config.bash ]; then sudo cp $jsk_fetch_startup/config/config.bash /var/lib/robot/config.bash diff --git a/jsk_fetch_robot/jsk_fetch_startup/scripts/dstat.bash b/jsk_fetch_robot/jsk_fetch_startup/scripts/dstat.bash new file mode 100755 index 0000000000..440237145e --- /dev/null +++ b/jsk_fetch_robot/jsk_fetch_startup/scripts/dstat.bash @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Keep only the last 1000 lines of csv log before executing dstat +CSV_FILE=/home/fetch/Documents/jsk_dstat.csv + +if [ -e $CSV_FILE ]; then + cp -f $CSV_FILE $CSV_FILE.bk + tail -n 1000 $CSV_FILE.bk > $CSV_FILE + rm -f $CSV_FILE.bk +else + touch $CSV_FILE +fi + +dstat -tl --cpufreq -c -C all --top-cpu-adv -dgimnprsTy --output $CSV_FILE diff --git a/jsk_fetch_robot/jsk_fetch_startup/supervisor_scripts/jsk-dstat.conf b/jsk_fetch_robot/jsk_fetch_startup/supervisor_scripts/jsk-dstat.conf new file mode 100644 index 0000000000..4fcf56a3e3 --- /dev/null +++ b/jsk_fetch_robot/jsk_fetch_startup/supervisor_scripts/jsk-dstat.conf @@ -0,0 +1,11 @@ +; Install dstat +; sudo apt install dstat +[program:jsk-dstat] +command=/bin/bash -c ". /opt/ros/roscore_poststart.bash && . /home/fetch/ros/melodic/devel/setup.bash && rosrun jsk_fetch_startup dstat.bash" +stopsignal=TERM +autostart=true +autorestart=false +stdout_logfile=/var/log/ros/jsk-dstat.log +stderr_logfile=/var/log/ros/jsk-dstat.log +user=root +priority=1