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)

rooted 2010-03-21 16:56

Re: Desktop Command Execution Widget scripts
 
Many new battery scripts had been added to the wiki. Also, don't forget about DCEW wiki page, scripts are constantly being added and improved.

mrmoosehead 2010-03-22 12:43

Re: Desktop Command Execution Widget scripts
 
Quick script to get % full MyDocs:

df /home/user/MyDocs -h | grep 'MyDocs' | cut -c53-55

Disclaimer: There's probably a much easier way to do this, but it works for me. :)

rooted 2010-03-22 14:48

Re: Desktop Command Execution Widget scripts
 
df /home/user/MyDocs | awk '/My/ {print $5}'

The better one. Displays percentage column, not fixed characters.

Also percentage and space free scripts for all filesystems had been added to the wiki.

mrmoosehead 2010-03-22 16:56

Re: Desktop Command Execution Widget scripts
 
Sweet. Never used awk before, but that's what I wanted to do, just didn't know how. :)

Today I am mostly liking sqlite and the events db. :)

slipkornsaad 2010-03-23 20:38

Re: Desktop Command Execution Widget scripts
 
Is this application causing desktop freezes (all widgets, won't work anymore, only after a reboot) ? For me, it freezes my desktops, i uninstalled it, i'll see how it'll goes.

radiowc 2010-03-23 20:41

Re: Desktop Command Execution Widget scripts
 
Love this widget and I used it a lot since day one...recommend to everyone :)

Great Job!!! U da Man!

andy_con 2010-03-23 23:02

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by slipkornsaad (Post 579312)
Is this application causing desktop freezes (all widgets, won't work anymore, only after a reboot) ? For me, it freezes my desktops, i uninstalled it, i'll see how it'll goes.

i have just the same problem

cpscotti 2010-03-24 04:46

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by andy_con (Post 579489)
i have just the same problem

Known problem:
All commands are executed on boot and thus if your commands take too long or if they lock if executed on boot... it locks!
Next versions will have another check box to enable/disable execution at boot.

Will be fixed on the next version..
(my thesis is due to friday... so... I'm kinda.. well.. )

Thanks for your comprehension

andy_con 2010-03-24 12:38

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by cpscotti (Post 579726)
Known problem:
All commands are executed on boot and thus if your commands take too long or if they lock if executed on boot... it locks!
Next versions will have another check box to enable/disable execution at boot.

Will be fixed on the next version..
(my thesis is due to friday... so... I'm kinda.. well.. )

Thanks for your comprehension

cool cheers

KiberGus 2010-03-24 14:03

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by cpscotti (Post 579726)
Known problem:
All commands are executed on boot and thus if your commands take too long or if they lock if executed on boot... it locks!
Next versions will have another check box to enable/disable execution at boot.

Will be fixed on the next version..
(my thesis is due to friday... so... I'm kinda.. well.. )

Thanks for your comprehension

May be you should make asynchronous communication with executed commands?

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

orac 2010-03-30 08:31

Re: Desktop Command Execution Widget scripts
 
Using the option --spider prevents you from having to actually download content, you only need the response code.

coolice 2010-03-30 08:44

Re: Desktop Command Execution Widget scripts
 
Hi !

I am a newbie for this DCEW, just playing with it since few days, reading its wiki pages and this forum regularly. I got lost as for me for certain reasons, scripts i could found on wiki or even the built in ones not working or better to say, several of them not working.

E.g. I would like to create a battery indicator as follows :

Battery : 45% (445mAh / 1200mAh) - Charging

"- Charging" part ONLY if charging

This should be simple as this script should do the main part (except the "- Charging") :

hal-device bme | awk '/l.p/ {perc = $3}; /g.c/ {curr = $3}; /g.la/ {last = $3}; /s_c/ {isch = $3} END if (isch == "false") {print perc" % ("curr"/"last" mAh)"} else {print "Charging"}'


Problem is, that it does not show the full capacity (1200mAh) for some reason.

I had found an other script where they used something like "grep" and that one could read out the 1200mAh, but I could not combine the 2 as I did not understood the structure how it works as lack of experience.

The other thing is, I tried to create a command retrieves the actual IP address which the device reachable from :

echo WAN IP: `wget -q -O - api.myiptest.com | awk -F"\"" '{print $4" ("$12" @ "$20", "toupper($28)")"}'`; echo LAN IP: `/sbin/ifconfig | awk '/Bc/ {print $2}' | cut -c6-`

Problem is, while my device connected to my home router, lcoal ip shown, but when the device conencted to my Mobile Internet , no ip shows at all, and none of the cases shows any country or such. However, if I load e.g. ipchicken.com, logically, I can see my public ip even through the firewall.

Could someone help me to go through these 2 examples to make it udnerstandable how tehy work, so i can learn it and create other scripts pelase ?

I know I am sking a lot, btu hoping someone could spare a bit of time,

Many Thansk in advance,

Andrew

x-lette 2010-03-30 11:16

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by orac (Post 587767)
Which is why I am interested in the status response and why I started with if you can.

No, you said, you'd recommend this way. Everybody can use the IP of the server where the site is hosted, but not for everyone this makes sense.

rooted 2010-03-30 15:29

Re: Desktop Command Execution Widget scripts
 
coolice: Ok, let's go through your questions...

First of all, everything built-in and in wiki is TESTED and it WORKS. So that means that problems are on your side.

First script that you ask for is the one you pasted and is the same as in wiki. It does EXACTLY what you want. It shows percentage, current mAh, last full mAh (after a reboot last full mAh becomes 0 because the phone forgets the value, but everything else works) and when the phone is charging, it displays "Charging".

The other one you found (using grep) reads design mAh, which is always the same. Last full mAh used in the script using awk is better, because you can also monitor battery wear level with it, but it displays 0 value between a reboot and next charging.

About the IP script: The script you found displays wlan0 LAN ip and WAN IP as seen from the internet. The gprs0's IP which you can get with ifconfig is often from private address range, because mobile operators like to use NAT, so this method is not reliable and therefore not used.

Go to myiptest.com from N900's browser while connected to GPRS and post the results here. Maybe myiptest.com doesn't recognize your IP yet.

orac 2010-03-30 18:48

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by x-lette (Post 588027)
No, you said, you'd recommend this way. Everybody can use the IP of the server where the site is hosted, but not for everyone this makes sense.

Actually, the question is not trivial.

To start with, we are in agreement, but you seem to misunderstand the following:

If you can, I would recommend using the IP...

There is an implication by stating "If you can" that what follows will not be suitable for all cases. Of course it is true that for all cases an IP can be used to just test the server and it goes without saying that it can be done.

What cannot be done by using the IP is as you stated, when using name based virtual hosting - which is why I refer to the status response as being important, since my script will give a different error response for the following conditions:

1. server cannot be resolved, server is down or server is up, but nothing from the appropriate port.
2. conditions which may indicate a running server but no website. maybe your account has been blocked returning a file not found.

I am with Bluehost and there 2 things I will note here, 1, I will need to modify the script further to get the result because they will block your account by simply placing a different .htaccess file in your folder if there is a potential cross site script problem with any php they know of as a security risk. updating the php code will have the site unblocked.

2. It costs an extra dollar a month to have your own IP. I can operate personal services on incoming ports.

This script will pause the entire desktop whilst running, so avoiding a name lookup is quite appropriate, an alternative solution is add your host to the /etc/resolv.conf and this will allow name based hosts to be checked more quickly.

I tried to make my solution as generic as possible, so only people who know about virtual hosts would know what they need to use. Those who don't know may or may not care that its just the physical server that is being checked and therefore may prefer the speed of an IP check

For those who know what they are looking for, they can of course modify this or write their own.

I thought your original comment was useful, to help clarify.

Neither of us was wrong though.

orac.

TheSov 2010-03-30 20:57

Re: Desktop Command Execution Widget scripts
 
actually i have to use the dns names because i have internal ip's when im at work on the wlan and external ip's when im outside work. however i am ALWAYS working.

orac 2010-03-31 00:23

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by TheSov (Post 588870)
actually i have to use the dns names because i have internal ip's when im at work on the wlan and external ip's when im outside work. however i am ALWAYS working.

That make sense. At my work, our public servers are offsite so our office has no public facing presence nor a public domain.

I only need to check public facing servers.

orac

GrimmReaperNL 2010-04-01 03:08

Re: Desktop Command Execution Widget scripts
 
could someone help me with a command?

I would like a command that shows the full date. preferably in this format:
<day nr (1-31)>-<month name><monthnumber>-<year>

with those i should be able to mod it if i want it changed.

mjec 2010-04-01 04:07

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by GrimmReaperNL (Post 590727)
could someone help me with a command?

I would like a command that shows the full date. preferably in this format:
<day nr (1-31)>-<month name><monthnumber>-<year>

with those i should be able to mod it if i want it changed.

date +%d-%B%m-%Y

Basically it's date +<format string>. For more info on format string possibilities see http://unixhelp.ed.ac.uk/CGI/man-cgi?date.

GrimmReaperNL 2010-04-01 14:14

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by mjec (Post 590769)
date +%d-%B%m-%Y

Basically it's date +<format string>. For more info on format string possibilities see http://unixhelp.ed.ac.uk/CGI/man-cgi?date.

sweet, thanks.

edit: for other users. make sure you disable updating or it'll drain your battery. or so it did for me

Robb 2010-04-02 10:43

Re: Desktop Command Execution Widget scripts
 
Does anyone know where/if I can access the data for GPRS data download?

I want to make a 2 queries to show
1) GPRS data download (units) for last month
2) GPRS data download (units) for this month
1 unit for me is 100k of data for every connection startup.
Sumed from a given day in month


I'm looking for info where/if I can find this data...
I will make this query by myself, and post for all ;)

lubabula 2010-04-04 07:57

Re: Desktop Command Execution Widget scripts
 
anyone can help?
i can only open 3 widgets on desktop, fourth only shows as "result" and all desktop widgets and shortcuts freeze. then hildon-home crashes.

Pavol 2010-04-04 18:24

Re: Desktop Command Execution Widget scripts
 
cpu and memory usage ?

DrHofmann 2010-04-04 19:07

Re: Desktop Command Execution Widget scripts
 
I wanted to try out the widget, and I created a new command that I called Reboot, sudo reboot. That was not so smart.... :-) My N900 started to reboot and reboot and reboot. We can call it major loop :-) I solved it by flashing the phone. http://wiki.maemo.org/Updating_the_tablet_firmware # Flashing_the_eMMC_in_the_N900
I dident flash the eMMC, only point: 2.3 Windows
2.3.1 N900: XP (SP3) / Vista (SP2) / Windows 7 32-bit

Maybe this can help someone in the future.

// DrH

rooted 2010-04-04 22:25

Re: Desktop Command Execution Widget scripts
 
Many scripts have been added to the DCEW wiki page lately. I suggest that author somehow connects/integrates/embeds those scripts into the program (at least the link to the wiki page should be added because it really has tons of scripts). Also some of the default scripts are a little outdated or better version has been added to the wiki.

Scripts that are in the wiki and not in the program:

1. Enhanced battery, IP, uptime/load scripts
2. Date
3. Disk usage
4. Wi-Fi signal
5. CPU frequency
6. Memory (RAM, swap) usage
7. GPRS data usage
8. Top X processes
9. World time

Pavol 2010-04-05 09:54

Re: Desktop Command Execution Widget scripts
 
Ram usage conky 135,64 / 239,76
script : RAM used : free | awk '/M/ {printf ("%.1f MB\n",$3/1024)}'
output 30 MB :) ?

HRZ 2010-04-05 10:15

Re: Desktop Command Execution Widget scripts
 
is it possible to make a script to show how many SMS's you've sent this month.

The devel app "SMS counter" isn't stable for me (weird graphical glitches) and sometimes doesn't count correctly - ie a deleted SMS wont be counted, or some new SMSs wont even be registered....

rooted 2010-04-05 11:18

Re: Desktop Command Execution Widget scripts
 
Quote:

Originally Posted by Pavol (Post 596027)
Ram usage conky 135,64 / 239,76
script : RAM used : free | awk '/M/ {printf ("%.1f MB\n",$3/1024)}'
output 30 MB :) ?

Thank you for feedback. I've retested the scripts and everything seems to be fine. Scripts are not that complicated, they take output of the free command, and calculate MB out of it. The mathematical part of the script is reliable. The error could happen when getting data from free command, but it is unlikely. Please retest and post the output of the "free" command (enter it in terminal) when you see wrong readings. And run conky in the background when you are testing, because conky itself impacts readings (uses RAM).

Also keep in mind that the commands are very similar and therefore when you see multiple almost same commands on the wiki page you might take the wrong one in confusion. Again, please retest and rethink and I'll do the debug work when I get more feedback.


Quote:

Originally Posted by HRZ (Post 596039)
is it possible to make a script to show how many SMS's you've sent this month.

The devel app "SMS counter" isn't stable for me (weird graphical glitches) and sometimes doesn't count correctly - ie a deleted SMS wont be counted, or some new SMSs wont even be registered....


It is not possible at the moment, because N900 does not count sent SMSes yet. Aforementioned app scans your messages and counts sent SMSes this month, that's why deleted SMSes are not counted.

Pavol 2010-04-05 11:33

Re: Desktop Command Execution Widget scripts
 
free | awk '/M/ {printf ("%.1f MB\n",$3/1024)}'
output : 214,2 MB

RAM free
free | awk '/M/ {printf ("%.1f MB\n",$4/1024)}'
output : 25,2 MB

25,2 is little

syteminfowidget = 136 MB used
conky = 138 MB used

rooted 2010-04-05 12:01

Re: Desktop Command Execution Widget scripts
 
Please enter command free in root terminal and post the output. Also post output of cat /proc/meminfo. Don't worry, the data is not sensitive.


All times are GMT. The time now is 06:37.

vBulletin® Version 3.8.8