(SIGAR-188) implement mem actual free/used on FreeBSD
This commit is contained in:
		
							parent
							
								
									a96bd1bc04
								
							
						
					
					
						commit
						089ba0d93c
					
				@ -391,8 +391,8 @@ static int sigar_vmstat(sigar_t *sigar, struct vmmeter *vmstat)
 | 
				
			|||||||
    GET_VM_STATS(vm, v_wire_count, 0);
 | 
					    GET_VM_STATS(vm, v_wire_count, 0);
 | 
				
			||||||
    GET_VM_STATS(vm, v_active_count, 0);
 | 
					    GET_VM_STATS(vm, v_active_count, 0);
 | 
				
			||||||
    GET_VM_STATS(vm, v_inactive_target, 0);
 | 
					    GET_VM_STATS(vm, v_inactive_target, 0);
 | 
				
			||||||
    GET_VM_STATS(vm, v_inactive_count, 0);
 | 
					    GET_VM_STATS(vm, v_inactive_count, 1);
 | 
				
			||||||
    GET_VM_STATS(vm, v_cache_count, 0);
 | 
					    GET_VM_STATS(vm, v_cache_count, 1);
 | 
				
			||||||
    GET_VM_STATS(vm, v_cache_min, 0);
 | 
					    GET_VM_STATS(vm, v_cache_min, 0);
 | 
				
			||||||
    GET_VM_STATS(vm, v_cache_max, 0);
 | 
					    GET_VM_STATS(vm, v_cache_max, 0);
 | 
				
			||||||
    GET_VM_STATS(vm, v_pageout_free_min, 0);
 | 
					    GET_VM_STATS(vm, v_pageout_free_min, 0);
 | 
				
			||||||
@ -425,6 +425,7 @@ static int sigar_vmstat(sigar_t *sigar, struct uvmexp *vmstat)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
 | 
					int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    sigar_uint64_t kern = 0;
 | 
				
			||||||
#ifdef DARWIN
 | 
					#ifdef DARWIN
 | 
				
			||||||
    vm_statistics_data_t vmstat;
 | 
					    vm_statistics_data_t vmstat;
 | 
				
			||||||
    uint64_t mem_total;
 | 
					    uint64_t mem_total;
 | 
				
			||||||
@ -469,6 +470,8 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
 | 
				
			|||||||
    mem->free *= sigar->pagesize;
 | 
					    mem->free *= sigar->pagesize;
 | 
				
			||||||
#elif defined(__FreeBSD__)
 | 
					#elif defined(__FreeBSD__)
 | 
				
			||||||
    if ((status = sigar_vmstat(sigar, &vmstat)) == SIGAR_OK) {
 | 
					    if ((status = sigar_vmstat(sigar, &vmstat)) == SIGAR_OK) {
 | 
				
			||||||
 | 
					        kern = vmstat.v_cache_count + vmstat.v_inactive_count;
 | 
				
			||||||
 | 
					        kern *= sigar->pagesize;
 | 
				
			||||||
        mem->free = vmstat.v_free_count;
 | 
					        mem->free = vmstat.v_free_count;
 | 
				
			||||||
        mem->free *= sigar->pagesize;
 | 
					        mem->free *= sigar->pagesize;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -481,8 +484,8 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    mem->used = mem->total - mem->free;
 | 
					    mem->used = mem->total - mem->free;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mem->actual_free = mem->free;
 | 
					    mem->actual_free = mem->free + kern;
 | 
				
			||||||
    mem->actual_used = mem->used;
 | 
					    mem->actual_used = mem->used - kern;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sigar_mem_calc_ram(sigar, mem);
 | 
					    sigar_mem_calc_ram(sigar, mem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user