Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more statistics and /status.json page #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

freddy36
Copy link
Contributor

No description provided.

@lars18th
Copy link
Contributor

Great @freddy36 !

This will be useful.

Perhaps you want also to complete the code about the UDP listening COMMAND from here: lars18th@e38fb3b
For the LCN part I'll provide a new updated PR. But this code includes the listing thread from the UDP socket. However, it doesn't take any action when receive the message. Open to implement anything to execute actions on-the-fly. What you think?

@lars18th
Copy link
Contributor

Hi @freddy36 ,

Perhaps you want to add one compile option to enable/disable the JSON code. I feel it will be useful to compile this tool without the JSON dependency in some small environments. You agree?

@freddy36
Copy link
Contributor Author

What kind of commands do you intend to send via UDP? For functions like modifying inputs, etc. we probably would prefer a REST API over a UDP command API.

In general I try to avoid having compile time options. If someone really is running mptsd in a heavily storage/memory constraint environment, it's easy to add. But unless requested by @gfto we're not planning to add it.

@lars18th
Copy link
Contributor

Hi @freddy36 ,

Regarding the remote control, perhaps you're right and it's preferable a REST API.

Regarding json library linking, the idea is to reduce library dependencies as much as possible. But if @gfto agrees with that, then I'm not opposed to it.

@gfto
Copy link
Owner

gfto commented Mar 14, 2024

At minimum the libjson-c dep should be optional and enabled via make -DWITH_JSON=1 (or something similar).

Far better (since the library is only used to generate output) is to avoid the dependency. The generated output json does not look that complex.

@lars18th
Copy link
Contributor

lars18th commented Mar 14, 2024

Hi @freddy36 ,

I have this suggestion:

I feel that this part of the code from tomcast could be reused.
What you think?

@freddy36 freddy36 force-pushed the stats branch 2 times, most recently from 127b83f to bd50d80 Compare March 14, 2024 16:53
@freddy36
Copy link
Contributor Author

updated the PR
JSON support can be disabled via make WITH_JSON=0 (default is enabled)
Also moved it to /status.json to keep /status free for future use.

@freddy36 freddy36 changed the title add more statistics and /status page add more statistics and /status.json page Mar 15, 2024
@freddy36
Copy link
Contributor Author

@gfto is this ok for you now or would you like to see any other changes?

@freddy36
Copy link
Contributor Author

@gfto do you have any otehr change request/other feedback regading this pull request?

@TagorePde
Copy link

TagorePde commented Jul 26, 2024

Hi @freddy36 i cannot compile this, this is the error:

  LINK  libfuncs.a
  MAKE  libtsfuncs/libtsfuncs.a
  LINK  libtsfuncs.a
  CC    mptsd           iniparser.c
  CC    mptsd           inidict.c
  CC    mptsd           pidref.c
  CC    mptsd           data.c
  CC    mptsd           config.c
  CC    mptsd           sleep.c
  CC    mptsd           network.c
  CC    mptsd           input.c
  CC    mptsd           output_psi.c
  CC    mptsd           output_mix.c
  CC    mptsd           output_write.c
  CC    mptsd           web_pages.c
web_pages.c: In function ‘cmd_status_json’:
web_pages.c:314:9: warning: implicit declaration of function ‘send_header_applicationjson’ [-Wimplicit-function-declaration]
  314 |         send_header_applicationjson(clientsock);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
web_pages.c:334:9: warning: implicit declaration of function ‘send_header_content_length’ [-Wimplicit-function-declaration]
  334 |         send_header_content_length(clientsock, length);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
web_pages.c:336:29: warning: passing argument 2 of ‘fdwrite’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  336 |         fdwrite(clientsock, jbuf, length);
      |                             ^~~~
In file included from web_pages.c:29:
libfuncs/io.h:29:31: note: expected ‘char *’ but argument is of type ‘const char *’
   29 | ssize_t fdwrite(int fd, char *buf, size_t buf_size);
      |                         ~~~~~~^~~
  CC    mptsd           web_server.c
  CC    mptsd           mptsd.c
  LINK  mptsd
/usr/bin/ld: web_pages.o: en la función `cmd_status_json':
/home/usuario/sources/mptsd_stats/mptsd/web_pages.c:314: referencia a `send_header_applicationjson' sin definir
/usr/bin/ld: /home/usuario/sources/mptsd_stats/mptsd/web_pages.c:334: referencia a `send_header_content_length' sin definir
collect2: error: ld returned 1 exit status
make: *** [Makefile:68: mptsd] Error ```


Any sugestion? 
Regards,

@freddy36
Copy link
Contributor Author

Hi @freddy36 i cannot compile this, this is the error:

  LINK  libfuncs.a
  MAKE  libtsfuncs/libtsfuncs.a
  LINK  libtsfuncs.a
  CC    mptsd           iniparser.c
  CC    mptsd           inidict.c
  CC    mptsd           pidref.c
  CC    mptsd           data.c
  CC    mptsd           config.c
  CC    mptsd           sleep.c
  CC    mptsd           network.c
  CC    mptsd           input.c
  CC    mptsd           output_psi.c
  CC    mptsd           output_mix.c
  CC    mptsd           output_write.c
  CC    mptsd           web_pages.c
web_pages.c: In function ‘cmd_status_json’:
web_pages.c:314:9: warning: implicit declaration of function ‘send_header_applicationjson’ [-Wimplicit-function-declaration]
  314 |         send_header_applicationjson(clientsock);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
web_pages.c:334:9: warning: implicit declaration of function ‘send_header_content_length’ [-Wimplicit-function-declaration]
  334 |         send_header_content_length(clientsock, length);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
web_pages.c:336:29: warning: passing argument 2 of ‘fdwrite’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  336 |         fdwrite(clientsock, jbuf, length);
      |                             ^~~~
In file included from web_pages.c:29:
libfuncs/io.h:29:31: note: expected ‘char *’ but argument is of type ‘const char *’
   29 | ssize_t fdwrite(int fd, char *buf, size_t buf_size);
      |                         ~~~~~~^~~
  CC    mptsd           web_server.c
  CC    mptsd           mptsd.c
  LINK  mptsd
/usr/bin/ld: web_pages.o: en la función `cmd_status_json':
/home/usuario/sources/mptsd_stats/mptsd/web_pages.c:314: referencia a `send_header_applicationjson' sin definir
/usr/bin/ld: /home/usuario/sources/mptsd_stats/mptsd/web_pages.c:334: referencia a `send_header_content_length' sin definir
collect2: error: ld returned 1 exit status
make: *** [Makefile:68: mptsd] Error ```


Any sugestion? 
Regards,


Go to the libfuncs directory and git pull the latest version:
https://github.com/gfto/libfuncs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants