![]() |
![]() |
Subject: | SMS message alerting works but message is empty! |
Author: | [Not Specified] |
Posted: | 2014-05-26 02:56 |
Hi all,
I've set up a Xenserver hosting a Debian VM with Zenoss Core 4.2.4.
The Xenserver has a Siemens T35 GSM Modem attached to its serial port COM1.
I used ser2net + some Xenserver configuration to get it working. (COM1 binding, SELinux, ...)
I created a shell script that can easily send SMS messages.
I created a trigger + notification and everything works perfectly EXPECT that the message is empty!!!
Here is the script: (WARNING, mind the HTML characters when copying!)
#!/usr/bin/expect
# - VAR
set ctrlz \032
set xt \135
set timeout 15
set host [lindex $argv 0]
set port [lindex $argv 1]
set number [lindex $argv 2]
set message [lindex $argv 3]
# - CONNECT
spawn telnet $host $port
sleep 1
# - SEND
send AT+CMGS="$number"\r;
expect ">"
send "$message$ctrlz";
expect "OK"
# - END
And here is the Zenoss Page Command:
$ZENHOME/bin/sms.sh 10.10.0.52 3333 $RECIPIENT
This works in Linux as follows:
./sms.sh 10.10.0.52 3333 +32486000000 message
I just can't get the message from Zenoss in the SMS message....
I need to complete this last step to get it fully working!
Please help me out and I might write a blog howto entry about this issue probably helping lots of people. ;)
Subject: | Some research data |
Author: | [Not Specified] |
Posted: | 2014-05-26 03:29 |
/usr/local/zenoss/Products/ZenModel/UserSettings.py
-------------------------------------------------------------------------
def manage_pagerTest(self, REQUEST=None):
''' Send a test page
'''
destSettings = self.getUserSettings(self.getId())
destPagers = [ x.strip() for x in
(destSettings.getPagerAddresses() or []) ]
msg = None
fqdn = socket.getfqdn()
srcId = self.getUser().getId()
testMsg = ('Test sent by %s' % srcId +
' from the Zenoss installation on %s.' % fqdn)
for destPager in destPagers:
result, errorMsg = Utils.sendPage(destPager, testMsg,
self.dmd.pageCommand)
if result:
msg = 'Test page sent to %s' % ', '.join(destPagers)
else:
msg = 'Test failed: %s' % errorMsg
break
if not destPagers:
msg = 'Test page not sent, user has no pager number.'
if REQUEST:
messaging.IMessageSender(self).sendToBrowser(
'Pager Test', msg)
return self.callZenScreen(REQUEST)
else:
return msg
/usr/local/zenoss/Products/ZenUtils/Utils.py
----------------------------------------------------------
def sendPage(recipient, msg, pageCommand, deferred=False):
"""
Send a page. Return a tuple: (success, message) where
sucess is True or False.
@param recipient: name to where a page should be sent
@type recipient: string
@param msg: message to send
@type msg: string
@param pageCommand: command that will send a page
@type pageCommand: string
@return: (sucess, message) where sucess is True or False.
@rtype: tuple
"""
import subprocess
env = dict(os.environ)
env["RECIPIENT"] = recipient
msg = str(msg)
if deferred:
from twisted.internet import reactor
protocol = SendPageProtocol(msg)
d = reactor.spawnProcess(
protocol, '/bin/sh', ('/bin/sh', '-c', pageCommand), env)
# Bad practice to block on a deferred. This is done because our call
# chain is not asynchronous and we need to behave like a blocking call.
while protocol.code is None:
reactor.iterate(0.1)
return (not protocol.code, protocol.out)
else:
p = subprocess.Popen(pageCommand,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
shell=True,
env=env)
p.stdin.write(msg)
p.stdin.close()
response = p.stdout.read()
return (not p.wait(), response)
Subject: | I'll add logging |
Author: | [Not Specified] |
Posted: | 2014-06-02 07:36 |
I'll add logging functionality to sms.sh to see what is passed through to my script.
Somebody know an easy way to manually trigger a pagecommand
Subject: | Can somebody enlight me on |
Author: | [Not Specified] |
Posted: | 2014-06-02 07:37 |
Can somebody enlight me on the above issue It's pretty useless having no text in the SMS....
< |
Previous Exclude specific process on server |
Next Localized zWinUser/zWinPassword |
> |