Using Actions Component Command Function
Posted: Thu Aug 13, 2020 4:10 pm
I am trying to use the Actions Component command function to work with CA-Unicenter distributed scheduling system agents that run on various Windows and Linux hosts. Specifically, I would like to be able to provide a status of the distributed agents, and the ability to stop and start the agents on a given host. The Windows agent commands are in separate batch scripts, and the Linux agent commands are in separate shell scripts.
I am working with 1 test Windows host that has the agents installed, but the scripts are very similar for either OS. I am using the status agent function for this example. I figure once I get one working, the others will be easy to replicate.
In the Actions Component, I set the object type to 'Host'. For testing, I hard coded the full Windows host name in the regex for the Host field. I did not input anything into the Service field regex, and am not currently using the Hostgroup or Servicegroup fields, although I expect to utilize Hostgroups eventually as there are approximately 60 hosts that I would like to have this functionality. I created 3 files in /usr/local/nagios/libexec that has the code for the desired function (status, stop, start). I labeled the Action Text 'WIN CA7 Agent Status'. I selected Action Type 'Command'. In the URL/Command field, I inserted the full path and script name (/usr/local/nagios/libexec/win_ca7statagent.bat). I did not place anything in the Code section. The Quick Action does show up on the host record, and it does launch a web page, but it does not appear to execute the actual commands in the code. The code does work when I run it from the command line on my Windows test host. There are multiple components to the CA7 Agents, and the commands unifstat and ccii were provided by the vendor CA. This is the result I would expect to get back -
Status of CA7 Agent processes...
C:\Windows\system32>unifstat
%CASP_I_113, Unifstat - Unicenter status utility
%CASP_I_114, Unifstat Mode is DEFAULT ALL
%CASP_I_119, Unicenter Status as of Thu Aug 13 17:04:57 2020
%CASP_I_120, General Information
%CASP_I_121, Number of Components: 5
%CASP_I_122, Number of SubComponents: 0
%CASP_I_123, Number of Requisites: 0
%CASP_I_124, Component Information for SAF
%CASP_I_125, Description: Store and Forward
%CASP_I_126, Current State: 500 - ACTIVE
%CASP_I_127, Events Queued: 0
%CASP_I_128, Requisites: 0
%CASP_I_129, SubComponents: 0
%CASP_I_124, Component Information for RTR
%CASP_I_125, Description: Router Services
%CASP_I_126, Current State: 500 - ACTIVE
%CASP_I_127, Events Queued: 0
%CASP_I_128, Requisites: 0
%CASP_I_129, SubComponents: 0
%CASP_I_124, Component Information for CAL
%CASP_I_125, Description: Calendar
%CASP_I_126, Current State: 500 - ACTIVE
%CASP_I_127, Events Queued: 0
%CASP_I_128, Requisites: 0
%CASP_I_129, SubComponents: 0
%CASP_I_124, Component Information for EMSRVC
%CASP_I_125, Description: EM Services Router
%CASP_I_126, Current State: 500 - ACTIVE
%CASP_I_127, Events Queued: 0
%CASP_I_128, Requisites: 0
%CASP_I_129, SubComponents: 0
%CASP_I_124, Component Information for SCHA
%CASP_I_125, Description: Workload Agent
%CASP_I_126, Current State: 500 - ACTIVE
%CASP_I_127, Events Queued: 0
%CASP_I_128, Requisites: 0
%CASP_I_129, SubComponents: 0
%CASP_I_113, Unifstat - Unicenter status utility
C:\Windows\system32>ccii
Oid(PWENTFTP01,CAAMSSEND ) Did( , ) type(L)
Oid(PWENTFTP01,CAI_OPR_SAFD ) Did( , ) type(L)
Oid(PWENTFTP01,CA_Cal_Chk ) Did( , ) type(L)
Oid(PWENTFTP01,EMSRVC_ROUTER_U ) Did( , ) type(L)
Oid(PWENTFTP01,SUBMITC Server ) Did( , ) type(L)
Oid(PWENTFTP01,ROUTER_SERVER ) Did( , ) type(L)
Oid(PWENTFTP01,CAU9SET SetUp Mgr ) Did( , ) type(L)
Oid(CCISYSA,CPS Manager ) Did( , ) type(R)
Oid(CCISYSA,CA$FOSYSA ) Did( , ) type(R)
Oid(CCISYSA,W410_SPAWN_SERVER ) Did( , ) type(R)
Oid(CCISYSA,MVS_START_SERVER ) Did( , ) type(R)
Oid(CCISYSA,CA7SYSA Server ) Did( , ) type(R)
Oid(CCISYSA,CAU9SET SetUp Mgr ) Did( , ) type(R)
Oid(CCISYSA,CA7SYSA Job track ) Did( , ) type(R)
Oid(CCISYSA,SUBMITC Server ) Did( , ) type(R)
Oid(CCISYSA,CA-7 XTM UC07 ) Did( , ) type(R)
This is the code in win_ca7statagent.bat -
@echo Status of CA7 Agent processes...
unifstat
ccii
I added macro $HOST% to the end of the command in the Actions Component, but still no luck.
I even changed the batch script to a shell script and inserted #!/bin/bash in the first line
I have the batch scripts copied into the NCPA plugins directory C:\Program Files (x86)\Nagios\NCPA\plugins\
I have also tried to use the path were the CA7 agent scripts reside - C:\Program Files (x86)\CA\SC\CCS\WVEM\BIN\unifstat
Any idea's?
I am working with 1 test Windows host that has the agents installed, but the scripts are very similar for either OS. I am using the status agent function for this example. I figure once I get one working, the others will be easy to replicate.
In the Actions Component, I set the object type to 'Host'. For testing, I hard coded the full Windows host name in the regex for the Host field. I did not input anything into the Service field regex, and am not currently using the Hostgroup or Servicegroup fields, although I expect to utilize Hostgroups eventually as there are approximately 60 hosts that I would like to have this functionality. I created 3 files in /usr/local/nagios/libexec that has the code for the desired function (status, stop, start). I labeled the Action Text 'WIN CA7 Agent Status'. I selected Action Type 'Command'. In the URL/Command field, I inserted the full path and script name (/usr/local/nagios/libexec/win_ca7statagent.bat). I did not place anything in the Code section. The Quick Action does show up on the host record, and it does launch a web page, but it does not appear to execute the actual commands in the code. The code does work when I run it from the command line on my Windows test host. There are multiple components to the CA7 Agents, and the commands unifstat and ccii were provided by the vendor CA. This is the result I would expect to get back -
Status of CA7 Agent processes...
C:\Windows\system32>unifstat
%CASP_I_113, Unifstat - Unicenter status utility
%CASP_I_114, Unifstat Mode is DEFAULT ALL
%CASP_I_119, Unicenter Status as of Thu Aug 13 17:04:57 2020
%CASP_I_120, General Information
%CASP_I_121, Number of Components: 5
%CASP_I_122, Number of SubComponents: 0
%CASP_I_123, Number of Requisites: 0
%CASP_I_124, Component Information for SAF
%CASP_I_125, Description: Store and Forward
%CASP_I_126, Current State: 500 - ACTIVE
%CASP_I_127, Events Queued: 0
%CASP_I_128, Requisites: 0
%CASP_I_129, SubComponents: 0
%CASP_I_124, Component Information for RTR
%CASP_I_125, Description: Router Services
%CASP_I_126, Current State: 500 - ACTIVE
%CASP_I_127, Events Queued: 0
%CASP_I_128, Requisites: 0
%CASP_I_129, SubComponents: 0
%CASP_I_124, Component Information for CAL
%CASP_I_125, Description: Calendar
%CASP_I_126, Current State: 500 - ACTIVE
%CASP_I_127, Events Queued: 0
%CASP_I_128, Requisites: 0
%CASP_I_129, SubComponents: 0
%CASP_I_124, Component Information for EMSRVC
%CASP_I_125, Description: EM Services Router
%CASP_I_126, Current State: 500 - ACTIVE
%CASP_I_127, Events Queued: 0
%CASP_I_128, Requisites: 0
%CASP_I_129, SubComponents: 0
%CASP_I_124, Component Information for SCHA
%CASP_I_125, Description: Workload Agent
%CASP_I_126, Current State: 500 - ACTIVE
%CASP_I_127, Events Queued: 0
%CASP_I_128, Requisites: 0
%CASP_I_129, SubComponents: 0
%CASP_I_113, Unifstat - Unicenter status utility
C:\Windows\system32>ccii
Oid(PWENTFTP01,CAAMSSEND ) Did( , ) type(L)
Oid(PWENTFTP01,CAI_OPR_SAFD ) Did( , ) type(L)
Oid(PWENTFTP01,CA_Cal_Chk ) Did( , ) type(L)
Oid(PWENTFTP01,EMSRVC_ROUTER_U ) Did( , ) type(L)
Oid(PWENTFTP01,SUBMITC Server ) Did( , ) type(L)
Oid(PWENTFTP01,ROUTER_SERVER ) Did( , ) type(L)
Oid(PWENTFTP01,CAU9SET SetUp Mgr ) Did( , ) type(L)
Oid(CCISYSA,CPS Manager ) Did( , ) type(R)
Oid(CCISYSA,CA$FOSYSA ) Did( , ) type(R)
Oid(CCISYSA,W410_SPAWN_SERVER ) Did( , ) type(R)
Oid(CCISYSA,MVS_START_SERVER ) Did( , ) type(R)
Oid(CCISYSA,CA7SYSA Server ) Did( , ) type(R)
Oid(CCISYSA,CAU9SET SetUp Mgr ) Did( , ) type(R)
Oid(CCISYSA,CA7SYSA Job track ) Did( , ) type(R)
Oid(CCISYSA,SUBMITC Server ) Did( , ) type(R)
Oid(CCISYSA,CA-7 XTM UC07 ) Did( , ) type(R)
This is the code in win_ca7statagent.bat -
@echo Status of CA7 Agent processes...
unifstat
ccii
I added macro $HOST% to the end of the command in the Actions Component, but still no luck.
I even changed the batch script to a shell script and inserted #!/bin/bash in the first line
I have the batch scripts copied into the NCPA plugins directory C:\Program Files (x86)\Nagios\NCPA\plugins\
I have also tried to use the path were the CA7 agent scripts reside - C:\Program Files (x86)\CA\SC\CCS\WVEM\BIN\unifstat
Any idea's?