From nobody Tue Jan 25 04:55:36 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 1D81B19767A3 for ; Tue, 25 Jan 2022 04:55:41 +0000 (UTC) (envelope-from yuri@aetern.org) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (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 4JjZL41fHrz3GFS for ; Tue, 25 Jan 2022 04:55:40 +0000 (UTC) (envelope-from yuri@aetern.org) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 9F42B3200946 for ; Mon, 24 Jan 2022 23:55:38 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 24 Jan 2022 23:55:38 -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=mvhkb4zyw9z7cD GNy7qx7NUFT67Xj4nFoUp5jnxneLI=; b=hLrzG7uWf/GIDsXPCtApWPX3xDlaUM gkYNGsxbZ7r9pp5h3r9awiEu3Rs9q/G+ToiOQN5D/jd+hWJWz6x78p3djBg46JvQ p0rRp6/N2KDUQ98uSiGWwccAqV7vSnMwdJmv8COJ575I/fqIVzPpKdmSEmAjqNu/ FUWFSiqBbVJD6p5Nnft8BJ27lG1fnt0o2BH4MykKi2HPWCeqRfYK09RyGLvFvHBa ogXtzQEqi6scErZl6BD0NcoR2EY2h5ke07q9/O6k57NsMl7U2eWPk7yDMBmR0hl0 SpcYWJBw/k/6XpvoXxxYo62fbBlzi2rw8h0kmuHkcOvQjuqMdcmAEt6g== 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=mvhkb4zyw9z7cDGNy7qx7NUFT67Xj4nFoUp5jnxneLI=; b=UoH4qtJ5 0MYDygCZu2b1WXgFtr5BbfH/YPr9bVbIAuTz6K7rllXVQXWfWLIACL5wE/73H762 CvbP50xAS24xuIsYMDjjAZZHm7nNMiyKzPFluAXH/gQ/gIrBM1uXWWtz4lysW3WK fuq4N+H55nn+svdP8n6jmtJY1ZDCf7PvFFPPml0oxJp8o6WKKJytpi8U0WRRozcj RznlZ06yt2JWWJ8gIZDWPWsL6r28Esvf1W/MR1GjPZxORFfX2AGpE0vvqLF1jvjj jSx536olzyTHpeaftS/fdp4TUdFxfyxH0ppKqh2i1evs1CCMH9WpVP+YbKcuhtxo V/MbxhxV/IRE3A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrvdekgdejiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekre dttdefjeenucfhrhhomhepjghurhhiuceohihurhhisegrvghtvghrnhdrohhrgheqnecu ggftrfgrthhtvghrnhephedtkeehfeelueehgfeuteegveeukedtuddtgeffhfeuueetle egieetveejueevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomhephihurhhisegrvghtvghrnhdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 24 Jan 2022 23:55:37 -0500 (EST) Message-ID: <0c8e1634-d4e2-2ecb-0af4-9f4eceab9124@aetern.org> Date: Tue, 25 Jan 2022 07:55:36 +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 To: freebsd-questions@freebsd.org References: From: Yuri In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4JjZL41fHrz3GFS X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=aetern.org header.s=fm2 header.b=hLrzG7uW; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=UoH4qtJ5; dmarc=none; spf=pass (mx1.freebsd.org: domain of yuri@aetern.org designates 64.147.123.20 as permitted sender) smtp.mailfrom=yuri@aetern.org X-Spamd-Result: default: False [-4.60 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; 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)[]; R_SPF_ALLOW(-0.20)[+ip4:64.147.123.20]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; TO_DN_NONE(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCPT_COUNT_ONE(0.00)[1]; DWL_DNSWL_LOW(-1.00)[messagingengine.com:dkim]; RCVD_COUNT_THREE(0.00)[4]; DMARC_NA(0.00)[aetern.org]; DKIM_TRACE(0.00)[aetern.org:+,messagingengine.com:+]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; MLMMJ_DEST(0.00)[freebsd-questions]; 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.20:from] X-ThisMailContainsUnwantedMimeParts: N 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.