LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-01-2016, 08:21 AM   #1
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 302
Blog Entries: 4

Rep: Reputation: Disabled
Script to send notification when process finishes


Hey all. So, the goal here is to know when tape backup jobs are idle (nothing being backed up). The process name I'm interested in is called nvjobmgr. They only exist (as far as I can tell, anyway) when jobs are active. Then they disappear when idle. I'm trying to determine how long Netvault is idle before the next set of jobs kick off. This metric, hopefully, should help determine whether we need to purchase additional drives, how much more/less data it's backing up, etc.

The initial thought was to somehow "daemonize" the script to constantly monitor PID names for process name "nvjobmjr", write a statement with date/time stamp when jobs start into a file (perhaps /var/log/netvault/nvactive.txt), then create a different file (/var/log/netvault/nvidle.txt) when jobs finish.

If anyone has done something similar, might you be willing to share your code please?
 
Old 04-01-2016, 08:37 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,474

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
If your process creates a PID file or lock file then you could use incrond/incrontab to monitor the folder and write a timestamp when the file is create and when the file is deleted.

Alternatively a cron job that runs every minute and detects the process name from ps and write a timestamp and sets a flag when there's no process and writes a timestamp and sets a flag if it sees a process.

What schedules the runs of your backup? Could you write a wrapper around them to write your timestamps when they start/finish rather than using an external detection process?

Alternatively, do your backup jobs have log files that give the start/finish times, you could write a script to pull the start/finish information from each job log file in to a central log file and analyse that?
 
Old 04-01-2016, 08:46 AM   #3
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 302

Original Poster
Blog Entries: 4

Rep: Reputation: Disabled
Unfortunately, the way Netvault handles log files is what I'd consider atypical. Their code creates binaries that are read by the nvgui Log program in /usr/netvault/logs/. But I think you might be on to something because, looking at those binaries, if I can cross-reference date/time with actual PID start/stop times, then they'd be accurate enough to use as a basis for metrics.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need advice on writing a script to check if a file exists and send notification santosh662 Linux - Server 20 04-09-2012 08:57 AM
How to start a process and send input to it in a shell script MTK358 Programming 46 06-11-2011 08:09 AM
Need a script which does Health check for Linux and send mail notification? your_shadow03 Linux - Newbie 6 11-26-2009 06:20 PM
SARG - sort process never finishes HiOctane21 Linux - Software 0 06-07-2006 05:53 PM
E-Mail notification to users via SMS (gateway script ok, but notification script?!?) Riku2015 Linux - Networking 10 03-08-2002 10:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration