How many times a file was requested from a server? - apache

Is it somehow possible to see how many times a specific file was requested from the server, or set up a system to see it in the future?
In my case, it is a Javascript file on my server that is included on many different websites.
My setup is using LAMP.

You can see requests in an access log of Apache server.
Simply scan for occurrences of requests to that file by hands or write some script.

So that JSON file is requested by HTTP requests going to your Apache server.
That server probably manages log files. (the location of that log file is configurable).
You then need to scan the access log file to find every access. You can use something like
grep yourfile.json /var/log/www/access.log | wc
(to count occurrences)
where /var/log/www/access.log is your access log file.
BTW, many log files are managed by logrotate. Details are system specific. Take than into account too.

Related

detect unused files/folders in a server via apache log

I inherited a server on which a large number of applications and files are installed.
Many of these are no longer in use, but I have no documentation of what is in production and what is not.
I should try to clean up and remove unused files and applications.
Since I have Apache logs, can I process them with an analyzer or some script to identify the files (or rather the folders) that are no longer in use (which have not had hits since January 2020 for example)?
Any help is appreciated.
In the end I solved it by simply using the grep command.
I used the Apache logs from January to now, and for each folder on the server I launched a command like:
cat access_log_20200* |grep "GET /folder"
So I deleted the ones that are not present in the log file.

List of served files in apache

I am doing some reverse engineering on a website.
We are using LAMP stack under CENTOS 5, without any commercial/open source framework (symfony, laravel, etc). Just plain PHP with an in-house framework.
I wonder if there is any way to know which files in the server have been used to produce a request.
For example, let's say I am requesting http://myserver.com/index.php.
Let's assume that 'index.php' calls other PHP scripts (e.g. to connect to the database and retrieve some info), it also includes a couple of other html files, etc
How can I get the list of those accessed files?
I already tried to enable the server-status directive in apache, and although it is working I can't get what I want (I also passed the 'refresh' parameter)
I also used lsof -c httpd, as suggested in other forums, but it is producing a very big output and I can't find what I'm looking for.
I also read the apache logs, but I am only getting the requests that the server handled.
Some other users suggested to add the PHP directives like 'self', but that means I need to know which files I need to modify to include that directive beforehand (which I don't) and which is precisely what I am trying to find out.
Is that actually possible to trace the internal activity of the server and get those file names and locations?
Regards.
Not that I tried this, but it looks like mod_log_config is the answer to my own question

Dropbox API requests performance issues

The issue we dealing with is when moving or copying files in Dropbox server to another folder in Dropbox server.
The API requires to send request for each file separately. That takes way too long.
Maybe You provide some kind of batch request so I could move more than one files per request?
I also know the ability to move all folder content, but it doesn't work on our case, cause we need only subset of files to move.
If we try to flush many request at once threw several connections, we get 'Server Unavailable' or 'File Locked' errors and need to repeat request again.
Tl;DR;
To move 1000 files that already are in Dropbox server it takes over 30 minutes.
What possible solutions You have to increase the performance?
The Dropbox API now provides a batch endpoint for moving files. You can find the documentation here:
https://www.dropbox.com/developers/documentation/http/documentation#files-move_batch

Create a random apache access log

To test some programs which process apache access logs, I need access logs of variable length and content. Is there a program or website which creates such log files? (I can't use my own access log files, since they are to small)
there is some here
you can search for other on google
http://www.monitorware.com/en/logsamples/apache.php

How do I get a status report of all files currently being uploaded via a HTTP form on an Apache Server?

How do I get a status report of all files currently being uploaded via HTTP form based file upload on an Apache Server?
I don't believe you can do this with Apache itself. The upload looks like nothing more than a POST as far as Apache cares. There are modules and other servers that do special processing to uploads so you may have some luck there. It would probably be easier to keep track of it in your application.
Check out SWFUpload, its uses Flash (in a nice way) to assist with managing multiple uploads.
There are events you can monitor for how many files of a set have been uploaded.