ilovepancakes Posted June 20, 2019 Share #1 Posted June 20, 2019 Hi all, I need a little assistance with direction on how to write a simple script involving the package status (start or stop) for specific packages in DSM. I am setting up a service monitor and want to be able to "read" the status of some of the packages running on DSM (Chat, VideoStation, etc...). The way it works is, a URL is provided by the service monitor and linux can "check in" using the specific URL to show it is alive. What I want to do is have a scheduled task on DSM execute bash commands (every 5 minutes) to check if a package is started and if it is, then curl or wget the URL to the service monitor. Creating the scheduled task and using curl to ping the URL I have a handle on but what commands can be run before the curl to make sure the package is in a start state before getting to the curl? Ideally I would imagine a command that returns an error or nothing at all would be best because then I could simply enter "status_check_command && wget https://ping.com/" and I think the wget won't fire unless the status_check_command runs successfully? Is that right? I have only come across commands (synoservice) though that return something all the time. That command with --status [service name] will output back out if the service is start or stop. But how can I create a command that only moves to the curl if the status returned is started? Quote Link to comment Share on other sites More sharing options...
Olegin Posted June 20, 2019 Share #2 Posted June 20, 2019 (edited) Seems something like this $ sudo synoservicectl --status pkg-Docker-dockerd pkg-Docker-dockerd start/running $ sudo synoservicectl --status pkg-videostation-synovideopreprocessd pkg-videostation-synovideopreprocessd start/running $ sudo synoservicectl --status pkg-videostation-synovideopreprocessd pkg-videostation-synovideopreprocessd stop/waiting Names of the packages you саn see in it's config path /etc/init Edited June 20, 2019 by Olegin Quote Link to comment Share on other sites More sharing options...
Olegin Posted June 20, 2019 Share #3 Posted June 20, 2019 (edited) Example, script Videost.sh: #!/bin/sh if synoservicectl --status pkg-videostation-synovideopreprocessd | grep 'start/running' then echo 'Videostation started...' else echo 'Videostation stoped...' fi Скрытый текст Скрытый текст Edited June 20, 2019 by Olegin 1 Quote Link to comment Share on other sites More sharing options...
ilovepancakes Posted June 20, 2019 Author Share #4 Posted June 20, 2019 12 hours ago, Olegin said: Example, script Videost.sh: #!/bin/sh if synoservicectl --status pkg-videostation-synovideopreprocessd | grep 'start/running' then echo 'Videostation started...' else echo 'Videostation stoped...' fi Task Scheduler settings (Reveal hidden contents) e-mail (Reveal hidden contents) Awesome help! I was able to make it work with that script as a base with some slight modifications. Name of service had to have "ctl" after "pkg" and no "-synovideopreprocessd" after package name. #!/bin/sh if synoservicectl --status pkgctl-VideoStation | grep 'start/running' then curl --retry 3 https://example.com else curl --retry 3 https://example.com/fail fi Thank you @Olegin! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.