change how telegraf script determine if there is already and instance of the script already running

This commit is contained in:
m0duspwnens
2021-11-04 23:22:13 -04:00
parent 665732bd32
commit 0b28e89f3c
13 changed files with 71 additions and 75 deletions

View File

@@ -15,17 +15,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
THEGREP=$(ps -ef | grep $0 | grep -v $$ | grep -v grep)
RAIDLOG=/var/log/raid/status.log
RAIDSTATUS=$(cat /var/log/raid/status.log)
# if this script isn't already running
if [[ ! "`pidof -x $(basename $0) -o %PPID`" ]]; then
if [ ! "$THEGREP" ]; then
RAIDLOG=/var/log/raid/status.log
RAIDSTATUS=$(cat /var/log/raid/status.log)
if [ -f "$RAIDLOG" ]; then
echo "raid $RAIDSTATUS"
else
exit 0
fi
else
exit 0
fi
exit 0