DATE fields in mysql database.

Started by prutser, January 25, 2008, 04:36:42 PM

Previous topic - Next topic

prutser

Hello again,

I need to make a php page that shows the uptime of various services monitored by NETXMS.
I found most of the data I need, but have a problem with 'DATES' that are stored in the database. Could you please tell me how I can extract the date and time from date and time fields (eg: alarms.creation_time, alarms.change_time, idata_xx.idata_timestamp etc)?
Also, the idata_xx tables. What is the number the xx refers to?

Thank you very much in advance!
Peter.

Victor Kirhenshtein

Hello!

All times in NetXMS database stored as UNIX timestamp - number of seconds passes since January 1, 1970 UTC. You can use MySQL function FROM_UNIXTIME() to convert them to other formats.
For idata_xx tables, xx is a node object ID - so each node have it's own idata table.

Best regards,
Victor

Alex Kirhenshtein

Hello.

Date is stored as unix timestamp (number of seconds since 1/1/1970), in php you can convert it to human readable form using date() function.

idata_xx tables contains per-node history data for each DCI (e.g. cpu usage values for retention period), where "xx" is "id" from table "nodes".


p.s. please keep in mind that server keeps operational data in memory and flushing changes in a background, so information in database can be sometimes out of sync or outdated (only while server is running - everything is flushed on shutdown, of course) - especially under heavy load.
p.p.s. you can make some assumptions about out of sync delay by looking at Server.AverageDBWriterQueueSizeAverage DCI.

prutser

#3
Thank you very much for the info.

I still have a question though. Does netxms also keep a history of "NETWORK SERVICES" data? I can find the DCI data in the IDATA_xx tables, but not the network services data?

If this is not the case, this means I need to get the status of ports via a DCI (Eg Peoplesoft JOLT listener on port 9000). I could us the ServiceCheck.Custom(x).
What do I give as a parameter x?

EG: I need to check port 9000 of node 12. How can I define a DCI for this?
ServiceCheck.Custom(localhost, 9000) -> returns status 2
ServiceCheck.Custom(9000) -> returns status 2

Thanxx in advance!

Victor Kirhenshtein

Hello!

Correct syntax is ServiceCheck(ip_addr,port). Note that you need to specify IP address, it will not resolve hostname. So ServiceCheck(127.0.0.1,9000) should work. Btw, I will add hostname resolution in the next release.

Also, you can create DCI for status of "network service" object, and then access it's collected data as for any other DCI. To do this, create new DCI with origin "Internal", select ChildStatus() parameter, and as the argument anter name or id of network service object.

Best regards,
Victor

prutser

Thank you very much for your information!

I don't seem to get the localhost part working, but am still trying. Apparently, I always get status 2 back instead of status 0. In case I don't use the (127.0.0.1,9000) but by a remote host, it works... It think it has not to do with the Peoplesoft JOLT listener because also ServiceCheck.Custom(127.0.0.1,21) on FTP-host returns dci-value 2.

Victor Kirhenshtein

Just tested on my machine - 127.0.0.1 works fine, so it seems like a bug or misconfiguration. Could you please send me agent's configuration from the host where you define DCI with ServiceCheck.Custom(127.0.0.1,xx) and output of netstat -an from this host?

Best regards,
Victor

prutser

Thank you very much for your help (especially the netstat typ). I'm sure now it has nothing to do with Netxms. Apparently the host is only listening on his own IP-adress, and not on address 127.0.0.1. This explains why only remote connections are accepted.
As this problem is on all tested hosts (Win XP and 2003 Adv Server), I think the problem is bound to Microsoft OS's...

If I have the solution, I'll post it here... Thanxx again for your help!!

Ps: the more I'm busy playing around with netxms, the more I love it!

Anth0ny

Request author's comment:

how i can create a standalone Service object?
for example for monitoring SSH daemon availability at host 10.0.0.1 without creating Server object and DCI "ServiceCheck.SSH".

path: Console root -> All Services -> Create -> Service...

Need more information about rights of filling for all "Create Network Service" fields.

Please.



Victor Kirhenshtein

You can create network service only under node object - because network service is just a process on a host, listening on TCP port. So, if you wish to monitor SSH on host 10.0.0.1, you create node object fro 10.0.0.1 and create SSH service object under it.

I don't actually understand question about rights - you can use the same rights assignment as for any other object.

Best regards,
Victor