Microsoft Virtualization Discussions

Cifs stat query

JGPSHNTAP

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.

Thanks

1 ACCEPTED SOLUTION

JGPSHNTAP

Clinton,

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

4 REPLIES 4

JGPSHNTAP

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

cknight

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

JGPSHNTAP

Clinton...

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..

JGPSHNTAP

Clinton,

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

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public