Microsoft Virtualization Discussions

Cifs stat query


Ok, I know from Clinton and beam there is no API for CIFS stat.  I know we can do invoke-nassh and run cifs stat.

Ok, I know it's really cold here in the northeast, so my brain is potentially frozen or i'm overlooking something..  I'm trying to pull OpLkBkNoBreakAck from cifs stat or any one of the counters.. The issue i'm having is if I do

$stat = invoke-nassh -command "cifs stat"  

It reads it as one

$stat.count = 1

So, when I try to throow it through a loop it thinks it's all one string so I can manipulate the text.

Any help in pushing me out of the mud would be great.



Re: Cifs stat query


One more thing i forgot to mention is I tried splitting the line with "`r" - but it wasn't helping

Re: Cifs stat query


Perhaps this will get you started:

PS C:\> (Invoke-NaSsh cifs stat).Split("`n").Trim() | % {if ($_.StartsWith("OpLkBkNoBreakAck")) { Write-Output $_ }}

OpLkBkNoBreakAck        0

OpLkBkNoBreakAck95        0

OpLkBkNoBreakAckNT        0

Re: Cifs stat query



Ok, thanks fo rthe kick start

I had

$var = invoke-nassh -command cifs stat

  $var | % {                  

  $newline = $var.split("`r").trim() 

    $newline |% {    
       if ($_ -like "*OpLkBkNoBreakAck*") {       

     write-host $_        




If I change the `r to `n, I get the correct output...   Hmm.. I was on the right path, I figured `r (return) would do the trick, not new line...

But your's looks cleaner...

Thanks as usual..

Re: Cifs stat query



here is the whole piece..  Short and simple...

Obviously, I left out $cred piece.. But if you are using straight RPC you should have no issue and can drop -cred if you have access already

And dfmimport is just a dump from dfm that we do in powershell

#Import filers
$dfmimport = import-csv c:\powershell\dfmcontrollers.csv | Select controller

$dfmimport | % {
$filer = $_.controller
Write-host "`n`tConnectiong to controller " $filer
$c = connect-nacontroller $filer -cred $cred

Write-host "Oplock Stats for controller:" $_.controller -fore Red -back Black
Ac -path c:\temp\opstats.log -value "`nController: $($filer)"
(Invoke-NaSsh cifs stat).Split("`n").Trim() | % {if ($_.StartsWith("OpLkBkNoBreakAck")) { ac -path c:\temp\opstats.log -value $_ }}
Ac -path c:\temp\opstats.log -value "----------------------"

Disclaimer - This is all with the through process that cifs is running.. I didn't build in logic otherwise..

View solution in original post

Earn Rewards for Your Review!
GPI Review Banner
All Community Forums