mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 23:25:56 -05:00
Start adding some stats stuff
This commit is contained in:
parent
e4df3def97
commit
a551776cf0
@ -508,6 +508,8 @@ void config_emit_int(WS_CONNINFO *pwsc, void *value, char *arg) {
|
|||||||
void config_emit_service_status(WS_CONNINFO *pwsc, void *value, char *arg) {
|
void config_emit_service_status(WS_CONNINFO *pwsc, void *value, char *arg) {
|
||||||
int mdns_running;
|
int mdns_running;
|
||||||
char *html;
|
char *html;
|
||||||
|
char buf[256];
|
||||||
|
int r_days, r_hours, r_mins, r_secs;
|
||||||
|
|
||||||
ws_writefd(pwsc,"<TABLE><TR><TH ALIGN=LEFT>Service</TH>");
|
ws_writefd(pwsc,"<TABLE><TR><TH ALIGN=LEFT>Service</TH>");
|
||||||
ws_writefd(pwsc,"<TH ALIGN=LEFT>Status</TH><TH ALIGN=LEFT>Control</TH></TR>\n");
|
ws_writefd(pwsc,"<TH ALIGN=LEFT>Status</TH><TH ALIGN=LEFT>Control</TH></TR>\n");
|
||||||
@ -536,6 +538,59 @@ void config_emit_service_status(WS_CONNINFO *pwsc, void *value, char *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ws_writefd(pwsc,"</TABLE>\n");
|
ws_writefd(pwsc,"</TABLE>\n");
|
||||||
|
|
||||||
|
ws_writefd(pwsc,"<TABLE>\n");
|
||||||
|
ws_writefd(pwsc,"<TR>\n");
|
||||||
|
ws_writefd(pwsc," <TH>Uptime</TH>\n");
|
||||||
|
|
||||||
|
r_secs=time(NULL)-config.stats.start_time;
|
||||||
|
|
||||||
|
r_days=r_secs/(3600 * 24);
|
||||||
|
r_secs -= ((3600 * 24) * r_days);
|
||||||
|
|
||||||
|
r_hours=r_secs/3600;
|
||||||
|
r_secs -= (3600 * r_hours);
|
||||||
|
|
||||||
|
r_mins=r_secs/60;
|
||||||
|
r_secs -= 60 * r_mins;
|
||||||
|
|
||||||
|
memset(buf,0x0,sizeof(buf));
|
||||||
|
if(r_days)
|
||||||
|
sprintf((char*)&buf[strlen(buf)],"%d day%s, ", r_days,
|
||||||
|
r_days == 1 ? "" : "s");
|
||||||
|
|
||||||
|
if(r_days || r_hours)
|
||||||
|
sprintf((char*)&buf[strlen(buf)],"%d hour%s, ", r_hours,
|
||||||
|
r_hours == 1 ? "" : "s");
|
||||||
|
|
||||||
|
if(r_days || r_hours || r_mins)
|
||||||
|
sprintf((char*)&buf[strlen(buf)],"%d minute%s, ", r_mins,
|
||||||
|
r_mins == 1 ? "" : "s");
|
||||||
|
|
||||||
|
sprintf((char*)&buf[strlen(buf)],"%d second%s ", r_secs,
|
||||||
|
r_secs == 1 ? "" : "s");
|
||||||
|
|
||||||
|
ws_writefd(pwsc," <TD>%s</TD>\n",buf);
|
||||||
|
ws_writefd(pwsc,"</TR>\n");
|
||||||
|
|
||||||
|
ws_writefd(pwsc,"<TR>\n");
|
||||||
|
ws_writefd(pwsc," <TH>Songs</TH>\n");
|
||||||
|
ws_writefd(pwsc," <TD>%d</TD>\n",db_get_song_count());
|
||||||
|
ws_writefd(pwsc,"</TR>\n");
|
||||||
|
|
||||||
|
ws_writefd(pwsc,"<TR>\n");
|
||||||
|
ws_writefd(pwsc," <TH>Songs Served</TH>\n");
|
||||||
|
ws_writefd(pwsc," <TD>%d</TD>\n",config.stats.songs_served);
|
||||||
|
ws_writefd(pwsc,"</TR>\n");
|
||||||
|
|
||||||
|
/*
|
||||||
|
ws_writefd(pwsc,"<TR>\n");
|
||||||
|
ws_writefd(pwsc," <TH>Bytes Served</TH>\n");
|
||||||
|
ws_writefd(pwsc," <TD>%d</TD>\n",config.stats.songs_served);
|
||||||
|
ws_writefd(pwsc,"</TR>\n");
|
||||||
|
*/
|
||||||
|
|
||||||
|
ws_writefd(pwsc,"</TABLE>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
13
src/daapd.h
13
src/daapd.h
@ -22,12 +22,13 @@
|
|||||||
#ifndef _DAAPD_H_
|
#ifndef _DAAPD_H_
|
||||||
#define _DAAPD_H_
|
#define _DAAPD_H_
|
||||||
|
|
||||||
typedef struct tag_songentry {
|
typedef struct tag_stats {
|
||||||
int index;
|
time_t start_time;
|
||||||
char *file;
|
int songs_served;
|
||||||
|
|
||||||
struct tag_songentry *next;
|
unsigned int gb_served;
|
||||||
} SONGENTRY;
|
unsigned int bytes_served;
|
||||||
|
} STATS;
|
||||||
|
|
||||||
typedef struct tag_config {
|
typedef struct tag_config {
|
||||||
int use_mdns;
|
int use_mdns;
|
||||||
@ -43,7 +44,7 @@ typedef struct tag_config {
|
|||||||
char *runas;
|
char *runas;
|
||||||
char *dbdir;
|
char *dbdir;
|
||||||
char *extensions;
|
char *extensions;
|
||||||
SONGENTRY songlist;
|
STATS stats;
|
||||||
} CONFIG;
|
} CONFIG;
|
||||||
|
|
||||||
extern CONFIG config;
|
extern CONFIG config;
|
||||||
|
@ -275,6 +275,8 @@ void daap_handler(WS_CONNINFO *pwsc) {
|
|||||||
config_set_status(pwsc,session_id,"Streaming file '%s'",pmp3->fname);
|
config_set_status(pwsc,session_id,"Streaming file '%s'",pmp3->fname);
|
||||||
DPRINTF(ERR_INFO,"Streaming %s\n",pmp3->fname);
|
DPRINTF(ERR_INFO,"Streaming %s\n",pmp3->fname);
|
||||||
|
|
||||||
|
config.stats.songs_served++; /* FIXME: remove stat races */
|
||||||
|
|
||||||
if(offset) {
|
if(offset) {
|
||||||
DPRINTF(ERR_INFO,"Seeking to offset %d\n",offset);
|
DPRINTF(ERR_INFO,"Seeking to offset %d\n",offset);
|
||||||
lseek(file_fd,offset,SEEK_SET);
|
lseek(file_fd,offset,SEEK_SET);
|
||||||
@ -462,7 +464,7 @@ int main(int argc, char *argv[]) {
|
|||||||
/* read the configfile, if specified, otherwise
|
/* read the configfile, if specified, otherwise
|
||||||
* try defaults */
|
* try defaults */
|
||||||
|
|
||||||
start_time=time(NULL);
|
config.stats.start_time=start_time=time(NULL);
|
||||||
|
|
||||||
if(config_read(configfile)) {
|
if(config_read(configfile)) {
|
||||||
perror("config_read");
|
perror("config_read");
|
||||||
|
Loading…
Reference in New Issue
Block a user