Changed filename to use microseconds in file name to exclude overlap in
high-connect count events
This commit is contained in:
parent
abec347ec2
commit
f0eb88af14
@ -9,6 +9,7 @@
|
|||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
@ -180,16 +181,18 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Collect the time of the connection, process it into
|
// Collect the time of the connection, process it into
|
||||||
// a short string
|
// a short string
|
||||||
time_t timeraw = time(NULL);
|
struct timeval tvtime;
|
||||||
struct tm* timeptr = localtime(&timeraw);
|
gettimeofday(&tvtime, NULL);
|
||||||
char timebuff[15];
|
struct tm* timeptr = localtime(&tvtime.tv_sec);
|
||||||
strftime(&timebuff[0], 15, "%Y%m%d%H%M%S", timeptr);
|
char timebuff[20];
|
||||||
|
strftime(&timebuff[0], 20, "%Y%m%d%H%M%S", timeptr);
|
||||||
|
|
||||||
// Take the short date/time connection string and add the client address
|
// Take the short date/time connection string and add the client address
|
||||||
// to create a filename
|
// to create a filename
|
||||||
char fnbuff[35];
|
char fnbuff[50];
|
||||||
snprintf(&fnbuff[0], 34, "%s-%s.dat",
|
snprintf(&fnbuff[0], 50, "%s.%ld-%s.dat",
|
||||||
timebuff, inet_ntoa(client.sin_addr)
|
timebuff, tvtime.tv_usec,
|
||||||
|
inet_ntoa(client.sin_addr)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Open a file to dump our data to
|
// Open a file to dump our data to
|
||||||
|
Loading…
Reference in New Issue
Block a user