Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What are the options for monitoring PHP session size from Nagios? I want to identify sessions that go over a certain threshold because they have too much data stored in them.

One option I can think of is listing the size of the files in /var/lib/php/session and counting the number of files that are over a certain threshold.

Disclaimer: I don't even use PHP - is the size of files in this folder a suitable and accurate-enough indicator of session size? Is there another way?

share|improve this question

It depends - that's one way if you are using a file-based session handler and that's the path use, then this will give you a fair idea of the size of the serialized session data - but it's impact on the memory usage per instance of PHP will be much higher (and not necessarily predictable).

But how you go about it really depends on what you are trying to achieve. A better solution might be to write your own session handler and include the logging there - perhaps using some additional logic, like only reporting back to nagios when it exceeds threshold, or logging the size to an interim aggregator.

share|improve this answer

Every one file (it's a text file) is one PHP session. Path to the sessions is as you wrote (on my computer is /var/lib/php5/*). Every session has following name:


I think that size of the sessions files are suitable indicator of session size, because in one file are stored all data of application for one PHP session. So the best way is to write a script that will list the session files by size and alert you when some of them reach certain treshold.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.