Manohar Reddy
2016-Oct-14 09:37 UTC
[R] Reg : R : How to capture cpu usage, memory usage and disks info using R language
Hi, ? Is there any possibility that we can capture cpu usage ,memory usage and disks info using R language on *windows family OS* ? I would like to see data that?s looks like ?a? below Cpu usage : 70 % Memory usage : 80 % Disks : C drive ? 40 % full,D dive ? 60 %,full E drive ? 30 % full ? for more info please find the attachement.? Thanks in Advance ,Manu.? -------------- next part -------------- A non-text attachment was scrubbed... Name: system_monitor_info.PNG Type: image/png Size: 37629 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20161014/29dc8be2/attachment.png>
jim holtman
2016-Oct-16 15:07 UTC
[R] Reg : R : How to capture cpu usage, memory usage and disks info using R language
Here is a start on the solution. This will create a VBS script that will gather the CPU data and return it in a character vector that you can extract the data from. You can add to it to get the other data you are looking for. ########################> temp <- tempfile(fileext = '.vbs') # get a temp file > > # create the VBS file to collect processor data > writeLines('Set objWMIService = GetObject("winmgmts:\\\\localhost\\root\\CIMV2")+ Set CPUInfo = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor",,48) + For Each Item in CPUInfo + Wscript.Echo "PercentProcessorTime: " & Item.PercentProcessorTime & _ + " processor:" & Item.Name + Next', + temp)> > results <- shell(paste("cscript", temp), intern = TRUE) # execute using 'cscript' > results # all the data[1] "Microsoft (R) Windows Script Host Version 5.8" [2] "Copyright (C) Microsoft Corporation. All rights reserved." [3] "" [4] "PercentProcessorTime: 18 processor:0" [5] "PercentProcessorTime: 6 processor:1" [6] "PercentProcessorTime: 6 processor:2" [7] "PercentProcessorTime: 0 processor:3" [8] "PercentProcessorTime: 7 processor:_Total"> grep("processor:", results, value = TRUE) # get just processor data[1] "PercentProcessorTime: 18 processor:0" "PercentProcessorTime: 6 processor:1" [3] "PercentProcessorTime: 6 processor:2" "PercentProcessorTime: 0 processor:3" [5] "PercentProcessorTime: 7 processor:_Total"> >##################################### Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Fri, Oct 14, 2016 at 5:37 AM, Manohar Reddy <manu.reddy52 at gmail.com> wrote:> Hi, > > Is there any possibility that we can capture cpu usage ,memory usage and > disks info using R language on *windows family OS* ? > > > > I would like to see data that?s looks like > a > below > > > > Cpu usage : 70 % > > Memory usage : 80 % > > Disks : C drive ? 40 % full,D dive ? 60 %,full E drive ? 30 % full > > > for more info please find the attachement. > > > Thanks in Advance ,Manu. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.