Active IQ Unified Manager Discussions

OnCommand Unified Manager alert/script integration?

WAFLHERDER
8,885 Views

Has anyone tried script integration with OCUM 7.1? I cannot seem to get it to work, or perhaps I have misunderstood something ...

 

I have uploaded a test script in Perl to the OCUM server and associated it with an alert.

 

I can then test this alert (click on test in the Web UI) and I receive an Alert email message from OCUM, however I don't see the output of my script anywhere. If I have understood correctly, it should be added to the body of the email message. Is that correct?

 

On the OCUM server system itself I can see that my script has apparently been successfully run i.e. in the file "/var/log/ocum/ocum-script.log" I see:

...

2017-03-07 20:42:13 [DEBUG] [ScriptExecutor-8] [AuthenticationUtils:73] - Successfully logged in for script execution.
2017-03-07 20:42:13 [INFO ] [ScriptExecutor-8] [AlertScriptService:104] - Script execution of file : all_args.pl for EventID : 282400 in progress..
$VAR1 = [
          '-eventID',
          '282400',
          '-eventName',
          'LIF Status Down',
          '-eventSeverity',
          'error',
          '-eventSourceID',
          '10056564',
          '-eventSourceName',
          'clusternodename-ic2',
          '-eventSourceType',
          'NETWORK_LIF',
          '-eventState',
          'NEW',
...

2017-03-07 20:42:53 [INFO ] [ScriptExecutor-8] [AlertScriptService:90] - Execution of script file : all_args.pl for EventID : 282400 completed successfully with exitcode : 0
2017-03-07 20:42:53 [DEBUG] [ScriptExecutor-8] [AuthenticationUtils:115] - Successfully logged out.

 

The "$VAR1 = ..." text is the output of the script, all this script does is to print out its arguments and environment.

 

The OCUM server is the VMware appliance platform, it was recently upgraded from version 6.2 to 7.1. Other than this issue it seems to be functioning normally.

 

Thanks in advance for any advice!

 

Cheers,

Robb.

 

4 REPLIES 4

mbeattie
8,708 Views

Hi Robb,

 

Here is very simple example of attaching a script to an alarm for the OCUM vApp in perl. There is additional information available here:

 

http://www.netapp.com/us/media/tr-4585.pdf

 

If for examples sake you just wanted to test that you can attach a script to an alarm and that the script is executed successfully to verify the application is functioning as expected then...

 

  • Create a perl script which creates a file in the scriptPlugin directory by eventID number. EG (in my case i saved the file as 'ocumalarm.pl')

 

 

#!/usr/bin/perl
my $file="/opt/netapp/ocum/scriptPlugin/$ARGV[1]";
open (MYFILE, ">>", $file);
print MYFILE "$ARGV[0] $ARGV[1]\n";
close (MYFILE);
  • Upload the script to OCUM ("Administration \ Manage Scripts \ Add").
  • Create your OCUM alarm and configure it to attach the uploaded script. EG

ocum_alarm.png

 

  • Invoke the process which triggers the alarms, creates an event and runs the script. (In my case i admin failed a disk to trigger the alarm and create the event)

ocum_event.png

 

  • Check the script logs to view the event arguments and script exit code.

You can view the instructions on how to login to the OCUM vApp applianance here:

https://kb.netapp.com/support/s/article/ka31A00000012qfQAA/How-to-access-the-OnCommand-Virtual-Machine-DIAG-shell


Also i've written some instuctions on how to troubleshoot it here:

https://community.netapp.com/t5/OnCommand-Storage-Management-Software-Discussions/customizing-mails-from-ocum-7-1/m-p/131149#M23751

Using the above example when i trigger the alarm (in my case by admin failing a disk on a simulator) the script is successfully invoked and executed creating the file by eventID number.

 

 

diag@TESTOC71P1:~$ sudo -i
root@TESTOC71P1:~# cd /var/log/ocum
root@TESTOC71P1:/var/log/ocum# cat ocum-script.log 2017-05-23 12:48:57 [DEBUG] [default task-64] [ScriptPlugin:30] - Processing the rest request for script plugin. Event ID : 10 2017-05-23 12:48:57 [INFO ] [ScriptExecutor-1] [AlertScriptService:216] - Detecting command for file : ocumalarm.pl 2017-05-23 12:48:57 [DEBUG] [ScriptExecutor-1] [AlertScriptService:169] - ------ Script Arguments BEGIN------ 2017-05-23 12:48:57 [DEBUG] [ScriptExecutor-1] [AlertScriptService:175] - -eventID : 10 -eventName : Some Failed Disks -eventSeverity : critical -eventSourceID : 1 -eventSourceName : cluster1 -eventSourceType : CLUSTER -eventState : NEW -eventArgs : count=1,diskMessage=NET-1.1 (admin failed),disksList=NET-1.1 2017-05-23 12:48:57 [DEBUG] [ScriptExecutor-1] [AuthenticationUtils:73] - Successfully logged in for script execution. 2017-05-23 12:48:57 [INFO ] [ScriptExecutor-1] [AlertScriptService:104] - Script execution of file : ocumalarm.pl for EventID : 10 in progress.. -eventID 2017-05-23 12:49:37 [INFO ] [ScriptExecutor-1] [AlertScriptService:90] - Execution of script file : ocumalarm.pl for EventID : 10 completed successfully with exitcode : 0 2017-05-23 12:49:38 [DEBUG] [ScriptExecutor-1] [AuthenticationUtils:115] - Successfully logged out.

The file is sucessfully created in the script plugin directory:

 

root@TESTOC71P1:/opt/netapp/ocum/scriptPlugin# ls -1
10
ocumalarm.pl
root@TESTOC71P1://opt/netapp/ocum/scriptPlugin# cat 10
-eventID 10

 

Obviously the script isn't doing much other than logging the event arguements but hopfully it's a useful example for you to get started.

 

/Matt

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

scheckel
8,426 Views

Hi,

 

we have installed OCUM on a windows server..

 

Can you advice if thee script will also  work on Windows:

 

#!/usr/bin/perl
my $file="/opt/netapp/ocum/scriptPlugin/$ARGV[1]";
open (MYFILE, ">>", $file);
print MYFILE "$ARGV[0] $ARGV[1]\n";
close (MYFILE);

 

I think wirth path spelling it needs to be modified, can you help on this?

 

Best wishes,

Markus.

mbeattie
8,409 Views

Hi Markus,

 

As you are running OCUM on Windows it would be more appropriate to run a powershell script than a PERL script. I don't believe the PERL binaries are included with the OCUM installer on windows. The OCUM vApp does have a version of PERL. If you want to do the same thing in powershell, first check\set your execution policy:

 

PS C:\> Get-ExecutionPolicy

PS C:\> Set-ExecutionPolicy Unrestricted

 

Note: on a default windows installation the powershell execution policy is set to restricted. This will prevent OCUM from running the script. The solution is to open an elevated powershell prompt running as admin and set your execution policy.

 

Then save the following as .ps1 file and upload it into the script plugin directory via GUI. Click on "manage scripts". The default location is "C:\Program Files\NetApp\ocum\scriptPlugin"

 

$Args[1] | Out-File -FilePath $($(Split-Path($MyInvocation.MyCommand.Path)) + "\" + $((Get-Date).ToString("yyyy_MM_dd_HH_mm_ss_fff")) + "_event_id_" + $Args[1] + ".log")

If you attach this to an alarm and trigger it all it will do is log the event ID by date and time to a file in the script plugin directory. EG

 

C:\Program Files\NetApp\ocum\scriptPlugin>dir /b
2017_07_20_22_32_02_056_event_id_13.log
ocum_event.ps1

It's just an example to test the functionality and ensure your script is being invoked when the alarm is triggered and an event is generated.

You can search "ocum-script.log" file for details. The default log file location on Windows is:

 

C:\ProgramData\NetApp\OnCommandAppData\ocum\log\ocum-script.log

Search the for the OCUM event ID number. Is there something in particular you are attempting to achieve with a script for your OCUM alarm?

 

Hope this helps

 

/Matt

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

TSUNIXBACKUP
6,302 Views

Hi

 

Could you output script 'ocumalarm.pl'?   I want to see sintax

 

thanks a lot in advanced

Public