Page 1 of 1

Using Actions Component Command Function

Posted: Thu Aug 13, 2020 4:10 pm
by JohnWillette
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?

Re: Using Actions Component Command Function

Posted: Fri Aug 14, 2020 2:51 pm
by tgriep
Couple of things to look at.
When the win_ca7statagent.bat is ran by nagios, it is ran with the nagios user account and if it does not have sufficient permissions to the the applications in the bat file, that could be the issue.

Next, the commands do not have the full path to where they are located on the system. Add the path for the unifstat and the ccii application to the script on the XI server.

Re: Using Actions Component Command Function

Posted: Wed Aug 19, 2020 9:31 am
by JohnWillette
I added the full path to the directories for the unifstat and ccii commands. I am still not getting any results, so it may be a permissions issue. I don't have the ability to configure permissions on a remote host, so I am waiting for an admin to assist me.

On a similar note, is it possible to also use the Actions component to SSH to a Cisco router, provide login credentials, and run router show commands, i.e. show log, show ip int desc, show int brie, etc? I do have credentials, and can connect/login/execute commands on a router through the existing host "Connect to ...' function. Our Operations staff provides Level 1 support for router connectivity issues related to dedicated circuits. I would like to be able to mask credentials from the Operations staff, and still give them the ability to execute the show commands.

Re: Using Actions Component Command Function

Posted: Wed Aug 19, 2020 4:03 pm
by tgriep
I think there are some confusion on the permissions.

The script is ran in the Nagios XI server and it runs those applications to gather the data from the remote host, it that correct?

If so, then the permissions I was talking about are on the Nagios XI server and if the nagios account can run the script.

Do this, login to the server in a shell.

Change to the nagios user by running

Code: Select all

su - nagios
Run the script that you are using in the Actions Component and see if it works or prints out error messages.
If there are errors, resolve them and try again until it works.
Then run it as the Action and see if that works.


About the SSH Action.
If you can create a script that logs in to the device, runs the commands and echo's the data, it should work.