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 EXCEPT that the message is empty!!!
Here is the script:
#!/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]
# - LOG
log_file -a sms.log;
send_log "$host $port $number:$message"
# - CONNECT
spawn telnet $host $port
sleep 1
# - SEND
send AT+CMGF=1\r;
expect "OK"
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!
If I try sending a test message from Zenoss, it also arrives but with no text...
Thank you for your time!
The problem appears to be that from my understanding Zenoss sends the actual message to the scripts STDIN input, but your script expects it as a command line parameter. You have to modify your expect script in a way that it will read the message from STDIN instead of
$argv 3
. After that, your test script should work like this:I don't really know expect, so I can't help with the actual script.
It's working,
I looked in the
/usr/local/zenoss/Products/ZenUtils/Utils.py
file to find that Zenoss sends the message text tostdin
so I only needed to read stdin in the expect script to get the message.Here is the new working script: (note that I left out host & port parameters)
Hope this will help anyone!
expect ">"
? Is that some kind of copy-paste error or should that actually beexpect ">"
?