# Shutdown synology Diskstation from on it running flow

**URL:** <https://discourse.nodered.org/t/shutdown-synology-diskstation-from-on-it-running-flow/25226>\
**Category:** General\
**Created:** [21 April 2020 08:25 UTC](https://discourse.nodered.org/t/shutdown-synology-diskstation-from-on-it-running-flow/25226 "2020-04-21T08:25:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephsache](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@stephsache](https://discourse.nodered.org/u/stephsache)\
**Post date:** [21 April 2020 08:25 UTC](https://discourse.nodered.org/t/shutdown-synology-diskstation-from-on-it-running-flow/25226/1 "2020-04-21T08:25:04Z")

</div>

Hi folks,  
I think, the topic says it all, but to explain a bit more:

I have running node-red on a Synology Diskstation without Docker.  
I want to have a flow that triggers the NAS to shutdown.  
Best option but not essential: check before if a user is still logged in.

Any idea, or even better, out-of-the-box solution?

All the best,  
Stephan

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 April 2020 09:52 UTC](https://discourse.nodered.org/t/shutdown-synology-diskstation-from-on-it-running-flow/25226/2 "2020-04-21T09:52:47Z")

</div>

Is it possible to shutdown from the command line? If it is running something like linux that might be  
`sudo shutdown -h now`

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 April 2020 10:27 UTC](https://discourse.nodered.org/t/shutdown-synology-diskstation-from-on-it-running-flow/25226/3 "2020-04-21T10:27:52Z")

</div>

As Colin suggests, use an exec node to run the command.

In order to check if someone is logged in:

```bash
admin@Knightnet01:~$ who
admin pts/15 2020-04-21 11:26 (192.168.1.145)
admin@Knightnet01:~$ users
admin

```

Either the who or users commands will work.

---

<div class="post-metadata">

**Author:** ![stephsache](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@stephsache](https://discourse.nodered.org/u/stephsache)\
**Post date:** [21 April 2020 11:38 UTC](https://discourse.nodered.org/t/shutdown-synology-diskstation-from-on-it-running-flow/25226/4 "2020-04-21T11:38:55Z")

</div>

Thank you, both!  
The shutdown command works well with the exec node!

Also thank you for the logged-in users check, I will check this later.

Great forum!

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 April 2020 13:07 UTC](https://discourse.nodered.org/t/shutdown-synology-diskstation-from-on-it-running-flow/25226/5 "2020-04-21T13:07:58Z")

</div>

I probably should say that I don't know whether those commands will pick up if someone is using one of the Synology's "stations" to view video, listen to music, etc. I suspect not but I don't know how you would spot that anyway. One for the Synology forum perhaps. If you find out, do let us know here, it would be interesting.

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [21 April 2020 13:12 UTC](https://discourse.nodered.org/t/shutdown-synology-diskstation-from-on-it-running-flow/25226/6 "2020-04-21T13:12:11Z")

</div>

Same for logged in on the web interface to DSM I'm afraid, afaik that doesn't register as logged in user on OS level, just for DSM itself.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 April 2020 13:14 UTC](https://discourse.nodered.org/t/shutdown-synology-diskstation-from-on-it-running-flow/25226/7 "2020-04-21T13:14:57Z")

</div>

Yes, I was afraid of that. Doubtless the login/out events are recorded in a log somewhere but I don't know where.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 April 2020 13:19 UTC](https://discourse.nodered.org/t/shutdown-synology-diskstation-from-on-it-running-flow/25226/8 "2020-04-21T13:19:50Z")

</div>

UPDATED: Improved flow to simplify the output.

Ah, here we go, you could use SNMP to monitor the NAS:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/1/618f3ef49542353c8b9620b0ac0a87d5aa6a6bb7.png)

Here you have a flow and can see that I'm logged into both one of the web pages (the admin page in this case) and my PC is connected to a remote share.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/50c7f90fefd3d02ad2a86e447025535928855a71.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/b/ab93e0063666422d5fd2736055fa7d9da5ff6f3d.png)

```auto
[{"id":"c003f871.ec8ac8","type":"inject","z":"ef122f0d.d488b","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":75,"y":2120,"wires":[["4a40fc6a.ebb774"]],"l":false},{"id":"4a40fc6a.ebb774","type":"snmp subtree","z":"ef122f0d.d488b","host":"192.168.1.161","community":"kn01","version":"2c","oids":"1.3.6.1.4.1.6574.6.1.1.2","timeout":5,"name":"NAS Service Names","x":220,"y":2120,"wires":[["f557d837.2a6c38"]]},{"id":"61272fd7.67b6c","type":"debug","z":"ef122f0d.d488b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":790,"y":2120,"wires":[]},{"id":"31552ed8.a53262","type":"snmp subtree","z":"ef122f0d.d488b","host":"192.168.1.161","community":"kn01","version":"2c","oids":"1.3.6.1.4.1.6574.6.1.1.3","timeout":5,"name":"NAS Service # Logged In Users","x":530,"y":2120,"wires":[["4cc8a2df.50425c"]]},{"id":"f557d837.2a6c38","type":"change","z":"ef122f0d.d488b","name":"Move payload","rules":[{"t":"move","p":"payload","pt":"msg","to":"namesArr","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":355,"y":2120,"wires":[["31552ed8.a53262"]],"l":false},{"id":"4cc8a2df.50425c","type":"function","z":"ef122f0d.d488b","name":"Simplify the data","func":"const out = {}\n\nmsg.namesArr.forEach( (name, i) => {\n n = (Buffer.from(name.value)).toString()\n out[n] = msg.payload[i].value\n} )\n\ndelete msg.namesArr\ndelete msg.oid\n\nmsg.payload = out\n\nreturn msg;","outputs":1,"noerr":0,"x":695,"y":2120,"wires":[["61272fd7.67b6c"]],"l":false}]

```

Amazing what you can do with Node-RED when you are bored of reviewing and responding to IT tenders. 😉

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [21 April 2020 15:09 UTC](https://discourse.nodered.org/t/shutdown-synology-diskstation-from-on-it-running-flow/25226/9 "2020-04-21T15:09:44Z")

</div>

some of my best flows are written during conference calls 😉

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 June 2020 15:23 UTC](https://discourse.nodered.org/t/shutdown-synology-diskstation-from-on-it-running-flow/25226/10 "2020-06-20T15:23:43Z")

</div>

Closed on 20 June 2020 15:23 UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
