Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

c++ cgi counter: holding env vars in memory after execution

Posted on 2003-02-24
5
Medium Priority
?
236 Views
Last Modified: 2013-12-25
hello,

I have a cgi logger with a hitcounter (for websites) written in c++ that reads an integer from a file,
updates the number with 1 and writes the new number back to the file.
This works fine, but now I would like to store information obtained from
cgi env vars, like REMOTE_ADDR, HTTP_USER_AGENT, etc together with a date stamp as well.

I have tried this with two seperate files (one for actual hitcount, one for env vars)
and that's working fine. The problem is that with a large amount of hits (50.000+ per hour)
the harddisk is constantly busy. So what I would like to do is somehow store those env
vars in an array (any other datatype will do as well of course), and have a cronjob write
the contents of the array once a minute to the harddisk and empty the array, so it can be filled with hits from the following minute again.

With this minute flushing the memory shouldn't get too filled, while the gain in speed is very high. Now my question is basically how to access one and the same array every time.
Since the counter is called in the actual html page (the counter is not a background-app, like a service in windows), the program closes everytime, deleting all the arrays, and other variables defined.

The only thing that comes to my mind is to manually specify the address of the memory for the array, but since there's no telling how big the one-minute buffer is going to be, this can easily cause memory problems.

There are three demands for this module:
1. it must be written in ansi c++ (must be able to run on linux, bsd)
2. it can not run as a background service
3. it must be fast

If there's anything unclear, please let me know.
Thank you
0
Comment
Question by:Aheib
  • 2
3 Comments
 

Author Comment

by:Aheib
ID: 8017296
points increased to 175.

Maybe I have more luck asking in the c++ section?
0
 
LVL 1

Accepted Solution

by:
MatrixDud earned 700 total points
ID: 8041833
Have you tried a memory map

here's a bit of info...you'll probably have to doa bit more digging

http://www.itworld.com/nl/lnx_tip/04272001/pf_index.html
0
 

Author Comment

by:Aheib
ID: 8048653
Nope, never looked into that.
You're throwing me a bit in the deep with that link tho :)
Perhaps someone can give some more pointers or a short example?
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question