From owner-p4-projects@FreeBSD.ORG Sat Jul 16 15:08:01 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4654D16A427; Sat, 16 Jul 2005 15:08:01 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 17D5516A423 for ; Sat, 16 Jul 2005 15:08:01 +0000 (GMT) (envelope-from soc-victor@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C50F643D46 for ; Sat, 16 Jul 2005 15:08:00 +0000 (GMT) (envelope-from soc-victor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j6GF80u0003586 for ; Sat, 16 Jul 2005 15:08:00 GMT (envelope-from soc-victor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j6GF80gS003579 for perforce@freebsd.org; Sat, 16 Jul 2005 15:08:00 GMT (envelope-from soc-victor@freebsd.org) Date: Sat, 16 Jul 2005 15:08:00 GMT Message-Id: <200507161508.j6GF80gS003579@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to soc-victor@freebsd.org using -f From: soc-victor To: Perforce Change Reviews Cc: Subject: PERFORCE change 80349 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jul 2005 15:08:01 -0000 http://perforce.freebsd.org/chv.cgi?CH=80349 Change 80349 by soc-victor@soc-victor_82.76.158.176 on 2005/07/16 15:07:54 Added some VM entries for hrStorageTable. Should be changed to be based on libmemestat - ASAP. Affected files ... .. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c#5 edit .. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h#7 edit .. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c#4 edit Differences ... ==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c#5 (text+ko) ==== @@ -149,7 +149,7 @@ case LEAF_hrSystemDate: { u_char s_date_time[11]; int s_date_time_len = -1; - if((s_date_time_len = OS_getSystemDate(s_date_time)) < 0){ + if((s_date_time_len = OS_getSystemDate(s_date_time)) < 0) { return (SNMP_ERR_GENERR); } return (string_get(value, s_date_time, s_date_time_len)); @@ -350,8 +350,8 @@ /*first time, do the sysctl*/ - struct timeval kernel_boot_timestamp={0,0}; - int mib[2]={CTL_KERN,KERN_BOOTTIME}; + struct timeval kernel_boot_timestamp={ 0, 0 }; + int mib[2]={ CTL_KERN, KERN_BOOTTIME }; size_t len = sizeof(kernel_boot_timestamp); if(sysctl(mib, 2, &kernel_boot_timestamp, &len, NULL, 0) == -1) { @@ -498,14 +498,14 @@ int OS_getSystemMaxProcesses(void) { if( hrState_g.max_proc == 0 ) { - int mib[2] = {CTL_KERN, KERN_MAXPROC}; + int mib[2] = { CTL_KERN, KERN_MAXPROC }; size_t len = 0; len = sizeof(hrState_g.max_proc); if(sysctl(mib, 2, &hrState_g.max_proc, &len, NULL, 0) == -1) { syslog(LOG_ERR, "sysctl KERN_MAXPROC failed: %m "); return (-1); /*error*/ } - HR_DPRINTF((stderr, "Got kernel maxporc: %d\n",hrState_g.max_proc)); + HR_DPRINTF((stderr, "Got kernel maxporc: %d\n", hrState_g.max_proc)); } return (hrState_g.max_proc); ==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h#7 (text+ko) ==== @@ -44,6 +44,7 @@ #include /*for getfsstat*/ #include /*for getfsstat*/ +#include /*a debug macro*/ #ifndef NDEBUG @@ -115,10 +116,11 @@ struct storage_tbl hr_storage_tbl; /*the head of the list with table's entries */ uint64_t hr_tick; - struct kvm_swap *swap_devs; /*for kvm_getswapinfo*/ + struct kvm_swap *swap_devs; /*for kvm_getswapinfo, malloc'd*/ size_t swap_devs_len; /*idem */ - struct statfs *fs_buf; /*for getfsstat*/ + struct statfs *fs_buf; /*for getfsstat, malloc'd*/ size_t fs_buf_count; /*idem*/ + struct vmtotal mem_stats; uint32_t next_hrStorage_index; /*next int availabe for indexing the hrStorageTable*/ time_t hrStorage_tbl_age; ==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c#4 (text+ko) ==== @@ -40,14 +40,10 @@ #include #include #include /*for getpagesize()*/ +#include -static -void hrStorage_get_vm_v(void){ - /*FIX ME*/ - HR_DPRINTF((stderr, "WARNING: hrStorageTable vm not implmeneted yet.\n ")); -} static @@ -138,7 +134,67 @@ return (NULL); } +/* + * Very silly implementation for VM info. + * Should be changed to use libmemestat API + * (Robert N M Watson has just created, not yet + * available for public for the time being) + * FIX ME + */ + static +void hrStorage_get_vm_v(void) { + /*FIX ME*/ + int mib[2] = { CTL_VM, VM_TOTAL }; + int len = sizeof(hrState_g.mem_stats); + int page_size_bytes; + struct hrStorageTblEntry *entry = NULL; + if( sysctl(mib, 2, &hrState_g.mem_stats, &len, NULL, 0) < 0 ) { + syslog(LOG_ERR, "%s: sysctl( { CTL_VM, VM_METER } ) failed: %m ", __func__ ); + assert(0); + return; + } + + page_size_bytes = getpagesize(); + + + + /*Real Memory Metrics*/ + entry = hrStorageTblEntry_find_by_name("Real Memory Metrics"); + if( entry == NULL ) { + entry = hrStorageTblEntry_create("Real Memory Metrics"); + } + assert(entry != NULL); + if( entry == NULL) return; /*I'm out of luck now, maybe next time*/ + + entry->flags |= HR_STORAGE_FOUND; + entry->type = (struct asn_oid)OIDX_hrStorageRam; + entry->allocationUnits = page_size_bytes; + entry->size = hrState_g.mem_stats.t_rm; + entry->used = hrState_g.mem_stats.t_arm; /*ACTIVE is not USED - FIX ME */ + entry->allocationFailures = 0; + + + + /*Shared Real Memory Metrics*/ + entry = hrStorageTblEntry_find_by_name("Shared Real Memory Metrics"); + if( entry == NULL ) { + entry = hrStorageTblEntry_create("Shared Real Memory Metrics"); + } + assert(entry != NULL); + if( entry == NULL) return; /*I'm out of luck now, maybe next time*/ + + entry->flags |= HR_STORAGE_FOUND; + entry->type = (struct asn_oid)OIDX_hrStorageRam; + entry->allocationUnits = page_size_bytes; + entry->size = hrState_g.mem_stats.t_rmshr; + entry->used = hrState_g.mem_stats.t_armshr; /*ACTIVE is not USED - FIX ME */ + entry->allocationFailures = 0; + +} + + +static void hrStorage_get_swap_v(void) { int nswapdev = 0; int len = sizeof(nswapdev); @@ -350,7 +406,8 @@ hrState_g.fs_buf = NULL; hrState_g.fs_buf_count = 0; - + memset( &hrState_g.mem_stats, 0, sizeof(hrState_g.mem_stats) ); + hrState_g.next_hrStorage_index = 1; STAILQ_INIT(&hrState_g.storage_name_map); @@ -449,7 +506,7 @@ /* refresh entries here?! */ - if ( (time(NULL) - hrState_g.hrStorage_tbl_age) > 7 ) { + if ( (time(NULL) - hrState_g.hrStorage_tbl_age) > HR_STORAGE_TBL_REFRESH ) { HR_DPRINTF((stderr, "%s: need refresh\n ",__func__)); refresh_hrStorage_tbl_v(); }