Hi All,

How do i send a NL ? in the template ?

If it helps anyone below is a copy of my alert script.



-------------------------------------------
#!/usr/bin/ruby1.9.1
require 'net/http'
require 'uri'
require 'cgi'

#BudgetSMS Account Details
$budgetsms_username = "user"
$budgetsms_userid = "uid"
$budgetsms_handle = "handle"
$budgetsms_password = "password"
$budgetsms_server = "http://www.budgetsms.net/api/sendsms";
$budgetsms_from = "Company Name"

argv = ARGV.join(", ")
ARGV.clear

def split_args( jmsg )
   args = jmsg.split(',')
   level = args.shift
   phone = args.shift.lstrip
   message = args.join("").lstrip
   action( level, phone, message)
end


def join_message( argv, argf)
   if argv.size == 0
       split_args(argf)
   else
       split_args("#{argv}, #{argf}")
   end
end


def write_file( level, phone, message )
   dump_file = File.open("/tmp/dump", 'w' )
   dump_file.puts "Level: #{level}; Phone: #{phone}; Message: #{message}"
   dump_file.close
end


def smsalert( encoded_message, to )
   puts to
   
url="#{$budgetsms_server}?username=#{$budgetsms_username}&handle=#{$budgetsms_handle}&userid=#{$budgetsms_userid}&to=#{to}&msg=#{encoded_message}&from=#{$budgetsms_from}"
   puts url
   answer=Net::HTTP.get_print URI.parse(url)
   puts answer
end


def smscheck( )
   
url="#{$budgetsms_server}?username=#{$budgetsms_username}&handle=#{$budgetsms_handle}&userid=#{$budgetsms_userid}"
   puts url
   answer=Net::HTTP.get_print URI.parse(url)
   puts answer
end


def alert( level, phone, message )
   if ( level =~ /FILLER/ )
       message = "FILE ERROR Alert: #{message}"
   else
       message = "System Alert: LEVEL: #{level} #{message}"
   end
   encoded_message = CGI.escape( message ).gsub("+", "%20")
   #smsalert( encoded_message, phone )
   write_file( level, phone, message )
end


def action( status, phone, message)
   if ( status =~ /not exist/ )
       level =  "CRITICAL"
       alert( level, phone, message )
   elsif ( status =~ /Timeout/ )
       level =  "CRITICAL"
       alert( level, phone, message )
   elsif ( status =~ /failed/ )
       level =  "CRITICAL"
       alert( level, phone, message )
   elsif ( status =~ /Resource limit matched/ )
       level =  "CRITICAL"
       alert( level, phone, message )
   elsif ( status =~ /Invalid type/ )
       level =  "CRITICAL"
       alert( level, phone, message )
   elsif ( status =~ /changed/ )
       level =  "WARNING"
       alert( level, phone, message )
   elsif ( status =~ /done/ )
       level =  "WARNING"
       alert( level, phone, message )
   elsif ( status =~ /FILLER/ )
       level =  "FILLER"
       alert( level, phone, message )
   else
       level = "OK"
       alert( level, phone, message )
   end
end


while !ARGF.eof?
   join_message( argv, ARGF.readline)
end



On 10 February 2011 14:49, Rainer Gerhards <rgerha...@hq.adiscon.com> wrote:
> ahhh... I see the message. Does your application wait for a NL character? I
> am asking, because you have written none!
>
>> -----Original Message-----
>> From: rsyslog-boun...@lists.adiscon.com [mailto:rsyslog-
>> boun...@lists.adiscon.com] On Behalf Of Rainer Gerhards
>> Sent: Thursday, February 10, 2011 3:49 PM
>> To: rsyslog-users
>> Subject: Re: [rsyslog] OMPROG data not being received
>>
>> thanks for the log. But please have a look at it: search for omprog.
>> You'll
>> see that the data is written to the pipe. I have no idea why the OS
>> doesn't
>> deliver it to your program. At this point, rsyslog has called the
>> write() OS
>> API, and I do not see what else should be required. Anyone an idea?
>>
>> Rainer
>>
>> > -----Original Message-----
>> > From: rsyslog-boun...@lists.adiscon.com [mailto:rsyslog-
>> > boun...@lists.adiscon.com] On Behalf Of Mark Olliver
>> > Sent: Thursday, February 10, 2011 3:21 PM
>> > To: rsyslog-users
>> > Subject: Re: [rsyslog] OMPROG Doccumentation
>> >
>> > Thanks
>> >
>> > Libtool fixed the build i will send the new log shortly.
>> >
>> > Regards
>> >
>> > On 10 February 2011 14:16, Rainer Gerhards <rgerha...@hq.adiscon.com>
>> > wrote:
>> > > libtool is missing, probably more. let me see that I upload a
>> tarball
>> > (but
>> > > that will take a short while, I am absent from the system now).
>> > >
>> > >> -----Original Message-----
>> > >> From: rsyslog-boun...@lists.adiscon.com [mailto:rsyslog-
>> > >> boun...@lists.adiscon.com] On Behalf Of Mark Olliver
>> > >> Sent: Thursday, February 10, 2011 3:15 PM
>> > >> To: rsyslog-users
>> > >> Subject: Re: [rsyslog] OMPROG Doccumentation
>> > >>
>> > >> mpo@mordac:rsyslog(v4.6.4-omprogTest)$ autoreconf -fvi
>> > >> Can't exec "libtoolize": No such file or directory at
>> > >> /usr/bin/autoreconf line 189.
>> > >> Use of uninitialized value in pattern match (m//) at
>> > >> /usr/bin/autoreconf line 189.
>> > >> autoreconf: Entering directory `.'
>> > >> autoreconf: configure.ac: not using Gettext
>> > >> autoreconf: running: aclocal --force -I m4
>> > >> autoreconf: configure.ac: tracing
>> > >> autoreconf: configure.ac: not using Libtool
>> > >> autoreconf: running: /usr/bin/autoconf --force
>> > >> configure.ac:25: error: possibly undefined macro:
>> AC_DISABLE_STATIC
>> > >>       If this token and others are legitimate, please use
>> > >> m4_pattern_allow.
>> > >>       See the Autoconf documentation.
>> > >> configure.ac:26: error: possibly undefined macro: AC_PROG_LIBTOOL
>> > >> autoreconf: /usr/bin/autoconf failed with exit status: 1
>> > >>
>> > >>
>> > >> On 10 February 2011 14:09, Rainer Gerhards
>> > <rgerha...@hq.adiscon.com>
>> > >> wrote:
>> > >> > http://www.rsyslog.com/doc/build_from_repo.html
>> > >> >
>> > >> >> -----Original Message-----
>> > >> >> From: rsyslog-boun...@lists.adiscon.com [mailto:rsyslog-
>> > >> >> boun...@lists.adiscon.com] On Behalf Of Mark Olliver
>> > >> >> Sent: Thursday, February 10, 2011 3:08 PM
>> > >> >> To: rsyslog-users
>> > >> >> Subject: Re: [rsyslog] OMPROG Doccumentation
>> > >> >>
>> > >> >> Hi,
>> > >> >>
>> > >> >> I am not sure on how to build that as there is no configure
>> > script,
>> > >> >> how should i generate this from the git checkout?
>> > >> >>
>> > >> >> Thanks
>> > >> >>
>> > >> >> Mark
>> > >> >> _______________________________________________
>> > >> >> rsyslog mailing list
>> > >> >> http://lists.adiscon.net/mailman/listinfo/rsyslog
>> > >> >> http://www.rsyslog.com
>> > >> > _______________________________________________
>> > >> > rsyslog mailing list
>> > >> > http://lists.adiscon.net/mailman/listinfo/rsyslog
>> > >> > http://www.rsyslog.com
>> > >> >
>> > >> _______________________________________________
>> > >> rsyslog mailing list
>> > >> http://lists.adiscon.net/mailman/listinfo/rsyslog
>> > >> http://www.rsyslog.com
>> > > _______________________________________________
>> > > rsyslog mailing list
>> > > http://lists.adiscon.net/mailman/listinfo/rsyslog
>> > > http://www.rsyslog.com
>> > >
>> > _______________________________________________
>> > rsyslog mailing list
>> > http://lists.adiscon.net/mailman/listinfo/rsyslog
>> > http://www.rsyslog.com
>> _______________________________________________
>> rsyslog mailing list
>> http://lists.adiscon.net/mailman/listinfo/rsyslog
>> http://www.rsyslog.com
> _______________________________________________
> rsyslog mailing list
> http://lists.adiscon.net/mailman/listinfo/rsyslog
> http://www.rsyslog.com
>
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com

Reply via email to