Re: Modifying DCL script (528 Views)
Reply
Occasional Advisor
Anup Varghese
Posts: 7
Registered: ‎02-21-2011
Message 1 of 21 (528 Views)

Modifying DCL script

Hi,

I am very new to writing DCL scripts, I have a script which i am using for monitoring the server for its availablity, but i need to modify this.

The
When the server is not reachable it writes a log to the error log and the script reads the error log and sends out a error message to the reciptents mail box.
But even if the error is rectified the scripts keeps on sending the error message as the script reads only the date and not the time.
The script runs every 15 min once and i would like to modify the time selection that is it should check for the last 15 min alone to see if any error messages and not for the whole date.

The script used to select the date is :
date1 = f$extract(0,11,f$time())

and the search script is :
sear ssfmoni:erf.log JHF,Failed,'date1/match=and/nooutput/nowarn

Kindly guide me here to modify the script.
Please use plain text.
Valued Contributor
Craig A
Posts: 99
Registered: ‎02-03-2009
Message 2 of 21 (528 Views)

Re: Modifying DCL script

$ write sys$output f$extract(0,11,f$time())
15-JUN-2011
$ write sys$output f$extract(0,16,f$time())
15-JUN-2011 11:0

Run some tests changing the the 11 to a 16 and run the job every 10 minutes.

Check what happens when the day value is <10, though.

Please use plain text.
HP Pro
Ian Miller.
Posts: 4,370
Registered: ‎06-03-2003
Message 3 of 21 (528 Views)

Re: Modifying DCL script

You may also find F$CVTIME as it can return the date&time in various formats and extract parts of the date&time.
___________________
Purely Personal Opinion
Please use plain text.
Honored Contributor
The Brit
Posts: 1,283
Registered: ‎06-18-2007
Message 4 of 21 (528 Views)

Re: Modifying DCL script

Also aware that when you include the time in the string, there is a between DATE and TIME. This will certainly break the symbol substitution in the SEARCH command.

Replace 'date1 with "''date1'"

Dave.
Please use plain text.
Occasional Advisor
Anup Varghese
Posts: 7
Registered: ‎02-21-2011
Message 5 of 21 (528 Views)

Re: Modifying DCL script

Hi,

If we are increasing the charater limit that is insted of
date1 = f$extract(0,11,f$time()) if we give date1 = f$extract(0,16,f$time()) and run the script for every 10 min then consider the situation like the error occured at 11:59 and the job ran at 12:00 the this error will not be identified.
Please use plain text.
Honored Contributor
Joseph Huber_1
Posts: 1,082
Registered: ‎02-03-2004
Message 6 of 21 (528 Views)

Re: Modifying DCL script

I would not insist to use SEARCH , instead:
Read the last entry , and build the time difference to now using f$delta_time().

Eventually use a descending sort of the file to have the last entry in the first line.
(don't use VMS format to store the date/time, but ISO format, also called VMS comparison format).
http://www.mpp.mpg.de/~huber
Please use plain text.
Honored Contributor
The Brit
Posts: 1,283
Registered: ‎06-18-2007
Message 7 of 21 (528 Views)

Re: Modifying DCL script

Another option for checking just the window since last execution would be to have each execution create a new log and search that log for your errors. After checking, you can then append the current log to the "master" log file.

Dave.
Please use plain text.
Honored Contributor
Joseph Huber_1
Posts: 1,082
Registered: ‎02-03-2004
Message 8 of 21 (528 Views)

Re: Modifying DCL script

re-reading the original question, You not only want to see the log messages from within the last 15 minutes. The file contains a lot of messages, You are interested only on those containing the strings "JHF" and "Failed", and containing a time within the last 15 minutes.

There is simply no way to select the lines using a single search.
What comes nearest would be to write the
SEARCH logifile JHF,Failed/match=and/window=1
/output=to a temporary file, read the file line-by-line until the first one where f$delta-time() tells it is not older than 15 minutes; then display/handle (send to mailbox) all lines up to the end of the file.
http://www.mpp.mpg.de/~huber
Please use plain text.
Occasional Advisor
Anup Varghese
Posts: 7
Registered: ‎02-21-2011
Message 9 of 21 (528 Views)

Re: Modifying DCL script

Hi,

I dont have much knowledge on the DCL scripts can you please help me in formaing a script.
Please use plain text.
Honored Contributor
Hoff
Posts: 4,905
Registered: ‎01-29-2006
Message 10 of 21 (528 Views)

Re: Modifying DCL script

Are you seeking to outsource your DCL coding requirements here, or are you looking to learn how to program DCL yourself, or is your central goal to get somebody here to solve a particular problem for you (at no charge)?

In place of this:

date1 = f$extract(0,11,f$time())

I'd tend to use this:

$ date1 = f$cvtime(,"ABSOLUTE","DATE")

And as for learning DCL, see the OpenVMS User's Guide available in the OpenVMS documentation shelf at:

http://www.hp.com/go/openvms/doc

If you're looking to outsource your DCL coding (or acquire training), then there are various providers available in the listings of companies over at the HP AllianceONE site:

http://www.hp.com/go/allianceone

There are various partners (that provide OpenVMS services and training) listed under the "find more partners" link at the bottom of that AllianceONE web page. (Various folks here provide these services, as well.)

And FWIW, I wrote the second edition of the _The Writing Real Programs in DCL_ book, if you can find a copy of that book around somewhere. (It's been out of print for a while.) That book goes into rather more detail, and specifically on DCL programming on OpenVMS.

I'd probably avoid this current design approach, and head toward a more managed and proactive notification approach, rather than basing the design on polling files at periodic intervals.

Have the code that is generating that log generate errors somewhere you can deal with, rather than adding more bags and baggage and complexity into the designs.

Also look to move to a scheduling tool as (when I see these piles of hacks) the folks have tended to build their own schedulers, and that gets to be a whole lot of work as compared with using a scheduler to start with. That might be Kronos or cron or a commercial package.

(And others have described the /BEFORE=time and /SINCE=time syntax, and you can have a look at specifying delta times in the /SINCE=time or /MODIFIED /SINCE=time specification. But polling is pretty gross, regardless, and as it tends involve various edge cases. So does process control. Even if you should know DCL well, these tasks and these areas can get slightly hairy.)

Please use plain text.
Honored Contributor
Joseph Huber_1
Posts: 1,082
Registered: ‎02-03-2004
Message 11 of 21 (528 Views)

Re: Modifying DCL script

something along this command file:

$ if p1.eqs."#PROCESS#" then goto process
$ pipe SEARCH ssfmoni:erf.log - JHF,Failed/match=and/window=1 | @'f$environ("PROCEDURE")' #PROCESS#
$ exit

$process:
$ now = f$time()
$loop:
$ read/end=end/err=end sys$pipe line
$ write sys$output line
$! parse the line to extract the time into symbol errtime
$! and get the difference between now and errtime:
$ dtime=f$delta_time(errtime,now)
$ dd=f$integer(f$element(0," ",dtime)) !day
$ dt=f$element(1," ",dtime)
$ dh=f$integer(f$element(0,":",dt)) !hour
$ dm=f$integer(f$element(1,":",dt)) !minute
$ if dd.eq.0 .and. dh.eq.0 .and. dm.le.15
$ then
$ write sys$output line
$! do whatever You want with the selected line (write to a mailbox ?)
$ endif
$ goto loop
$end:
$ exit


where the 'parse line' part only You, the OP, knows the syntax or format of the log lines.
DCL has the lexical functions f$extract,f$element,f$length,f$fao to help in parsing a string.
http://www.mpp.mpg.de/~huber
Please use plain text.
Honored Contributor
Joseph Huber_1
Posts: 1,082
Registered: ‎02-03-2004
Message 12 of 21 (528 Views)

Re: Modifying DCL script

correct in the above (line breaks) to read in one single line:

$ pipe SEARCH ssfmoni:erf.log JHF,Failed/match=and/window=1 | @'f$environ("PROCEDURE")' #PROCESS#
http://www.mpp.mpg.de/~huber
Please use plain text.
Honored Contributor
Hoff
Posts: 4,905
Registered: ‎01-29-2006
Message 13 of 21 (528 Views)

Re: Modifying DCL script

Unless this is a fossil version of VMS in use, then hacking up the date with the following constructs:

$ hour = f$cvtime(,"ABSOLUTE","HOUR")
$ minute = f$cvtime(,"ABSOLUTE","MINUTE")
$ day = f$cvtime(,"ABSOLUTE","DAY")
etc...

is easier and a whole lot more obvious...

Or better, using delta times or combination times and not trying to do time math, given that home-grown time math tends to introduce errors and particularly errors around the daylight saving time switch-overs. (If y'all don't understand what the delta time, combination time and absolute time formats can provide, please go see the DCL documentation.)

For details on the f$cvtime lexical function, please see the arguments listing and description from:

HELP LEXICAL F$CVTIME

Or see the two-volume DCL reference manual in the OpenVMS documentation set available at:

http://www.hp.com/go/openvms/doc
Please use plain text.
Honored Contributor
Joseph Huber_1
Posts: 1,082
Registered: ‎02-03-2004
Message 14 of 21 (528 Views)

Re: Modifying DCL script

...this reminds me: correctly parsing the delta time, f$CVTIME needs a "DCL" format delta time:

$ dtime=f$delta_time(errtime,now,"DCL")
$ dd= f$cvtime(dtime,"DELTA","DAY") !days
$ dh= f$cvtime(dtime,"DELTA","HOUR") !hour
$ dm= f$cvtime(dtime,"DELTA","MINUTE") !minute


$ if dd.eq.0 .and. dh.eq.0 .and. dm.le.15 ...
http://www.mpp.mpg.de/~huber
Please use plain text.
Honored Contributor
Hein van den Heuvel
Posts: 6,579
Registered: ‎05-19-2003
Message 15 of 21 (528 Views)

Re: Modifying DCL script

Joseph wrote

>> $ dtime=f$delta_time(errtime,now,"DCL")
>> $ dd= f$cvtime(dtime,"DELTA","DAY") !days
:
>> $ if dd.eq.0 .and. dh.eq.0 .and. dm.le.15 ...

Huh?

$ dtime=f$delta_time(errtime,f$time())
$ show symb dtime
DTIME = " 0 00:13:03.73"
$ if dtime .le. " 0 00:15:00.00" ...

$ ! That's 3 spaces before the 0 for the days

fwiw,
Hein


Please use plain text.
Honored Contributor
Hein van den Heuvel
Posts: 6,579
Registered: ‎05-19-2003
Message 16 of 21 (528 Views)

Re: Modifying DCL script

Bah, made a typo myself...

Hein>>> $ if dtime .le. " 0 00:15:00.00" ...

That's a STRING compare and should read

$ if dtime .LES. " 0 00:15:00.00" ...

( Of course if it was up to me I'd write the whole search and compare in perl, allthough admittedly the VMS time convert to second is a bit of a hassle. )

Hein
Please use plain text.
Honored Contributor
Joseph Huber_1
Posts: 1,082
Registered: ‎02-03-2004
Message 17 of 21 (528 Views)

Re: Modifying DCL script

yes, if one likes to count characters ...
My example extracts delta time into integers.
And "DCL" caveat:

$ dtime=f$delta_time("today","tomorrow")
$ write sys$output f$cvtime(dtime,"DELTA","DAY")
%DCL-W-IVDTIME, invalid delta time - use DDDD-HH:MM:SS.CC format
\1 00:00:00.00\

"DCL" fiormat:
$ dtime=f$delta_time("today","tomorrow","DCL")
$ write sys$output f$cvtime(dtime,"DELTA","DAY")
1
$
http://www.mpp.mpg.de/~huber
Please use plain text.
Honored Contributor
Hein van den Heuvel
Posts: 6,579
Registered: ‎05-19-2003
Message 18 of 21 (528 Views)

Re: Modifying DCL script

My reply was not about saving characters.
I thought you had 2 problems with:

$ dtime=f$delta_time(errtime,now,"DCL")

The 'now' must have been a symbol, but can not be the mighty tempting "NOW"... for that you need just a double double quote = empty string.
The "DCL" was new to me. It is not documented in the help, and with the line failing a simple cut & paste test I thought that was the problem at first.
I Learned something new.

I do think comparing the strings is much more readable than picking it apart, followed by the compound checking of those parts.

Hein
Please use plain text.
Honored Contributor
John Gillings
Posts: 2,991
Registered: ‎07-31-2003
Message 19 of 21 (528 Views)

Re: Modifying DCL script

[ Edited ]

Hein,

The 3rd parameter of F$DELTA can be "ASCTIM" or "DCL". Default is "ASCTIM".

This was a late addition, after F$DELTA had been released into the wild. It was necessary because of the inconsistencies in date formats. I think it was one of the last things Guy did before he left. Maybe the documentation never got through the system?

BTW, this is an example of a change to VMS instigated by an ITRC discussion. See http://h30499.www3.hp.com/t5/Languages-and-Scripting/F-DELTA-TIME-returns-a-non-standard-delta-time-...

A crucible of informative mistakes
Please use plain text.
Occasional Advisor
Anup Varghese
Posts: 7
Registered: ‎02-21-2011
Message 20 of 21 (528 Views)

Re: Modifying DCL script

Hi All,

Thanks a lot for all your replies, i was able to get a new logic for getting the data for the 15 min interval,

The logic used here is:

Took the copy of the log file for the current day during the first run and took the copy of the log file again during the next run that is after 15 min interval.
checked the difference between the 2 log files and got the output to another file, now searching the new file for the error will give the error message for the last 15 min interval.

i am using the assign command for getting the output for the file differences.
Please use plain text.
Occasional Advisor
Anup Varghese
Posts: 7
Registered: ‎02-21-2011
Message 21 of 21 (528 Views)

Re: Modifying DCL script

Thanks for all you help and support on this.
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation