From: Felix Morgner Date: Wed, 11 Feb 2015 09:49:47 +0000 (+0100) Subject: moved mon-umurmurd into seperate project X-Git-Url: http://git.code-monkey.de/?p=umurmur.git;a=commitdiff_plain;h=3e2d621584bf6ec81b83bdbc0f6dd574bfa6228c moved mon-umurmurd into seperate project --- diff --git a/shm_utils/mon-umurmurd/CHANGES b/shm_utils/mon-umurmurd/CHANGES deleted file mode 100644 index 9b4f768..0000000 --- a/shm_utils/mon-umurmurd/CHANGES +++ /dev/null @@ -1,19 +0,0 @@ -* BUG_FIX: Fix the screen not clearing when last person exits the server - - -* Code clean up - - -* Added more client data 99% of the useful client data shown -* rework Sharedmemory_update() to not use memcpy (requested by fatbob) - - -* Using a more modern unix sharedmemory API. this requires linking with librt.so (requested by fatbob) -* Added away to know if umurmurd is not connected/updateing the shm_t struct. I use 8bit timer with - rollover protection see check_serverTick() and where I use the function near bottum of mon-umurmurd.c - for how to use this. - - -* code clean up and some comments added -* ~95% of the useful client data shown -* outputs a more meaningful idle and online time, both are reported in secs (error reported by fatbob) diff --git a/shm_utils/mon-umurmurd/Makefile b/shm_utils/mon-umurmurd/Makefile deleted file mode 100644 index 6a4187f..0000000 --- a/shm_utils/mon-umurmurd/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -############################################################################# -# -# Makefile for mon-umurmurd - - -# The recommended compiler flags for the Raspberry Pi -#CCFLAGS=-Wall -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -g -lrt -CCFLAGS=-lrt -CCFLAGS+=-I../../src/ - -# define all programs -PROGRAMS = mon-umurmurd -SOURCES = ${PROGRAMS:=.c} - -all: ${PROGRAMS} - -${PROGRAMS}: ${SOURCES} - gcc ${CCFLAGS} $@.c -o $@ - -clean: - rm -rf $(PROGRAMS) - -install: all - cp mon-umurmurd /usr/local/bin/ - -.PHONY: install diff --git a/shm_utils/mon-umurmurd/README.md b/shm_utils/mon-umurmurd/README.md deleted file mode 100644 index 72473de..0000000 --- a/shm_utils/mon-umurmurd/README.md +++ /dev/null @@ -1,7 +0,0 @@ -mon-umurmurd -============ - -outputs server/client data to term useing the sharedmemory API added to umurmur for testing - -make -./mon-umurmurd diff --git a/shm_utils/mon-umurmurd/mon-umurmurd.c b/shm_utils/mon-umurmurd/mon-umurmurd.c deleted file mode 100644 index 7c02759..0000000 --- a/shm_utils/mon-umurmurd/mon-umurmurd.c +++ /dev/null @@ -1,168 +0,0 @@ -#include /* For O_* constants */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sharedmemory_struct.h" - -enum{ NOP_SHM, WAIT_ATTACH_SHM, TRY_ATTACH_SHM, MAT_SHM, CLEAN_UP_SHM, RUN_SHM }; - -int shm_fd; -shm_t *shmptr = NULL; -char shm_file_name[128]; - -int wait = 0, opt; -uint8_t last, shm_statem = TRY_ATTACH_SHM; - -void run_shm(void); - -int main(int argc, char **argv) -{ - struct stat buf; - int bindport = 0; - - while ( (opt = getopt(argc, argv, "wb:")) != -1 ) - { - switch(opt) - { - case 'w': - wait = 1; - break; - case 'b': - bindport = atoi(optarg); - break; - default: - fprintf(stderr, "Usage: %s [-w] [-b ]\n", argv[0]); - fprintf(stderr, "\t-w - Wait for umurmurd to create shm area. useful if you need to start from init.d script\n" ); - fprintf(stderr, "\t-b - Change this to the port used when starting umurmurd. Defaults to \"/umurmurd:64738\" \n"); - exit(EXIT_FAILURE); - } - } - - shmptr = NULL; - - if( !bindport ) - { - bindport = 64738; - } - - sprintf( shm_file_name, "/umurmurd:%i", bindport ); - - if( wait ) - shm_statem = WAIT_ATTACH_SHM; - - while( shm_statem ) - { - switch( shm_statem ) - { - case RUN_SHM: - run_shm(); - break; - case WAIT_ATTACH_SHM: - printf( "Waiting for umurmurd to be run\n\r"); fflush(stdout); - while( ( shm_fd = shm_open( shm_file_name, O_RDONLY, 0666 ) ) == -1 ) - sleep( 1 ); - shm_statem = MAT_SHM; - break; - case TRY_ATTACH_SHM: - if( ( shm_fd = shm_open( shm_file_name, O_RDONLY, 0666 ) ) == -1 ) - { - printf( "umurmurd doesn't seem to be running\n\r" ); - exit(EXIT_FAILURE); - } - shm_statem = MAT_SHM; - break; - case MAT_SHM: - fstat( shm_fd, &buf); - if( ( shmptr = mmap(0, buf.st_size, PROT_READ, MAP_SHARED, shm_fd, 0) ) == MAP_FAILED ) - { - exit(EXIT_FAILURE); - } - printf( "umumurd PID: %u\n\r", shmptr->umurmurd_pid ); - shm_statem = RUN_SHM; - break; - case CLEAN_UP_SHM: - - break; - - } - } - fflush(stdout); - return 0; -} - -uint8_t check_serverTick(void) -{ - last = shmptr->alive; - sleep( 1 ); // Sleep for 1 sec - return(shmptr->alive - last); -} - -void run_shm(void) -{ - -int cc; - - printf( "\033[2J\033[H" ); fflush(stdout); //clear screen VT100 - printf( "%s Clients(CONECTED/MAX) %i/%i\n\n", shm_file_name, shmptr->clientcount, shmptr->server_max_clients ); - - for( cc = 0 ; cc < shmptr->server_max_clients ; cc++ ) - { - - if( !shmptr->client[cc].authenticated ) - continue; - - printf( "%s@%s:%i in channel: %s\n\ - \tclient_OS: %s %s\n\ - \tclient_info: %s\n\ - \tavailableBandwidth: %i\n\ - \tOnline(secs): %lu Idle(secs): %lu\n\ - \tusingUDP=%i\n\ - \tdeaf=%i, mute=%i\n\ - \tself_deaf=%i, self_mute=%i\n\ - \trecording=%i\n\ - \tbOpus=%i\n\ - \tisAdmin=%i\n\ - \tisSuppressed=%i\n\ - \tUDP_Avg/Var: %3.2f/%3.2f\n\ - \tTCP_Avg/Var: %3.2f/%3.2f\n\ - \tUDP_C/TCP_C: %lu/%lu\n", - shmptr->client[cc].username, - shmptr->client[cc].ipaddress, - shmptr->client[cc].udp_port, - shmptr->client[cc].channel, - shmptr->client[cc].os, - shmptr->client[cc].os_version, - shmptr->client[cc].release, - shmptr->client[cc].availableBandwidth, - shmptr->client[cc].online_secs, - shmptr->client[cc].idle_secs, - - shmptr->client[cc].bUDP, - shmptr->client[cc].deaf, - shmptr->client[cc].mute, - shmptr->client[cc].self_deaf, - shmptr->client[cc].self_mute, - shmptr->client[cc].recording, - shmptr->client[cc].bOpus, - - shmptr->client[cc].isAdmin, - shmptr->client[cc].isSuppressed, - - shmptr->client[cc].UDPPingAvg, - shmptr->client[cc].UDPPingVar, - shmptr->client[cc].TCPPingAvg, - shmptr->client[cc].TCPPingVar, - shmptr->client[cc].UDPPackets, - shmptr->client[cc].TCPPackets ); fflush(stdout); // fflush need because of sleep() call - } - if( !check_serverTick() ) - { - exit(EXIT_FAILURE); //You dont have to exit you could just report the fact that the data is not valid - } -}