Jump to content
XPEnology Community

Simple package status commands/script help


ilovepancakes
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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 by Olegin
Link to comment
Share on other sites

Example, script Videost.sh:

#!/bin/sh
if synoservicectl --status pkg-videostation-synovideopreprocessd | grep 'start/running'
then echo 'Videostation started...'
else echo 'Videostation stoped...'
fi
Скрытый текст

1989713638_.png.586501bbe6469a1962f21d158d317912.png127787854_.png.509f3b02470797bd9c6a51e0c6ddecf8.png

1738479015_.png.a6f8562d69a2e700652cb97a95cef86e.png

 

Скрытый текст

1416979043_.thumb.png.3561ab1c8bcfe5ef15482ac815ba9548.png

 

Edited by Olegin
  • Like 1
Link to comment
Share on other sites

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)

1989713638_.png.586501bbe6469a1962f21d158d317912.png127787854_.png.509f3b02470797bd9c6a51e0c6ddecf8.png

1738479015_.png.a6f8562d69a2e700652cb97a95cef86e.png

 

  e-mail (Reveal hidden contents)

1416979043_.thumb.png.3561ab1c8bcfe5ef15482ac815ba9548.png

 

 

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!

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...