mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
add meminfo
This commit is contained in:
parent
15aea4d9b3
commit
a5f4f6bd14
5 changed files with 208 additions and 12 deletions
|
@ -48,6 +48,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#define SERVER_LISTEN_BACKLOG 512
|
||||
|
||||
// system interval
|
||||
// all resolution times should be times togother,
|
||||
// for example, system-time is 3(300ms),
|
||||
// then rusage can be 3*x, for instance, 3*10=30(3s),
|
||||
// the meminfo canbe 30*x, for instance, 30*2=60(6s)
|
||||
#define SRS_SYS_CYCLE_INTERVAL 100
|
||||
|
||||
// update time interval:
|
||||
|
@ -62,6 +66,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_CPU_STAT_RESOLUTION_TIMES
|
||||
#define SRS_SYS_CPU_STAT_RESOLUTION_TIMES 30
|
||||
|
||||
// update rusage interval:
|
||||
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_MEMINFO_RESOLUTION_TIMES
|
||||
#define SRS_SYS_MEMINFO_RESOLUTION_TIMES 60
|
||||
|
||||
SrsListener::SrsListener(SrsServer* server, SrsListenerType type)
|
||||
{
|
||||
fd = -1;
|
||||
|
@ -411,6 +419,7 @@ int SrsServer::cycle()
|
|||
int max = srs_max(0, SRS_SYS_TIME_RESOLUTION_MS_TIMES);
|
||||
max = srs_max(max, SRS_SYS_RUSAGE_RESOLUTION_TIMES);
|
||||
max = srs_max(max, SRS_SYS_CPU_STAT_RESOLUTION_TIMES);
|
||||
max = srs_max(max, SRS_SYS_MEMINFO_RESOLUTION_TIMES);
|
||||
|
||||
// the deamon thread, update the time cache
|
||||
while (true) {
|
||||
|
@ -440,15 +449,18 @@ int SrsServer::cycle()
|
|||
}
|
||||
|
||||
// update the cache time or rusage.
|
||||
if (i == SRS_SYS_TIME_RESOLUTION_MS_TIMES) {
|
||||
if ((i % SRS_SYS_TIME_RESOLUTION_MS_TIMES) == 0) {
|
||||
srs_update_system_time_ms();
|
||||
}
|
||||
if (i == SRS_SYS_RUSAGE_RESOLUTION_TIMES) {
|
||||
if ((i % SRS_SYS_RUSAGE_RESOLUTION_TIMES) == 0) {
|
||||
srs_update_system_rusage();
|
||||
}
|
||||
if (i == SRS_SYS_CPU_STAT_RESOLUTION_TIMES) {
|
||||
if ((i % SRS_SYS_CPU_STAT_RESOLUTION_TIMES) == 0) {
|
||||
srs_update_proc_stat();
|
||||
}
|
||||
if ((i % SRS_SYS_MEMINFO_RESOLUTION_TIMES) == 0) {
|
||||
srs_update_meminfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue