How to tell if someone is remote accessing my NAS

Status
Not open for further replies.
Joined
Apr 10, 2016
Messages
3
Hi there, I have a FreeNAS box that is used for plex on the go for me, my father, and my brother.

Currently, me and my father are in 1 location, and my brother is in another location on the other side of the country due to university.
As my dad does not want the NAS on all the time (only when he's updating the plex library or when streaming), I enabled remote access through the Asrock motherboard to let my brother turn it on when he wants to use it.
However, as my dad doesn't know he's using it, he often turns it off without checking. So my question is how I could make a notification to see when it's being actively used, and when it's on, but idling.

Any ideas are much appreciated.

EDIT 1: My first idea is to create a script that checks CPU usage to see if it is below 10%* for a certain amount of time, and if it meets the arguments, it turns itself off.

* I need to check exactly how much cpu usage varies when streaming at different qualities
 
Last edited:

Pitfrr

Wizard
Joined
Feb 10, 2014
Messages
1,531
I find the CPU usage check idea interesting but I'm not sure if it is accurate: on my system I don't think I can tell from the CPU usage if someone is connected! Eventually from the network usage...
You could also ping the client that might be more accurate? And if you have a ping response, you don't allow the shutdown.

Then.... I'd say that it you have multiple users (and not on the same site) why would you shut down the server at all? It makes little sense. And if it is about power savings then search through the forum and you'll find enough arguments in favor for not shutting you server down. So that might be the simplest solution...
 

nikkon

Contributor
Joined
Dec 16, 2012
Messages
171
You can control this easy. who | less is the command to see this on the OS level. If you wanna check this on the jail level :

jexec <jid> w

Or

jls | awk '\!/JID/ { print $1 }' | xargs -I % jexec % who
 

Pitfrr

Wizard
Joined
Feb 10, 2014
Messages
1,531
@nikkon: I am not very confident with Linux/FreeBSD command line but in my understanding with who you get the users connected through a terminal on the OS (not those connected to a SMB share for example)? Am I correct? (And I'm not at home to try it out.... ;-P hence my question, thanks.)
 

nikkon

Contributor
Joined
Dec 16, 2012
Messages
171
@nikkon: I am not very confident with Linux/FreeBSD command line but in my understanding with who you get the users connected through a terminal on the OS (not those connected to a SMB share for example)? Am I correct? (And I'm not at home to try it out.... ;-P hence my question, thanks.)
hmm..
 
Joined
Feb 2, 2016
Messages
574
1. Seems foolish to turn it off.

2. From the Plex web interface, you can see if anyone is streaming content.

3. The most accurate method I can think of for seeing if the device is being accessed is to check ESTABLISHED connections...

netstat -n 2>/dev/null | grep ESTABLISHED | wc -l

That'll tell you how many connections are currently active. If the number of active connections is greater than zero, something on the device is being used.

If you have loopback connections - which you might have if you're using jails or VMs - zero might not be the right number of connections to recognize as unused. So, look at the count when the machine is not doing anything and use that as your baseline.

Cheers,
Matt
 

pirateghost

Unintelligible Geek
Joined
Feb 29, 2012
Messages
4,219
Turning the NAS on and off is harder on the system. It doesn't make sense to do this for a number of reasons.

FreeNAS expects to perform SMART tests, and scrubs, and you're disabling these safety features.
 
Status
Not open for further replies.
Top