Author |
Post |
|
#1 Thu Jan 27, 2011 15:28, 169 months ago.
|
Member
Registered: Aug 2010
Location: United Kingdom
|
Operating system name and version: CentOS 5.5 Version of smsd: 3.1.14 Smsd installed from: sources Name and model of a modem / phone: Wavecom Fastrack Go Plus Interface: serial
Hi,
Using the eventhandler i've got smstools to notify my monitoring application when a message is sent,received, or failed.
Using the alarmhandler i've got smstools to notify my monitoring application when there is a problem with the modem, such as it can't connect or it loses network registration.
I'm not always receiving or sending messages, so I could do with a way for smstools to notify my monitoring application when network registration is restored and currently active on an interval basis.
I really don't want to parse the logfiles, so currently I think I can do this by using regular_run and connect to the modem my self to run +CREG? but it would be cool if smstools would generate an event or alarm handle on reconnection/network registration.
Thanks,
Matt
|
|
#2 Fri Jan 28, 2011 11:29, 169 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
Good idea, thanks New messages are: Problem with registration has started n seconds ago. Problem with registration has ended. Duration was n seconds/minutes.Here is the patch: diff -Naur smstools3.orig/src/modeminit.c smstools3/src/modeminit.c --- smstools3.orig/src/modeminit.c 2010-09-20 12:31:43.000000000 +0300 +++ smstools3/src/modeminit.c 2011-01-28 13:22:45.000000000 +0200 @@ -2043,6 +2043,12 @@ static char prev_ci[32] = ""; char lac[32]; char ci[32]; + // 3.1.15: + static time_t registration_problem_started = 0; + time_t start_time; + + // 3.1.15: + start_time = time(0);
writelogfile(LOG_INFO, 0, "Checking if Modem is registered to the network");
@@ -2152,6 +2158,15 @@ { writelogfile0(LOG_ERR, 1, tb_sprintf("Error: Modem is not registered to the network")); alarm_handler0(LOG_ERR, tb); + + // 3.1.15: + if (!registration_problem_started) + { + writelogfile0(LOG_ERR, 1, tb_sprintf("Problem with registration has started %i seconds ago.", (int)time(0) - start_time)); + alarm_handler0(LOG_ERR, tb); + registration_problem_started = start_time; + } + return -1; }
@@ -2185,6 +2200,24 @@
registration_ok = 1;
+ // 3.1.15: + if (registration_problem_started) + { + int duration; + char *unit = "seconds"; + + if ((duration = (int)time(0) - registration_problem_started) >= 60) + { + duration /= 60; + unit = "minutes"; + } + + writelogfile0(LOG_ERR, 0, tb_sprintf("Problem with registration has ended. Duration was %i %s.", duration, unit)); + alarm_handler0(LOG_ERR, tb); + + registration_problem_started = 0; + } + return retries; } 'diff' Syntax Highlight powered by GeSHi
|
|
#3 Thu Feb 10, 2011 13:05, 169 months ago.
|
Member
Registered: Aug 2010
Location: United Kingdom
Topic owner
|
Very cool. It would be great if this was a regular heartbeat, so say ever 1 or 2 minutes I could set this to run an eventhandler script or similar.
|
|
#4 Thu Feb 10, 2011 13:27, 169 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
The code runs alarmhandler, eventhandler is used for other purposes.
Why do you need those messages more than once? And do you mean something like:
Problem with registration continues, has started n seconds ago.
...and this is repeated every two minutes?
|
|
#5 Thu Feb 10, 2011 13:35, 169 months ago.
|
Member
Registered: Aug 2010
Location: United Kingdom
Topic owner
|
I was thinking of:
heartbeat_sec = 60 heatbeat_script = /etc/script.sh
Using the script I can ping a monitoring app or similar to say everything is okay. I prefer this approach then just using the alarmhandler where it's either broke then fixed (with your patch).
I understand the eventhandler to be used for events (sending SMS etc.) Alarmhandler to be used for when something goes wrong, and with your patch could also be used to say when something is fixed. But a continual message to say everything is okay would be cool.
Thanks,
Matt
|
|
#6 Thu Feb 10, 2011 14:10, 169 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
If you just ping the monitoring application, it does not mean that everything is okay. It just means that smsd can ping, and is not halted. Heartbeat is problematic, because sending of SMS may take some time, probably with retries, and then beat is late. And if beat is generated by the timer, it has no original meaning. Do you use the status monitor? If you install libmm and enable status monitor in the src/Makefile, you can see the status of all modem processes from the file /var/spool/sms/stats/status. For example: Status: 11-02-10 16:06:12, riirr------- SONERA: 11-02-10 16:06:10, Receiving, 36458, 0, 457, ssi: -67 dBm (Excellent), ber: < 0.2 % ELISA: 11-02-10 16:06:08, Idle, 37703, 0, 450, ssi: -69 dBm (Excellent), ber: < 0.2 % DNA: 11-02-10 16:06:09, Idle, 32063, 0, 452, ssi: -81 dBm (Good), ber: < 0.2 % SAUNALAHTI: 11-02-10 16:06:12, Receiving, 35141, 0, 446, ssi: -75 dBm (Good), ber: < 0.2 % SAUNA2: 11-02-10 16:06:11, Receiving, 544, 0, 5, ssi: -77 dBm (Good), ber: < 0.2 %
Start: 11-02-06 16:40:37, up 3 days, 23:25
|
|
#7 Thu Feb 10, 2011 14:20, 169 months ago.
|
Member
Registered: Aug 2010
Location: United Kingdom
Topic owner
|
Yes I looked at status monitor, I could use that, just means I have to have a cron job or something to parse it, which is fine, just another piece of glue :-).
I like the idea of the heartbeat just sending network registration OK/NOT OK. For me this would cover my corner cases for monitoring.
heartbeat to say network is registered, modem OK alarmhandler to notify when things are broke then fixed eventhandler to notify when SMS sent/failed etc.
I've noticed smstools seems to halt when executing the alarmhandler script. So for now i'm using that to reset the modem then sleep for 60s. Seems to work as smstools logging starts again after 60 seconds :-)
|
|
#8 Thu Feb 10, 2011 19:10, 169 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
mattym wrote Yes I looked at status monitor, I could use that, just means I have to have a cron job or something to parse it, which is fine, just another piece of glue :-).
Not a piece of glue. This file already tells what processes are doing, and when they have had the last activity / change of status. If a modem is not registered, it's status is "Trouble". Custom external script could monitor this file, and create a hearbeat call which does whatever is required. I have to think if there can be additional column in this file, which says "registered" or "not registered". But usually status of registration has not been a problem. Perhaps you could consider to buy a modem which stays on the network . mattym wrote I like the idea of the heartbeat just sending network registration OK/NOT OK. For me this would cover my corner cases for monitoring.
Yes, basically this kind of a call sounds like a nice feature. But smstools cannot have all custom features built-in. mattym wrote I've noticed smstools seems to halt when executing the alarmhandler script. So for now i'm using that to reset the modem then sleep for 60s. Seems to work as smstools logging starts again after 60 seconds :-)
During the alarmhandler, modem is not closed. On Linux it still can be used, but it's not meant to use from alarmhandler. However, as your solution works, it of course can be used. Next version may have timeout settings for alarmhandler, eventhandler etc., and this causes that the process is terminated/killed if it's too slow. By default timeouts will not be in use, because of backwards compatibility.
|
|
#9 Thu Feb 10, 2011 22:19, 169 months ago.
|
Member
Registered: Aug 2010
Location: United Kingdom
Topic owner
|
Would smstools still have the modem open though when I parse the stats file for trouble and then do something? A modem that automatically gets registration again after two minutes would be good! I'll see about parsing the stats file just in case you change the behaviour in the next version Thanks for the help Keke Matt
|
|
#10 Fri Feb 11, 2011 09:01, 169 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
mattym wrote Would smstools still have the modem open though when I parse the stats file for trouble and then do something?
Yes, the modem is open because modem processes do their work and mainprocess updates the stats periodically. Usually smsd should be stopped when external watchdog does some actions. But one important question: when you recover a dropped modem, what do you actually do? Do you need to switch it off and on, or is it enough to send some AT command to it? If AT command is enough, what is it and what is the response for it? If AT command is enough, there could be a "reset" procedure, which is automatically done after maximum retries, when the registration fails. mattym wrote A modem that automatically gets registration again after two minutes would be good!
Or even better, a modem which does not drop from th network . Usually modems work without problems. I do not remember this kind of problems, or many of them, during the last 8 - 9 years. I think that your device is somehow broken, or bad.
|
|
#11 Fri Feb 11, 2011 09:58, 169 months ago.
|
Member
Registered: Aug 2010
Location: United Kingdom
Topic owner
|
I have to issue a AT+CFUN=1 to it, the modem then takes around 10s to reset and start network registration again.
Unfortunately it's the network reception which is a bit dodgy not the modem :-( I have one with a different aerial that is behaving much better. So i'll probably get another aerial for this one. :-D
|
|
#12 Fri Feb 11, 2011 10:26, 169 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
Okay, your antenna is broken or it's for incorrect frequency. The other one, as it works much better, does it still have the same problem, but not so often? While searching for the new antenna, "yet another glue" could be like this: - Use the modem settings start = AT+CFUN=1 and startsleeptime = 15 or little bit more. - With alarmhandler, create a flag-file when modem cannot register. - With cron, run the external watchdog which will find that flag-file. - When required, watchdog should run /etc/init.d/sms3 stop; sleep 3; /etc/init.d/sms3 start;
|
|
#13 Fri Feb 11, 2011 11:47, 169 months ago.
|
Member
Registered: Aug 2010
Location: United Kingdom
Topic owner
|
The other has the same problem, but only every couple of days/weeks... so it's not so bad. I like that solution better keke. Thanks!
|