Unix ID of Enterprise

Trying to resolve an ongoing effort to set up monitoring and automatic launches or reboots of Enterprise if it crashes, freezes or stalls with a dialog. I’ve worked out an AppleScript that does the job perfectly as long as I have the correct Unix process id assigned to the application: the pid.

The pid changes on every launch so I need to find a way to discover it. The AppleScript runs in a Panorama file that is using PostURL for monitoring Enterprise so I can also run shell scripts or anything else in order to get the current pid.

The pid is viewable in the Activity Monitor so there must be a way to acquire it, but - so far - that has evaded me. If anyone has ideas or suggestions…

When I get this worked out I intend to share the monitor with the community. We’ve all wanted it.

It should work with Pan Enterprise X too once it’s available.

The shell command

ps -u username

will return a list of every running process. Then you can search it for the one you want. This is part of the list I got when I entered

ps -u dthmpsn1

into Terminal.

The line for Safari is underlined. The pid is in the second column.

There is the unix pgrep command that supposedly will do the trick.

pgrep firefox

This returned 999 in the Terminal for me as the pid of Firefox.

Further note: You can add the -i token to make the application name case insensitive.

pgrep Firefox

This will not return anything because the app in this instance should be lower case. This however will work with it in upper or lower case:

pgrep -i Firefox

It looks like the name you will need to use for Enterprise is Carbulator. Unfortunately, that will also give you the pid of any copy of Panorama you have running.

Color me confused.

If this runs in a Panorama file, and Panorama hangs or the computer hangs, how does your AppleScript then run?

Wouldn’t a device external to the computer that monitored the ability for Enterprise to display a web page be more appropriate?

Panorama can monitor Panorama Enterprise and Enterprise can actually monitor Panorama the same way, so either will keep the other up and running with both set to run on startup. External monitoring systems can reboot the whole machine if Enterprise stays down, but to simply dodge a dialog or a crash quickly, this is my desired route.

We’re definitely on the right path here. And Enterprise comes up separately as:
501 21594 ?? 0:14.72 /Applications/Panorama/Panorama Server.app/Conte

Panorama has been able to pull it off on my own machine and I’m correctly extracting the pid. :grinning:

How to do this as the root user, or un-named user will be the next trick.

So far I’ve failed in getting Gary’s method to work but I’m sure I’m omitting something.

I wasn’t very clear. Carbulator is the name you need to use with pgrep, and even with the long format, it doesn’t seem to give you enough information to tell Panorama from Enterprise. I installed a copy of Enterprise so that I could have them both running and this is what I get.

According to Activity Monitor, Panorama Server is 1410, and Panorama is 1386.

If Panorama and Enterprise are both running on the same user account, you should be able to use info("unixusername") in your shellscript command.

Bingo! It’s working like a charm.

I need to polish it just a bit and then I’ll post a file.

It’s alive… as promised I’ve posted the result.