• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 138
  • Last Modified:

IFS trigger function

Hi Experts,

I prefer to use a Webservice for this kind of requirements, but that is not in scope in this question

So I have to write a trigger (or trigger-like program) on the IFS, that will be fired when a File is added to a specified path (or even a specific file extention)
Writing a NEP is no option because of the immediate action I have to take.
I found the next options:
  1. Use an ExitProgram on QIBM_QP0L_SCAN_CLOSE
  2. set Journaling to the specific IFS-path
  3. .... any other sugestion is more then welkome

Defining the Exit program keep telling me :
CPF3CE5 ; Exit point QIBM_QP0L_SCAN_CLOSE with format SCCL0100 will not allow exit program MyEXIT library MyLIB to be added.                    
I also not convinced that this is the right way, because every close action in the IFS will trigger this program (not only one specific path I assume)

Journaling is maybe better but:
RCVJRNE seems to loop through all entries and give unreadable data to my program (lots of questionmarks).

I'm out of ideas... don't know what I have to specify to solve this.
0
Murphey
Asked:
Murphey
  • 3
  • 3
1 Solution
 
MurpheyApplication ConsultantAuthor Commented:
Hi Experts,

Some extra info:
The IFS map can be a remote mounted filesystem or Local

IBM info tells me that I need to define some Program Data:
"When you register the exit program, the following program data must be provided. The following table shows the structure of the program data information. For a description of the fields in this format, see Field Descriptions. This structure is defined in header file qp0lscan.h as data type Qp0l_Scan_Program_Data_t."

Offset      Type      Field
Dec      Hex
0      0      Char(10)      User profile
10      A      Char(20)      Scan key
30      1E      Char(12)      Scan key signature

This last info doesn't make it any clearer for me?
What scan key?
What signature?
0
 
Gary PattersonVP Technology / Senior Consultant Commented:
The scanning exit points are primarily for use by antivirus software.  You can use them for what you want to do, but that isn't the primary purpose.  You'll need to configure the scanning system values appropriately, write exit programs (they need to be thread-safe), and properly register the exit programs.  If you use IBM i based AV software, you'll need to avoid conflicts.

This API has lots of conditions and restrictions:

https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/apis/ifscloseexit.htm

CPF3CE5 means that you had an error on ADDEXITPGM - most likely, you didn't specify (or correctly specify) the  required Exit Program Data (PGMDTA) parameter for this Exit Point: User Profile, Scan Key, and Scan Signature.  This exit point is designed to be used by multiple applications for a variety of purposes, and can be registered to up to 50 different exit programs.  The User Profile, Scan Key, and Scan Signature are fields that you can define distinguish your exit program from others.

You can find the descriptions of these fields here in the "Field Descriptions" sections:

https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/apis/ifscloseexit.htm

The User Profile is the *USRPRF object that the Exit program you create will run under.  Make sure this profile has *USE rights to the exit program object.

Scan key and scan key signature are explained here, and are designed to allow AV vendors to minimize the number of times an IFS object is scanned, for example if the object was scanned when it was created, and hasn't been changed in a significant way since.

https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/apis/ifsopenexit.htm#HDRSCkey

You'll also need to define proper values for your application for a couple of scanning-related system values (QSCANFSCTL and QSCANFS):

https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/ifs/rzaaxscansval.htm
0
 
Gary PattersonVP Technology / Senior Consultant Commented:
Setting up journaling to cover the specific directories you are interested in is going to be the simpler solution to implement, in my opinion.  If you're having trouble, provide your code and a dump of data that is creating problems for you.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
MurpheyApplication ConsultantAuthor Commented:
Hi Gary,

Thanks for the response, I tried figure-out how to read the Journal-entries, and found a layout I can use (Type4),
I'm not sure if this is the right format, for my purpose, but tests will learn :-)
0
 
Gary PattersonVP Technology / Senior Consultant Commented:
I don't know what different mechanisms can be used to create the IFS files you need, but make sure and test them and look at the journal entries generated.  For example, it isn't uncommon for a process (especially PASE/QShell processes) to create a file in a temporary location, write to the temp file, close the temp file, and the and them MOVE the file to a destination folder only once it is finalized.  If you are just journaling a particular subset of directories, you would miss the create and close events, and only see the MOVE event.

You will probably be interested in journal entries of the following types:

B/B0: IFS object create summary - If you use this to trigger an action that reads the IFS file, you may need to delay execution until you get the B/CS entry - otherwise you may start processing the file before it has been completely written.  Haven't used this in a while, though, and don't have code sample available, so just make sure you test by creating a veery large file, or delaying closing the file to see thepattern of journal entries you get if this is a concern.

B/CS: IFS object closed

B/ B3: IFS object moved - If the file is created in another location and moved into the destination directory, you may have to watch for this entry.  Object name requires pointers + offset to locate.

https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzaki/rzakijournalfinderall2.htm

Be aware of additional complexities if you use commitment control: https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/ifs/rzaaxspecial.htm

- Gary
0
 
MurpheyApplication ConsultantAuthor Commented:
Hi Gary,

Thanks, I asked my comm.partner if it's possible to send a record to a PF with FTP Append, that would make it a lot easier.
But I will try your suggestion anyway. :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now