maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   Desktop Command Execution Widget scripts (https://talk.maemo.org/showthread.php?t=39177)

orac 2010-03-28 18:58

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by KiberGus (Post 580330)
May be you should make asynchronous communication with executed commands?

That's a good thought. I was really liking this widget until it locked up sometimes when roaming. I realised like you guys here, its that some commands don't complete.

In particular, any use of wget requires the "-T" option be set.

I like the real IP preloaded command, by adding "-T 5" it now never locks up.

Maybe at the least, improve the default scripts not to lock up.

Later you can try a "throw and catch" execution model.

Great widget,

orac.

TheSov 2010-03-29 02:42

Re: Desktop Command Execution Widget scripts
 
can anyone help me out, i would like to use this widget to check the status of a webserver, does anyone have a cmd that does that?

x-lette 2010-03-29 08:17

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by TheSov (Post 586141)
can anyone help me out, i would like to use this widget to check the status of a webserver, does anyone have a cmd that does that?

What do you mean with status? The Webserver (http-Server) can be checked with a wget command. Whether the machine itself is up and running could be tested with a simple ping. For nearly any service running there is a simple tool to check it's status.

TheSov 2010-03-29 17:30

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by x-lette (Post 586312)
What do you mean with status? The Webserver (http-Server) can be checked with a wget command. Whether the machine itself is up and running could be tested with a simple ping. For nearly any service running there is a simple tool to check it's status.

status like to see if its running the site, so i could use wget to get the file but how do i signal to the widget if it fails?

i consulted some people and the best i have is this

wget --timeout=10 --tries=1 http://mywebsite/sometestfile.txt
echo "$?"

thats it.

x-lette 2010-03-29 20:27

Re: Desktop Command Execution Widget scripts
 
that might work if you know what the return codes mean. easier might be clear text message like following:
wget .... && echo "success" || echo "fail"
the last echo will only fire up if one of the previous commands fails and an echo never fails ;)

TheSov 2010-03-29 20:57

Re: Desktop Command Execution Widget scripts
 
I was actually able to accomplish it by this thanks to the awesome people on freenode's #linux

first i created a script called qwebcheck in /usr/bin
Code:

wget --timeout=10 -O /dev/null http://theserveruwanttocheck.xxx/somefile.html
if [ $? -eq 1 ] ; then exit 2 ; fi
echo "System OK"

chmod the script +x and then add a new command and type in your script name and WALA!

orac 2010-03-30 06:05

Re: Desktop Command Execution Widget scripts
 
Here is my solution since I am interested in the return code:

Add a desktop widget command that contains the following line:

perl -lae '$_=`sh -c "wget -T 10 --tries=1 --spider http://www.yourserver.com/" 2>&1`;@a=split(/g\ response\.\.\.\ /s,$_);@b=split(/\n/,@a[$#a]);if (!((/failed/)||(/error/))) {print @b[0];} else {print "Error"};'

I think its safe, it should not lock up, but it does sometimes need you click it a few times to confirm its not just a network error on the way to your server.

If you can, I would recommend using the IP of your server to prevent name lookups everytime you run it.

orac.

x-lette 2010-03-30 07:57

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by orac (Post 587681)
If you can, I would recommend using the IP of your server to prevent name lookups everytime you run it.

Raw IP will work only if you are running a dedicated server (or virtual server) with own IP. If you only got webspace somewhere this would not ensure that your website can get accessed.

orac 2010-03-30 08:14

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by x-lette (Post 587753)
Raw IP will work only if you are running a dedicated server (or virtual server) with own IP. If you only got webspace somewhere this would not ensure that your website can get accessed.

Which is why I am interested in the status response and why I started with if you can.

hellnick 2010-03-30 08:22

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by TheSov (Post 586141)
can anyone help me out, i would like to use this widget to check the status of a webserver, does anyone have a cmd that does that?

Consider installing Queen Beecon

The following script was posted on Reddit by theSov:

before we start install queenbeecon drop to a shell and create the following script in your /usr/bin

wget -O /dev/null http://theserveruwanttocheck.xxx/somefile.html

if [ $? -eq 1 ] ; then exit 2 ; fi

echo "System OK"

save it, chmod +x it.

then you add a widget for queenbeecon

edit the widget, click on add command type any name u want and the name of the script you created under "command" set any settings u want. select "when connected" and your auto update at the bottom of the widget properties and there you go, remote monitoring on the go.

screens: http://imgur.com/WfosH.png http://imgur.com/QtyLo.png



Haven't tried it yet as just being lazy at the moment.

Edit. Note that Queen Beecon is in Extras Dev so usual warnings apply


All times are GMT. The time now is 05:53.

vBulletin® Version 3.8.8