[R] Reg : R : How to capture cpu usage, memory usage and disks info using R language
Manohar Reddy
manu.reddy52 at gmail.com
Mon Oct 17 11:58:03 CEST 2016
Thanks Jim.
Actually my requirement is I have ~ 20 servers which are running on
windows server family OS,if I want to check any server cpu usge,memory
usage or disk info I need to log into every server instead of doing like
this if I get that kind of information using R then I can save it in some
RDBMS database then I will populate this live data on some dashboard like
which are made by R using shiny,so that I can view/get the all the
information on single page.
Here for me challenging work is how to capture cpu,memory,disk info
using R .
On Sun, Oct 16, 2016 at 8:37 PM, jim holtman <jholtman at gmail.com> wrote:
> 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.
>
--
*Manu.*
[[alternative HTML version deleted]]
More information about the R-help
mailing list