unsigned int64 bit data polling

Started by duanebutler, November 24, 2015, 08:36:18 AM

Previous topic - Next topic

duanebutler

Good day

I am busy setting up File.Time.Access / Change / Modify parameters. 

I don not understand the Int64 bit type.  Is the data in milliseconds? When i convert it, the data set is wrong in days or hours.

My server's date is correct tho as i thought it could be NTP or system date.

Thanx

duanebutler

I found that it polls UNIX time.

How can i convert this once polled?


Victor Kirhenshtein

Hi,

depending on what you want to achieve. If you are interested in file's age, you can get it in seconds using transformation script like this:


return time() - $1;


For more complicated transformations you can use gmtime or localtime functions. Both returns break down time as TIME object. There is also function strftime that can be used to format time but it is not documented yet.

Best regards,
Victor

duanebutler

Thanx Victor

Much Appreciate it.

By files age do you mean the date stamp on file when last modified?

I will try the script and see how it goes.

Thanx alot!!

Victor Kirhenshtein

Hi,

by file age I meant how old it is - difference between current time and time of file creation/modification.

Best regards,
Victor

duanebutler

Hi Victor

I am fairly new to NetXMS scripting.  I actually got this far as to use the gmtime function gmtime()->mday to get the day only.

How can i use the gmtime function to extract the DD-MM-YYYY and maybe HH-SS if possible? Like 12-01-2016 14:30

Regards

Victor Kirhenshtein

If you need to format date like this you can use strftime function:

return strftime("%d-%m-%Y %H:%M", $1);

This will convert UNIX time stamp from $1 into string of format DD-MM-YYYY HH:MM.

Alternatively, you can use string concatenation, like this:

t = gmtime($1);
return t->mday . "-" . t->mon . "-" . t->year;

Best regards,
Victor

duanebutler

Hi Victor

Thanx so much for your help.  It put me in the right direction.

My script i compiled was:
t = ($1);
day = gmtime(t)->mday;
mon = gmtime(t)->mon+1;
year = gmtime(t)->year;
hour = gmtime(t)->hour;
min = gmtime(t)->min;
return day."-".mon."-".year."/".hour.":".min;

This gave me an output in the following date format:
14-1-2016/14:29
DD-M-YYY/HH:MM

I also struggled a bit but remembered to capture string data and not int.

I find this helpful for monitoring last modified date and time (which is highly important in my company for some files).

Just wanted to say thanx to Victor.  Really appreciate your help.

Regards
Duane