Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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:

sess_IDsession

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

 
discard

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.