cramer wrote:Is there any way of listing all active IPH instances?
cramer wrote:Is there any way of listing all active IPH instances?
ps aA -o pid,command|grep IndigoPluginHost|grep "\-f"|cut -c1-6,129-|sed -e "s/.indigoPlugin//"
cramer wrote:The script is running from a Virtual device. When the virtual device is set to off, the script is invoked and continues to process while monitoring an Indigo variable. When the virtual device is set to on, the Indigo variable is given a new value. The script should see this and terminate.
cramer then wrote:It sounds like you want a script that stays active in the background and monitors the activity of other scripts. First, if you are monitoring a script launched from inside Indigo, the command I sent you needs to be modified to include scripts, right now they are edited out to show only plugins. Something like this will show all IPH processes:I want to check that this is happening. Also, the script creates a secondary thread and I would like to be able to check that that has terminated along with the initial thread.
ps aA -o pid,command|grep IndigoPluginHost|cut -c1-6,127-|sed -e "s/.indigoPlugin//"
berkinet wrote:I am still a bit confused as to what you are doing. But, I will try to offer some thoughts...
(BTW, I assume you are coding your script in Python. If you are using AppleScript the first comment below will not apply.cramer wrote:The script is running from a Virtual device. When the virtual device is set to off, the script is invoked and continues to process while monitoring an Indigo variable. When the virtual device is set to on, the Indigo variable is given a new value. The script should see this and terminate.
This part seems straight forward, the script needs to subscribe to changes in variable values and watch for changes to the specific variable in question, then exit. Rather than doing this in a script, have you thought of using a trigger or triggers to monitor the Variable value and then take some action?cramer then wrote:I want to check that this is happening. Also, the script creates a secondary thread and I would like to be able to check that that has terminated along with the initial thread.
It sounds like you want a script that stays active in the background and monitors the activity of other scripts. First, if you are monitoring a script launched from inside Indigo, the command I sent you needs to be modified to include scripts, right now they are edited out to show only plugins. Something like this will show all IPH processes:Which will give an output something like:
- Code: Select all
ps aA -o pid,command|grep IndigoPluginHost|cut -c1-6,127-|sed -e "s/.indigoPlugin//"
638 -f.Action Collection
The option flags -f, -e and -x seem to mean, respectively, Plugin, internal process, script. I think those flags come from Indigo, but I can't find any documentation - Jay, Matt?
639 -f.INSTEON Commands
641 -f.Z-Wave
642 -fDSC Alarm
643 -fGrowl
647 -fIP9258
648 -fMetaDevice
649 -fNetatmo 2
650 -fPhidgets
652 -fProliphix
653 -fTimers and Pesters
654 -fVirtual Devices
12800 -e_background_
23934 -x/Library/Application Support/Perceptive Automation/Indigo 6/Scripts/MyScripts/doorbirdserver.py
Basically, you need to repeatedly run this command, or some variant in a sub-process, capture and parse the output as needed. Since you know the names of the processes you are interested in, you can simply key on the executable name. However, what is still not clear is what you intend to do when your monitor script detects a problem?
$ Indigo_processes
127 42:51.49 Indigo Server
385 0:04.32 plugin Growl
386 0:04.22 plugin minMax
391 0:04.29 plugin SQL Logger
396 0:00.00 zombie
397 0:06.17 plugin Weather-Conditions
404 34:22.30 Indigo WebServer
2626 18:47.72 plugin Thermostat
2634 16:45.45 plugin BetterEmail
2644 17:58.52 plugin apcupsd
2663 16:22.62 plugin NOAA Weather
2665 53:11.54 plugin NOAA Weather Plus
46209 0:00.00 zombie
52822 6:55.06 plugin utilities
52888 8:50.48 plugin Action Collection
62666 0:00.33 script /Library/Application Support/Perceptive Automation/Indigo 5/Scripts/local/check_log_for_send_failures.py
62667 0:00.44 script /Library/Application Support/Perceptive Automation/Indigo 5/Scripts/local/check_internet.py
63731 0:00.04 AppleScript /Library/Application Support/Perceptive Automation/Indigo 5/Scripts/local/log_entries_into_variables.scpt
#/bin/bash
# list out all Indigo processes, including Indigo's Server, WebServer, plugins, running scripts and any zombie processes
# start with only the process values we're interested in
ps aA -o pid,cputime,command | \
# only include lines that have "Indigo" somewhere in the command line
grep Indigo | \
# remove any lines that could just be copies of this script running
grep -v -e ' grep Indigo' -e ' awk ' -e ' sed -E' | \
#
# reformat the output for some process types
awk ' \
# setup an output line format for the `cut` to come later
BEGIN { OUTPUT_FMT = "%5u %9s %112s %s\n" }
/\(IndigoPluginHost\)/ { printf (OUTPUT_FMT, $1, $2, " ", "zombie") ; next }
/IndigoPluginHost/ { print $0 ; next }
/IndigoServer/ { printf (OUTPUT_FMT, $1, $2, " ", "Indigo Server") ; next }
/IndigoWebServer/ { printf (OUTPUT_FMT, $1, $2, " ", "Indigo WebServer") ; next }
# we do not specifically recognize the line but it could be an external script (python or AppleScript)
{ printf (OUTPUT_FMT, $1, $2, " ", substr($0, 17, 999)) }
# we are done with awk
' | \
# for debugging of the awk output...
# tee Indigo_processes.lst | \
#
# take only the parts of the output line we're wanting to show
cut -c1-16,129- | \
#
# massage some of the information if it shows up to make the final output more readable:
#
# remove any communications port number argument
# strip off the extension used for plugins
# make AppleScript seem more normal
# decode the flags seen with IndigoPluginHost processes
#
sed -E -e 's/ -p([0-9]*) / /' \
-e 's/.indigoPlugin//' \
-e 's./usr/bin/osascript .AppleScript .' \
-e 's/ -x/ script /' -e 's/ -f/ plugin /' -e 's/ -e/ internal /'
Users browsing this forum: No registered users and 4 guests