Commander
Commander
781 views

how to monitor a file's age in hpomw

Hi Guys,

 

how to monitor a file's age in hpomw 9.

Need to monitor a file, and generate an alert if that file isn't modified for four hours.

Please help.

Labels (1)
0 Likes
3 Replies
Highlighted
Admiral
Admiral

Hello,

 

you cannot do it directly in OMW, i mean there is no out of the box policy allowing such thing. But you can do it by other ways:

1) You have to write a little script to check your file age, same script will send an opcmsg alert for example.

2) Or you can write your own script directly in OMW policy editor (so in Perl or VBS only) with threshold policy type, if value match the threshold you generate an alert.

Choosing local script calling opcmsg or a monitor threshold policy it's up to you, and depends on the langage you prefer coding.

0 Likes
Highlighted
Commander
Commander

Hi Nic,

 

Thank you for your response.

Have you done this before? I mean if you have the script with the below mentioned logic. If so, please help me out with the script.

"Need to monitor a file, and generate an alert if that file isn't modified for four hours"

0 Likes
Highlighted
Admiral
Admiral

Hello,

There is no  traps, just search for your exact need on google, and adapt it.

In PERL:

my $fileName = "/tmp/myfile.log";

my $fileAge = -M $fileName;

#if file is older than 1 day

if ( $fileAge > 1 ) {

opcmsg a=application o=object msg_g=message_group msg_t="text of your alarm" s=minor

}

 

Here a simple exeample in Perl, adapt it to your specific needs.

In my humble opinion, when you do not have too many exit code to test, prefer the opcmsg command, because threshold policy are more tricky to developp, here you juste have to format your opcmsg command and create a policy that match it easily.

 

PS: do not forget to close the topic if your issue is solved 😉

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.