From nobody Tue Jan 25 05:32:19 2022 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AEE9F1970434 for ; Tue, 25 Jan 2022 05:32:29 +0000 (UTC) (envelope-from yuri@aetern.org) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jjb8X5Ln3z3nnD for ; Tue, 25 Jan 2022 05:32:28 +0000 (UTC) (envelope-from yuri@aetern.org) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id EB3053200927 for ; Tue, 25 Jan 2022 00:32:21 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 25 Jan 2022 00:32:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aetern.org; h=cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; bh=G6Cl0hkGxTcUQp KldwH3/Omoy7/GxxtHr6b3LXN/uB4=; b=fPogeZWvNKrTapoK87g63wWZEfHf0f TrzH1a2EV+mTTcDswC8a0xM5PyWADmu6JHjmDdOarQhKwnhZb9/TlS0GaZMBQjYW zY3tThjtNuDhzqQAfXtu0J6QbiCbSMqsGaYLLBVah8dEw+7j/HRTdAmBic1mIvDq v8xBxm+tL5E9ha0y1MFCsxRAcZfD/Ur3BXakiD4i8cN8qpEj4J0XlId8B5WMU9pc fCXWDboA4GGGfIN3CP4pIjbnU7B8wDqCdZd716oKemfvSwcj9Bajvz1Wd284rb3S cphSNQblhn0IvoH9I1foRDHZYCpUC+1Ucj/KV4ioXoWlZhQVhzpoLD7A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=G6Cl0hkGxTcUQpKldwH3/Omoy7/GxxtHr6b3LXN/uB4=; b=n2g5ktRz iSX1aI5oB2b095FnL67uflx8cgi72YLzk+/PJp5TQBZqGiwCjihW5pRk3LBqeoCx iW74+cfk84RjrEtF9QzgxzCmw3COUHA47uLnYriwa80nd6rMZRKFrnVfd87apA0C /B4Hjxe/drZjHN2uXt/9SwwJv+JC+ZpzqI17LUwf4RwcFnnGOXSzKevIIjmwHAnc +1FjOJMEPHei5MB3PAcid3lcprOjpNv5GTPogyXdHeZSv7qXfPqJBlSVQ/ZuaLz9 CrsZocCffat8NeUfD0TOn1/uM87s63nC5M7YZs/X+zgYET/AeI06HV6roFF8Yqk+ JgA7J3mVEFTGTQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrvdekgdekgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffhvfhfjggtgfesthekre dttdefjeenucfhrhhomhepjghurhhiuceohihurhhisegrvghtvghrnhdrohhrgheqnecu ggftrfgrthhtvghrnhepteduhfeggfdvhefhieevvdefieelhfekteefffetteevueefge eltefhudethfefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomhephihurhhisegrvghtvghrnhdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 25 Jan 2022 00:32:20 -0500 (EST) Message-ID: Date: Tue, 25 Jan 2022 08:32:19 +0300 List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: snmp oid for memory usage, vmstat -i and others Content-Language: en-US From: Yuri To: freebsd-questions@freebsd.org References: <0c8e1634-d4e2-2ecb-0af4-9f4eceab9124@aetern.org> In-Reply-To: <0c8e1634-d4e2-2ecb-0af4-9f4eceab9124@aetern.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4Jjb8X5Ln3z3nnD X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=aetern.org header.s=fm2 header.b=fPogeZWv; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=n2g5ktRz; dmarc=none; spf=pass (mx1.freebsd.org: domain of yuri@aetern.org designates 64.147.123.21 as permitted sender) smtp.mailfrom=yuri@aetern.org X-Spamd-Result: default: False [-4.60 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[64.147.123.21:from]; R_SPF_ALLOW(-0.20)[+ip4:64.147.123.21:c]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[aetern.org:+,messagingengine.com:+]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:29838, ipnet:64.147.123.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[64.147.123.21:from]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[aetern.org:s=fm2,messagingengine.com:s=fm1]; FREEFALL_USER(0.00)[yuri]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; DMARC_NA(0.00)[aetern.org]; RCPT_COUNT_ONE(0.00)[1]; DWL_DNSWL_LOW(-1.00)[messagingengine.com:dkim]; MLMMJ_DEST(0.00)[freebsd-questions] X-ThisMailContainsUnwantedMimeParts: N Yuri wrote: > Victor Gamov wrote: >> Hi All >> >> Some questions about bsnmpd. >> >> Is it possible to get memory usage via bsnmpd?  When I tried to get >> something like "snmpget hrStorageDescr.1 hrStorageAllocationUnits.1 >> hrStorageSize.1 hrStorageUsed.1" then I've got this values: >> >> ===== >> HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Real Memory Metrics >> HOST-RESOURCES-MIB::hrStorageAllocationUnits.1 = INTEGER: 4096 Bytes >> HOST-RESOURCES-MIB::hrStorageSize.1 = INTEGER: 391488 >> HOST-RESOURCES-MIB::hrStorageUsed.1 = INTEGER: 391252 >> ===== >> >> How I must process it to calculate actual memory usage for machine with >> 4GB RAM and without swap? >> >> ===== >> $ sysctl hw | egrep 'hw.(phys|user|real)' >> hw.physmem: 4243894272 >> hw.usermem: 3580182528 >> hw.realmem: 4294967296 >> ===== > > Values returned by bsnmpd look weird to me as well, so I looked into it > a bit. Excerpt from the snmp_hostres (as a standalone test case): > ---- > #include > #include > #include > > #include > > #include > #include > > static struct vmtotal mem_stats; > > int > main(void) > { > int mib[2] = { CTL_VM, VM_TOTAL }; > size_t len = sizeof(mem_stats); > > if (sysctl(mib, 2, &mem_stats, &len, NULL, 0) != 0) > err(1, "sysctl"); > > printf("real=%lu\n", mem_stats.t_rm); > > return (0); > } > ---- > output: > real=31632 > ---- > > Now the sysctl output: > ---- > $ sysctl vm.vmtotal > vm.vmtotal: > System wide totals computed every five seconds: (values in kilobytes) > =============================================== > Processes: (RUNQ: 1 Disk Wait: 0 Page Wait: 0 Sleep: 28) > Virtual Memory: (Total: 547240K Active: 542480K) > Real Memory: (Total: 126572K Active: 125600K) > Shared Virtual Memory: (Total: 4612K Active: 0K) > Shared Real Memory: (Total: 924K Active: 0K) > Free Memory: 3608396K > --- > I can't map the output to anything on the system (16G RAM, 16G swap) > except for the "Free Memory", it matches. > > 31632 ("real") * 4096 ("pagesize") matches the "Real Memory" in sysctl > output. Though to get anything resembling 16G, "real" needs to be > multiplied by 512 (K?). > > As a wild guess, it seems that the units used are wrong here, or I > simply don't understand the meaning of these values. Looking at sys/vmmeter.h, my assumptions above are wrong: uint64_t t_rm; /* total real memory in use */ But that does not include the "wired" (and other) pages, so I'm not sure about this metric usefulness. In any case, you have the following: HOST-RESOURCES-MIB::hrMemorySize.0 = INTEGER: 16734232 KBytes