Data ONTAP Discussions

How to find stale cifs sessions in Netapp

There is a requirement in my organization. I have to find the stale CIFS sessions and list them across the globe. Is there any command or process to find them?

14 REPLIES 14

Re: How to find stale cifs sessions in Netapp

From storage end, you can run below command to list all the cifs sessions:

::> cifs session show

You can use question mark followed by this command which will list out many filters which can be used. 

Use "-instance" followed by complete command to get more details about cifs sessions.

https://docs.netapp.com/ontap-9/index.jsp?topic=%2Fcom.netapp.doc.dot-cm-cmpr-930%2Fvserver__cifs__session__show.html 

 

From windows client, you can use below command to list out cifs sessions:

>net use

 

Stale cifs sessions can be found out by listing cifs sessions on storage end and comparing them with sessions running on client. If sessions are available on client but not listing out in storage then those sessions are stale and will not be accessible.

 

Let me know if this answers your query.

Re: How to find stale cifs sessions in Netapp

Hi @ManpreetS 

 

I know how to check CIFS sessions on NetApp, but here is the actual requirement, we are trying to write a script to find the stale sessions in all the NetApp Arrays. If you know how to proceed further. Please guide me through the process.

Re: How to find stale cifs sessions in Netapp

You can do it with a couple lines of PowerShell (RegEx with the assist) which could easily be put into a script that loops through a list of all of your controllers. 

 

Let's assume that you want to find sessions with an IdleTime value of greater than one day: 

 

Connect-NcController <controller hostname or IP> 
Get-NcCifsSession | ? {$_.IdleTime -Match '([1-9]+)d[\w\s]*'} | Select-Object WindowsUser,Address,IdleTime

It'll return output that looks like this:

 

WindowsUser           Address        IdleTime
-----------           -------        --------
Domain\user1         10.0.0.42       28d 1h 50m 47s
Domain\user2         10.0.0.218      26d 20h 34m 51s
Domain\user3         10.0.0.219      1d 9h 15m 6s

Here's an explanation of what the RegEx pattern does, for reference:

 

regex.png

 

Donny

Re: How to find stale cifs sessions in Netapp

Hi @donny_lang 

 

When I tried to run the script provided by you, I got the below error. 

cifs_script_issue.JPG

 

 

Re: How to find stale cifs sessions in Netapp

Looks like you weren't able to successfully connect to your controller. Can you run "system services web show" from the ONTAP CLI and paste the output here? 

Re: How to find stale cifs sessions in Netapp

Hi @donny_lang 

 

Please find the output here. Looks like HTTP and HTTPS are turned on.

 

smaolab.JPG

Highlighted

Re: How to find stale cifs sessions in Netapp

Do you possibly have a firewall policy blocking the traffic? I'm assuming that you're connecting to your cluster management LIF in your screenshot - can you run "system services firewall policy show" and "net int show -role cluster-mgmt -fields firewall-policy" to make sure that your connection is allowed? 

 

Can you try manually specifying an HTTPS connection by adding the "-HTTPS" parameter in your "Connect-NcController" command?

What version of ONTAP are you running? 

Re: How to find stale cifs sessions in Netapp

Hi @donny_lang 

 

I will test this script in LAB and see if it works as there will be no restrictions in LAB.

 

Thanks, Donny. I will get back to you soon.

Re: How to find stale cifs sessions in Netapp

You can also get it via CLI.

 

vserver cifs session show -node xxx -fields idle-time

 

You can then grep it for what you are looking for.  Not as elegant as PS, but it gives you output.

 

Forums