NetXMS Support Forum

English Support => General Support => Topic started by: duanebutler on November 24, 2015, 08:36:18 AM

Title: unsigned int64 bit data polling
Post by: duanebutler on November 24, 2015, 08:36:18 AM
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
Title: Re: unsigned int64 bit data polling
Post by: duanebutler on November 24, 2015, 11:00:38 AM
I found that it polls UNIX time.

How can i convert this once polled?

Title: Re: unsigned int64 bit data polling
Post by: Victor Kirhenshtein on November 24, 2015, 08:46:22 PM
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 (https://wiki.netxms.org/wiki/NXSL:gmtime) or localtime (https://wiki.netxms.org/wiki/NXSL:localtime) functions. Both returns break down time as TIME (https://wiki.netxms.org/wiki/NXSL:TIME) object. There is also function strftime that can be used to format time but it is not documented yet.

Best regards,
Victor
Title: Re: unsigned int64 bit data polling
Post by: duanebutler on December 16, 2015, 06:04:00 PM
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!!
Title: Re: unsigned int64 bit data polling
Post by: Victor Kirhenshtein on December 16, 2015, 10:31:49 PM
Hi,

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

Best regards,
Victor
Title: Re: unsigned int64 bit data polling
Post by: duanebutler on January 13, 2016, 11:54:46 AM
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
Title: Re: unsigned int64 bit data polling
Post by: Victor Kirhenshtein on January 14, 2016, 10:12:43 AM
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
Title: Re: unsigned int64 bit data polling
Post by: duanebutler on January 14, 2016, 04:48:57 PM
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