summaryrefslogtreecommitdiff
path: root/atop.d
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2025-09-01 03:37:41 +0000
committerCoprDistGit <infra@openeuler.org>2025-09-01 03:37:41 +0000
commit9277230d563667e3f0dcf643f8d8b6340b283959 (patch)
tree364b839c96fa63c0d28878b2b54cdd7796c61412 /atop.d
parentebea0bc511d8dea186a6a197da59354787b4ea1f (diff)
Diffstat (limited to 'atop.d')
-rw-r--r--atop.d41
1 files changed, 41 insertions, 0 deletions
diff --git a/atop.d b/atop.d
new file mode 100644
index 0000000..0195ad1
--- /dev/null
+++ b/atop.d
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# load sysconfig atop
+
+[ -f /etc/sysconfig/atop ] && . /etc/sysconfig/atop
+# Current Day format
+[ -z $CURDAY ] && CURDAY=`date +%Y%m%d`
+# Log files path
+[ -z $LOGPATH ] && LOGPATH=/var/log/atop
+# Binaries path
+[ -z $BINPATH ] && BINPATH=/usr/bin
+# PID File
+[ -z $PIDFILE ] && PIDFILE=/var/run/atop.pid
+# interval (default 10 minutes)
+[ -z $INTERVAL ] && INTERVAL=600
+
+
+start_atop() {
+# start atop for all processes with interval of $INTERVAL
+# (by default 10) minutes
+$BINPATH/atop -a -w $LOGPATH/atop_$CURDAY $INTERVAL > $LOGPATH/atop.log 2>&1 &
+echo $! > $PIDFILE
+}
+
+# verify if atop still runs for daily logging
+#
+if [ -f $PIDFILE ]; then
+ PID=`cat $PIDFILE`
+ if [ -s $PIDFILE ] && ps -p $PID | grep 'atop$' > /dev/null
+ then
+ kill -USR1 $PID # take final sample
+ sleep 3
+ kill -TERM $PID
+ rm $PIDFILE
+ sleep 1
+ else
+ exit 1
+ fi
+fi
+start_atop
+exit 0