Author |
Message
|
mrk.for.dev |
Posted: Fri Apr 16, 2021 7:52 am Post subject: MQ Prometheus Windows Service |
|
|
Novice
Joined: 11 Jan 2021 Posts: 23
|
Hello,
I try to create a service in the QM to start and stop the mq_prometheus collector like in the following link but on Windows: https://github.com/ibm-messaging/mq-metric-samples
For the "Stop command", I found the equivalent on Windows which is : taskkill.exe /F /PID mq_prometheus.exe
Except I get the following error when I try to stop it:
AMQ5019E: Unable to access program 'C:\Windows\System32\taskkill.exe /F /PID mq_prometheus.exe'.
some help please? |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
markt |
Posted: Fri Apr 16, 2021 11:32 am Post subject: |
|
|
![](images/avatars/519b992c426bb0c8eac47.jpg) Knight
Joined: 14 May 2002 Posts: 504
|
The help info for taskkill says that the /pid points at a process id (eg 1234) not a program name. You should probably be looking at using the /im flag instead. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
mrk.for.dev |
Posted: Sat Apr 17, 2021 8:45 am Post subject: |
|
|
Novice
Joined: 11 Jan 2021 Posts: 23
|
Yes, I am sorry the command is:
taskkill.exe /F /IM mq_prometheus.exe |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
mrk.for.dev |
Posted: Sun Apr 18, 2021 4:19 am Post subject: |
|
|
Novice
Joined: 11 Jan 2021 Posts: 23
|
but even with this command, MQ can't execute it :/ with the same error :
IBM MQ cannot process the request because the executable specified cannot be started. (AMQ4160)
IBM MQ cannot process the request because the executable specified cannot be started. (AMQ4160)
The IBM MQ user does not have sufficient access to execute the program. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
bruce2359 |
Posted: Sun Apr 18, 2021 4:51 am Post subject: |
|
|
![](images/avatars/58715422151eef88d5f6e3.jpg) Poobah
Joined: 05 Jan 2008 Posts: 9407 Location: US: west coast, almost. Otherwise, enroute.
|
mrk.for.dev wrote: |
but even with this command, MQ can't execute it :/ with the same error :
IBM MQ cannot process the request because the executable specified cannot be started. (AMQ4160)
IBM MQ cannot process the request because the executable specified cannot be started. (AMQ4160)
The IBM MQ user does not have sufficient access to execute the program. |
Which user is attempting to execute the program? _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
mrk.for.dev |
Posted: Sun Apr 18, 2021 5:01 am Post subject: |
|
|
Novice
Joined: 11 Jan 2021 Posts: 23
|
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
bruce2359 |
Posted: Sun Apr 18, 2021 5:56 am Post subject: |
|
|
![](images/avatars/58715422151eef88d5f6e3.jpg) Poobah
Joined: 05 Jan 2008 Posts: 9407 Location: US: west coast, almost. Otherwise, enroute.
|
mrk.for.dev wrote: |
User(MUSR_MQADMIN) |
How did you determine that this is, in fact, the user attempting to execute the program? _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
mrk.for.dev |
Posted: Mon Apr 19, 2021 11:19 pm Post subject: |
|
|
Novice
Joined: 11 Jan 2021 Posts: 23
|
I finally managed to find an explanation.
In fact, the user MUSR_MQADMIN does not have the right to kill a process by its name but rather by its PID.
To solve the problem, a simple batch script can find the PID according to the port used and then kill it with: C:\Windows\System32\taskkill.exe /F /PID <PID_MQ_PROMETHEUS> |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
bruce2359 |
Posted: Tue Apr 20, 2021 4:40 am Post subject: |
|
|
![](images/avatars/58715422151eef88d5f6e3.jpg) Poobah
Joined: 05 Jan 2008 Posts: 9407 Location: US: west coast, almost. Otherwise, enroute.
|
For the benefit of others, how did you discover that MUSR didn’t have execution authority? _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
hughson |
Posted: Tue Apr 20, 2021 9:52 pm Post subject: |
|
|
![](images/avatars/810794940518bb946528b3.jpg) Padawan
Joined: 09 May 2013 Posts: 1916 Location: Bay of Plenty, New Zealand
|
mrk.for.dev wrote: |
I finally managed to find an explanation.
In fact, the user MUSR_MQADMIN does not have the right to kill a process by its name but rather by its PID.
To solve the problem, a simple batch script can find the PID according to the port used and then kill it with: C:\Windows\System32\taskkill.exe /F /PID <PID_MQ_PROMETHEUS> |
You don't need to write a batch script to find the PID, the queue manager has an insert which it will replace with the PID of the program that was started as a SERVICE object.
So you should be able to make your STOP command something like:
Code: |
taskkill.exe /F /PID +MQ_SERVER_PID+ |
The +MQ_SERVER_PID+ is a token representing the process id of the process started by the STARTCMD and STARTARG arguments.
See Running the Trigger Monitor as a SERVICE for an example of doing this with the trigger monitor that I wrote a little while back.
Cheers,
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
markt |
Posted: Tue Apr 20, 2021 11:17 pm Post subject: |
|
|
![](images/avatars/519b992c426bb0c8eac47.jpg) Knight
Joined: 14 May 2002 Posts: 504
|
One thing you have to be careful of on Windows is how the program is actually started. Using +MQ_SERVER_PID+ is fine where the real program is started directly from the service definition.
But in many cases, what people do is have a batch program/script that wraps around the main program. Perhaps setting up additional environment variables, or expanding beyond the length limits of the STARTARG attribute. That's often particularly needed when running Java programs where you need to setup CLASSPATHs etc. So that the pid as seen by the qmgr refers to the script rather than the real program.
At least the Windows taskkill program does have the /T option to kill children of the nominated process, so that should work here. But you may need to know a bit more about the overall process structure to be sure that is what you want.
On Unix it's less of an issue because the last line of a setup script can use "exec" so that the invoked program inherits the pid from the script and +MQ_SERVER_PID+ works directly. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
mrk.for.dev |
Posted: Wed Apr 21, 2021 1:08 am Post subject: |
|
|
Novice
Joined: 11 Jan 2021 Posts: 23
|
I think Chevalier has already said what I wanted to say.
In fact, the program is run in a batch file. The queue manager sets MQ_SERVER_PID to the PID of the launched batch and not the PID of the program launched in the batch. And this is not enough.
On Unix, we don't have this problem. I tested it and it works without fail.
Poobah: You can see this in the MQ logs. When the process does not stop, an error is traced with information like the user who executed the command. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
bruce2359 |
Posted: Wed Apr 21, 2021 7:07 am Post subject: |
|
|
![](images/avatars/58715422151eef88d5f6e3.jpg) Poobah
Joined: 05 Jan 2008 Posts: 9407 Location: US: west coast, almost. Otherwise, enroute.
|
mrk.for.dev wrote: |
Poobah: You can see this in the MQ logs. When the process does not stop, an error is traced with information like the user who executed the command. |
Rather than telling us that an error is traced, please post here complete error that you saw in the logs - especially the message ID (AMQ.......). _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
mrk.for.dev |
Posted: Wed Apr 21, 2021 7:39 am Post subject: |
|
|
Novice
Joined: 11 Jan 2021 Posts: 23
|
Code: |
18/04/2021 14:52:14 - Process(3772.1) User(MUSR_MQADMIN) Program(amqzmgr0.exe)
Host(DESKTOP-2J0TVOF) Installation(Installation1)
VRMF(9.2.1.0) QMgr(QMMONITORED)
Time(2021-04-18T12:52:14.372Z)
CommentInsert1(C:\Windows\System32\taskkill.exe /F /PID 11856)
AMQ5019E: Unable to access program 'C:\Windows\System32\taskkill.exe /F /PID
11856'.
EXPLANATION:
A request was made to execute the program C:\Windows\System32\taskkill.exe /F
/PID 11856, however the operation was unsuccessful because the program could
not be found in the specified location.
ACTION:
Check the definition of the service specifies the correct and full path to the
program to run. If the path is correct then verify that the program exists in
the specified location and that IBM MQ userid has permission to access it. |
|
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
RogerLacroix |
Posted: Wed Apr 21, 2021 10:16 am Post subject: |
|
|
![](images/avatars/136281076646ca0b3d89dee.gif) Jedi Knight
Joined: 15 May 2001 Posts: 3254 Location: London, ON Canada
|
Can you dump out the service object definition and post it here? I'm curious how you have STOPCMD and STOPARG configured.
i.e.
Code: |
dis service({service_name}) |
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
|