GithubHelp home page GithubHelp logo

Comments (12)

itpp16 avatar itpp16 commented on August 21, 2024

strange, restarted nginx and the negative value is gone, normal time now.

from nginx-module-vts.

vozlt avatar vozlt commented on August 21, 2024

To get the uptime is using the simple method which is current_time(json:nowMsec) - process_start_time(json:loadMsec) in built-in html.
If it is happening again, you need to check it(json:loadMsec and json:nowMsec in format/json).
Let me check it on the 'streams' later because of so busy now.

from nginx-module-vts.

centminmod avatar centminmod commented on August 21, 2024

thank you @vozlt this module is awesome and just what I was looking for. I've integrated it into my Centmin Mod LEMP stack installer's latest beta https://community.centminmod.com/threads/centmin-mod-nginx-live-vhost-traffic-statistics-preview-discussion.3022/ - works wonderfully with Nginx 1.9.1 :)

from nginx-module-vts.

itpp16 avatar itpp16 commented on August 21, 2024

It tool awhile to get back to this issue but this is a common json output when it goes wrong:
"loadMsec":4108553345,"nowMsec":20948346,
As you see loadMsec should remain static but at some point it is going negative and also starts to drift, might be a few days before I get back to the code to see why, might be a nginx internal value going bust.
index

from nginx-module-vts.

itpp16 avatar itpp16 commented on August 21, 2024

It is vtscf->start_msec going mad, no idea why. For the time being I'm pushing this static value onto the stack after 60sec and just use this value throughout runtime.

from nginx-module-vts.

vozlt avatar vozlt commented on August 21, 2024

I will check it soon.
Probably, It seem to be overflow of 32bit variables.
Is it a 32bit system?

The time variables(start_msec, now) in module is millisecond as follows:

(seconds since 1970-01-01 00:00:00 UTC) * 1000

So, In case of normal in json as follows:
{
.
.
"loadMsec":1443142379895,
"nowMsec":1443142397017`
.
.
.
The calculation of uptime second using json in html as follows:

uptime = (nowMsec - loadMsec) / 1000

from nginx-module-vts.

itpp16 avatar itpp16 commented on August 21, 2024

it is a 32bit system but in this variable case I don't think its an overflow because it happens anywhere after 3 days to 2 weeks (sometimes it never happens) and after it, it starts to drift (counting down negative). Either nginx is messing up this variable or the pointer gets invalid. ea. loadMsec(vtscf->start_msec) should be set once and stay static so it can't be an overflow issue.

from nginx-module-vts.

vozlt avatar vozlt commented on August 21, 2024

As you commented above: "loadMsec":4108553345,"nowMsec":20948346,
I think that the loadMsec in json was wrong because of smaller than 1420038000000(2015/01/01 12:00 to milliseconds)
Please check variable maxIntegerSize in json.

from nginx-module-vts.

itpp16 avatar itpp16 commented on August 21, 2024

It's not a maxsize issue, let me show you an example:
nginx starts:
"loadMsec":20948346,"nowMsec":20949346,
nginx is running for a while:
"loadMsec":20948346,"nowMsec":23212222,
nginx is still running for a while:
"loadMsec":20948346,"nowMsec":25333333,

So far as it should work, loadMsec is STATIC and NEVER changes.

At some point in time (3 days <-> 2 weeks) loadMsec (which is vtscf->start_msec) returns a negative value and you get:
"loadMsec":4108553345,"nowMsec":253444444,

The question is WHY is loadMsec (which is vtscf->start_msec) becoming negative while this is a static value which should not change?
I think it is a nginx value going bust, see also:
http://hg.nginx.org/nginx/rev/8c6e71722aff
Which is not related to this value but it might be a nginx value which isn't defined large enough, but that still does not explain why a static value changes (or its pointer gets lost).

from nginx-module-vts.

vozlt avatar vozlt commented on August 21, 2024

Just to be sure, Is nginx's worker process restart(not to master process)?
I was wondering whether each worker process's uptime is same or not at that point.

from nginx-module-vts.

itpp16 avatar itpp16 commented on August 21, 2024

It should be a master value as uptime can't be tied to a worker which can be restarted, crashed, reloaded, etc... Most of the time (99%) vtscf->start_msec is fine and stays static.
nb. a master can reload as well (binary replace function) but the master passes some values to the new master when this happens.

from nginx-module-vts.

vozlt avatar vozlt commented on August 21, 2024

OK, I understand but it still may be problem of nginx-module-vts.
If you are able to modify and test, then try as below:

--- ngx_http_vhost_traffic_status_module.c.org  2015-10-15 10:32:18.023029431 +0900
+++ ngx_http_vhost_traffic_status_module.c      2015-10-15 10:43:02.524150308 +0900
@@ -1849,7 +1849,7 @@ ngx_http_vhost_traffic_status_create_loc
         return NULL;
     }

-    conf->start_msec = (ngx_msec_t) (tp->sec * 1000 + tp->msec);
+    conf->start_msec = (ngx_msec_t) (tp->sec);
     conf->enable = NGX_CONF_UNSET;
     conf->shm_zone = NGX_CONF_UNSET_PTR;
     conf->format = NGX_CONF_UNSET;

And check whether json's loadMsec is changed or not.
If it was changed, then please let me know its values.(for checking actual time)

FYI. I merged commit aca8fab by issue #23 just now.

from nginx-module-vts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.