IPH Instance List

Posted on
Thu Sep 01, 2016 4:26 pm
cramer offline
Posts: 33
Joined: Feb 03, 2015

IPH Instance List

Is there any way of listing all active IPH instances?

Posted on
Thu Sep 01, 2016 9:19 pm
MartyS offline
Posts: 86
Joined: May 06, 2008
Location: Charlotte, North Carolina

Re: IPH Instance List

cramer wrote:
Is there any way of listing all active IPH instances?

Please check out this post which first describes what I think you're looking for. The output goes into the Indigo log.

/Marty

Posted on
Fri Sep 02, 2016 8:32 am
cramer offline
Posts: 33
Joined: Feb 03, 2015

Re: IPH Instance List

Thanks Marty. I am checking out the plugin.

Posted on
Fri Sep 02, 2016 8:51 am
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: IPH Instance List

Or, open the Activity Monitor app and search for IndigoPluginHost.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Sep 03, 2016 1:56 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: IPH Instance List

cramer wrote:
Is there any way of listing all active IPH instances?

As others have noted, yes, there are several ways. It really depends on what you want the information for. The following shell (terminal) command will get you a somewhat cleaned-up list of all IPH processes:
Code: Select all
ps aA -o pid,command|grep IndigoPluginHost|grep "\-f"|cut -c1-6,129-|sed -e "s/.indigoPlugin//"

On my system the output looks like this:
    638 .Action Collection
    639 .INSTEON Commands
    641 .Z-Wave
    642 DSC Alarm
    643 Growl
    647 IP9258
    648 MetaDevice
    649 Netatmo 2
    650 Phidgets
    652 Proliphix
    653 Timers and Pesters
    654 Virtual Devices
Plugin names starting with a "." are internal Indigo plugins.

It is also possible to include background scripts. But, as noted above, the contents and output format really depend nohow you want to use the data. If you can provide more detail, I can tune the command above to suit your needs.

Posted on
Sat Sep 03, 2016 12:34 pm
cramer offline
Posts: 33
Joined: Feb 03, 2015

Re: IPH Instance List

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. 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.

Posted on
Mon Sep 05, 2016 2:42 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: IPH Instance List

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:
Code: Select all
ps aA -o pid,command|grep IndigoPluginHost|cut -c1-6,127-|sed -e "s/.indigoPlugin//"

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?

Posted on
Mon Sep 05, 2016 2:45 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: IPH Instance List

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:
Code: Select all
ps aA -o pid,command|grep IndigoPluginHost|cut -c1-6,127-|sed -e "s/.indigoPlugin//"
Which will give an output something like:
    638 -f.Action Collection
    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
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?

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?

Posted on
Mon Sep 05, 2016 1:55 pm
cramer offline
Posts: 33
Joined: Feb 03, 2015

Re: IPH Instance List

Thanks berkinet. I am using Python and the -x lines are what I am interested in.

Posted on
Tue Sep 06, 2016 3:01 am
MartyS offline
Posts: 86
Joined: May 06, 2008
Location: Charlotte, North Carolina

Re: IPH Instance List

Thanks to berkinet's sleuthing to come up with the likely "meaning" of -f, -e and -x, I have updated my bash shell script for listing out all Indigo processes.

An example of running the script (it is in my ~/bin folder for easy access):
Code: Select all
$ 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
The script lists the process PID, cumulative CPU time and information about the process derived from its command line. Note too that it shows any zombie processes — ones that are no longer able to run for some reason. Unfortunately, once a process is a zombie its original command line is not directly accessible to know what its purpose was, and cannot ordinarily be killed without rebooting

The reason my AppleScript process shows up in the output is because I store all my external (python or AppleScript) scripts into the Indigo Scripts path and this bash script starts its search off looking for Indigo, not IndigoServerPlugin or other more specific names. Clever, huh! 8)

In case it would be of use to others, the updated script is as follows:
Code: Select all
#/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  /'
If the command lines of Indigo processes change with a future version then the script may need some adjustments.

/Marty

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests

cron