0

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?

Rich
  • 1,333
  • 5
  • 27
  • 39

2 Answers2

0

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.

symcbean
  • 19,931
  • 1
  • 29
  • 49
0

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.

panaroik
  • 832
  • 5
  • 12