0
votes

As you can tell, I have a problem with Gammu. I'm using Gammu to send SMS in conjunction with PRTG Network Monitor, which is used to monitor Networking Devices(i.e Servers, Switches, Routers, Firewalls) and whenever one of the important Services goes Down, PRTG executes some batchfiles I have created, which do Gammu calls to send SMS.

But, whenever one or more services goes down, some of the batchfiles don't get executed at all and I receive the followin error:

Error 102 Error opening device. Unknown, busy or no permissions.

I have seen many related topics to this problem, but I couldn't solve my problem through any of them.

I have configured logging for Gammu, so that everything gets logged whatever happens. I have two errors that are showing up in these logs:

[System error - CreateFile in serial_open, 32, "The process cannot access the file because it is being used by another process. "] [System error - SetCommState in serial_close, 6, "The handle is invalid. "]

I have a question about the first error "The process cannot access the file because it is being used by another process.". Which file is it talking about, Gammu or my batchfile?

Here is an example of how I setup my batchfiles:

cd c:\Program Files (x86)\Gammu\bin


Rem User1
gammu sendsms TEXT 0123456789 -text "%*" -report

Rem User2
gammu sendsms TEXT 0123456789 -text "%*" -report

I tried the timeout mechanism before executing the gammu sendsms, but it didn't work at all. Do you guys have any solutions on how I can make the execution wait, until other processes are finished, so that I don't get that message?

Here is the gammuconfig:

[gammu]

device = com4:
connection = at115200
logfile = gammulog
logformat = errors

[gammu1]

device = com3:
connection = at115200
logfile = gammulog
logformat = errors

thank you in advance.

1

1 Answers

0
votes

this looks like one process is locking the whole system which sends the SMS (using serial port?)

in this case you need to rewrite your script in a way that it sends those messages not in parallel, but sequentially. Using queues is the way to go.

One possibility is to let PRTG execute batch (or python) script which will add your message to the queue. Another process which would run in loop would fetch new messages from queue and process them (send them). This way you would not execute Gammu more than once at the time. There is disadvantage to this solution and it is that if you have many alerts then it will take longer to send them all since Gammu doesn't support parallel processing

Another option is using some internet sms gateway which would allow you to send many SMS at one time