[gentoo-user] Re: [OT] attach a perl script to daemon services

2010-03-02 Thread Harry Putnam
Alan McKinnon alan.mckin...@gmail.com writes:

 On Monday 01 March 2010 06:16:09 Harry Putnam wrote:
 Alan McKinnon alan.mckin...@gmail.com writes:

  FWIW, Solaris syslogd is like other basic tools on Solaris:
  standards compliant in that it caters for the lowest common
  denominator that comprises Unix. Which is to say, almost always
  useless for real work.
 
 A little turn towards OT:
 so what are using your opensolaris machines for?
 The advantages of zfs?


 I had Solaris, not OpenSolaris. I've been steadily reducing my
 Solaris machines (mostly because of the horrendous cost) and not
 many are left. Other teams here still have quite a few, mostly for
 proprietary ISP monitoring stuff, Oracle, VoIP billing systems -
 that kind of thing.

No interest in opensolaris then?  The `ZFS' file system alone makes it
worth looking at... its a working system very similar to what linux
community is trying with btrfs

I guess you know that Oracle bought Sun.  Some on the opensolaris
lists have been pretty concerned about the fate of opensolaris.

In the last few days some Oracle heavies have put it on line that
Oracle plans to put more devel money into Opensolaris than Sun had
been so many in that community are relieved.

If you're interested, look for: 

  Subject: Oracle Says OpenSolaris Will Stay Open Source

On news.gmane.org under:
  gmane.os.solaris.opensolaris.general

The only url have to hand is below but there were several others 
cited a fair bit more info in thead as well:

  
http://www.internetnews.com/dev-news/article.php/3867776/Oracle+Says+OpenSolaris+Will+Stay+Open+Source.htm




Re: [gentoo-user] Re: [OT] attach a perl script to daemon services

2010-03-02 Thread Alan McKinnon
On Wednesday 03 March 2010 00:26:35 Harry Putnam wrote:
 Alan McKinnon alan.mckin...@gmail.com writes:
  On Monday 01 March 2010 06:16:09 Harry Putnam wrote:
  Alan McKinnon alan.mckin...@gmail.com writes:
   FWIW, Solaris syslogd is like other basic tools on Solaris:
   standards compliant in that it caters for the lowest common
   denominator that comprises Unix. Which is to say, almost always
   useless for real work.
  
  A little turn towards OT:
  so what are using your opensolaris machines for?
  The advantages of zfs?
  
  I had Solaris, not OpenSolaris. I've been steadily reducing my
  Solaris machines (mostly because of the horrendous cost) and not
  many are left. Other teams here still have quite a few, mostly for
  proprietary ISP monitoring stuff, Oracle, VoIP billing systems -
  that kind of thing.
 
 No interest in opensolaris then?  The `ZFS' file system alone makes it
 worth looking at... its a working system very similar to what linux
 community is trying with btrfs

Sadly, using opensolaris would require a massive change in how we do things, 
and it's just not worth it for us.

ZFS is great, but it's not something we'd use. Rather, it's not something we 
have a pressing need for and the problems it solves are not problems we have.



 
 I guess you know that Oracle bought Sun.  Some on the opensolaris
 lists have been pretty concerned about the fate of opensolaris.
 
 In the last few days some Oracle heavies have put it on line that
 Oracle plans to put more devel money into Opensolaris than Sun had
 been so many in that community are relieved.
 
 If you're interested, look for:
 
   Subject: Oracle Says OpenSolaris Will Stay Open Source
 
 On news.gmane.org under:
   gmane.os.solaris.opensolaris.general
 
 The only url have to hand is below but there were several others
 cited a fair bit more info in thead as well:
 
  
 http://www.internetnews.com/dev-news/article.php/3867776/Oracle+Says+OpenS
 olaris+Will+Stay+Open+Source.htm

-- 
alan dot mckinnon at gmail dot com



Re: [gentoo-user] Re: [OT] attach a perl script to daemon services

2010-03-01 Thread Alan McKinnon
On Monday 01 March 2010 06:16:09 Harry Putnam wrote:
 Alan McKinnon alan.mckin...@gmail.com writes:
  FWIW, Solaris syslogd is like other basic tools on Solaris: standards
  compliant in that it caters for the lowest common denominator that
  comprises Unix. Which is to say, almost always useless for real work.
 
 A little turn towards OT:
 so what are using your opensolaris machines for?
 The advantages of zfs?


I had Solaris, not OpenSolaris. I've been steadily reducing my Solaris 
machines (mostly because of the horrendous cost) and not many are left. Other 
teams here still have quite a few, mostly for proprietary ISP monitoring 
stuff, Oracle, VoIP billing systems - that kind of thing.



-- 
alan dot mckinnon at gmail dot com



Re: [gentoo-user] Re: [OT] attach a perl script to daemon services

2010-02-28 Thread Alan McKinnon
On Saturday 27 February 2010 20:40:17 Harry Putnam wrote:
 In the back of my mind there was a reason on opensolaris, that the
 script would fail if the fifo was empty... Then once data comes the
 script isn't listening.  Or syslog won't write or something similar.
 
 I also have an opensolaris box that will be using this same script.
 
 I don't want to back up and relocate all that right now... Not sure I
 have it remembered right either, it seems just easier to have the
 script check before trying to start (for portability).
 
 Solaris syslog can write to named pipes but no so readily as linux
 syslog.  Not sure of the details now.

The rest of your post seems adequately answered elsewhere.

FWIW, Solaris syslogd is like other basic tools on Solaris: standards 
compliant in that it caters for the lowest common denominator that comprises 
Unix. Which is to say, almost always useless for real work.

I tossed syslogd on Solaris long long ago and migrated everything to syslog-
ng. The nice thing about syslog-ng is that it actually *works*, and does so 
predictably.

-- 
alan dot mckinnon at gmail dot com



[gentoo-user] Re: [OT] attach a perl script to daemon services

2010-02-28 Thread Harry Putnam
Alan McKinnon alan.mckin...@gmail.com writes:

 FWIW, Solaris syslogd is like other basic tools on Solaris: standards 
 compliant in that it caters for the lowest common denominator that comprises 
 Unix. Which is to say, almost always useless for real work.

A little turn towards OT:
so what are using your opensolaris machines for?
The advantages of zfs?




[gentoo-user] Re: [OT] attach a perl script to daemon services

2010-02-27 Thread Harry Putnam
Alan McKinnon alan.mckin...@gmail.com writes:

 On Friday 26 February 2010 23:44:03 Harry Putnam wrote:
 Where I'm weak is the part where the custom script checks if the
 daemon is running, before the script itself starts.  That part would
 need to be something pretty fool proof... maybe just grep ps output
 for the daemon?

 Maybe I'm misunderstanding you, but I don't understand this approach.

 If the daemon is not running there's nothing in the fifo. Why got to all the 
 complexity of writing an independent program that checks if something is 
 running then does various actions? The script necessarily depends on the 
 daemon running so instead of checking if it is, simply have the daemon start 
 the script. No daemon running = no script launched = no complexity.

In the back of my mind there was a reason on opensolaris, that the
script would fail if the fifo was empty... Then once data comes the
script isn't listening.  Or syslog won't write or something similar.

I also have an opensolaris box that will be using this same script.

I don't want to back up and relocate all that right now... Not sure I
have it remembered right either, it seems just easier to have the
script check before trying to start (for portability).

Solaris syslog can write to named pipes but no so readily as linux
syslog.  Not sure of the details now.

 If I'm still off-bat and this approach cannot work for solid technical 
 reasons, then I'll go away and shut if if you say so :-)

No, not off-base... thanks.  The checking isn't so hard to figure
anyway, but you didn't talk about the script having some kind of trap
or something to cover unexpected kill or failure.

Michael has covered that somewhat.

Also I didn't think to search cpan for something that does what I
want. That may turn up something I can just plug into.

Michael Higgins li...@evolone.org writes:

[...]

 in my perl script:

 log_file='Sys::Syslog', pid_file='/var/run/evolone_agi.pid';

 Sys::Syslog is an interface to the UNIX syslog(3) program.

 from /etc/init.d/evolone_agi

 depend() {
   need net asterisk postgresql-8.4
 }

 As for reading new information, there are a gazillion ways. Trap a
 signal to reread the configs?

 reload() {
 ebegin Reloading evolone_agi configuration 
   start-stop-daemon --signal 1 --pidfile /var/run/evolone_agi.pid 
 eend $? Error reloading evolone_agi
 }

Thanks ... good info.  How does the script behave regarding what
happens if it receives a sigINT or sigKILL, or some other way dies
(even from an internal error)?

Does it log to syslog? and notify sysadmin?

I haven't had occasion to run into an `EXIT trap' in perl... but there
must be such a thing.




Re: [gentoo-user] Re: [OT] attach a perl script to daemon services

2010-02-27 Thread Michael Higgins
On Sat, 27 Feb 2010 12:40:17 -0600
Harry Putnam rea...@newsguy.com wrote:

  reload() {
  ebegin Reloading evolone_agi configuration 
  start-stop-daemon --signal 1
  --pidfile /var/run/evolone_agi.pid eend $? Error reloading
  evolone_agi }  

 Thanks ... good info.  How does the script behave regarding what
 happens if it receives a sigINT or sigKILL, or some other way dies
 (even from an internal error)?

This script is more proof-of-concept piece hacked together in an hour
which just routes my outgoing calls to local free PSTN or SIP. So I know
if it needs restarting when I can't make a call from home. ;-)

Basically, I think if you perldoc Net::Server[::SIG]

In there is:

  $self-pre_server_close_hook;

... might be your friend to share some Sys::Syslog routines.

In the Net::Server code:
### set some sigs
  $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = sub { $self-server_close; };

  ### most cases, a closed pipe will take care of itself
  $SIG{PIPE} = 'IGNORE';

  ### catch children (mainly for Fork and PreFork but works for any
  chld) $SIG{CHLD} = \sig_chld;

  ### catch sighup
  $SIG{HUP} = sub { $self-sig_hup; }


... seems to have it covered for most cases. ;-) You can see sig_hup is
almost expected to do something.

 
 Does it log to syslog? and notify sysadmin?

I think a good use of Net::Server::* and Sys::Syslog can get you where
you want. I'd bet you can put anything in that pre_server_close_hook
hook... send an email, set off the building alarms... it's perl, after
all. But I really haven't done much directly with it.

 
 I haven't had occasion to run into an `EXIT trap' in perl... but there
 must be such a thing.
 

perldoc -q signal
perldoc perlipc

HTH.

-- 
 |\  /||   |  ~ ~  
 | \/ ||---|  `|` ?
 ||ichael  |   |iggins\^ /
 michael.higgins[at]evolone[dot]org



[gentoo-user] Re: [OT] attach a perl script to daemon services

2010-02-26 Thread Harry Putnam
Alan McKinnon alan.mckin...@gmail.com writes:

 Then tap into the fifo with a perl script that is written to be able
 to sort and write the syslog output according to various regex that
 may be part of startup cmd or fed in later during the running script.

 I don't know rsyslog at all (I use syslog-ng), but certain concepts
 are stable and universal.

Please reread my OP or maybe I should attempt to clarify what must be
a poorly written question.

I'm not asking help on anything about writing to a named pipe or
anything about the functioning of rsyslog... I know that part.

Not asking  about the bulk of  the perl scripting, such  as sorting by
regex, reading from fifo, etc (are all understood [at least well enough]).

I want an overview/outline of how one goes about attaching a script to
the operations such as start/stop of a daemon

Even there... the additions necessary to the scripts in
/etc/init.d... are understood.

I guess I want to know if its even advisable to attach custom
scripting to a daemon or if there is a well worn path for doing that.

Assuming its not clear off the wall then:

Where I'm weak is the part where the custom script checks if the
daemon is running, before the script itself starts.  That part would
need to be something pretty fool proof... maybe just grep ps output
for the daemon?

And where the custom script sends syslog (and sysadmin) a message  in
the event the script itself is killed or dies for some unexpected
reason. Something like an EXIT `trap' in shell scripting... (how its
done is perl)





Re: [gentoo-user] Re: [OT] attach a perl script to daemon services

2010-02-26 Thread Alan McKinnon
On Friday 26 February 2010 23:44:03 Harry Putnam wrote:
 Where I'm weak is the part where the custom script checks if the
 daemon is running, before the script itself starts.  That part would
 need to be something pretty fool proof... maybe just grep ps output
 for the daemon?

Maybe I'm misunderstanding you, but I don't understand this approach.

If the daemon is not running there's nothing in the fifo. Why got to all the 
complexity of writing an independent program that checks if something is 
running then does various actions? The script necessarily depends on the 
daemon running so instead of checking if it is, simply have the daemon start 
the script. No daemon running = no script launched = no complexity.

The script will simply accept what is it is given, no complex checks needed. 
Seeing as the input is from a logger, chances are you are inserting logs to a 
db, or launching a log analyser, right? Modern loggers support launching child 
scripts as a matter of routine.

If I'm still off-bat and this approach cannot work for solid technical 
reasons, then I'll go away and shut if if you say so :-)

-- 
alan dot mckinnon at gmail dot com



Re: [gentoo-user] Re: [OT] attach a perl script to daemon services

2010-02-26 Thread Michael Higgins
On Sat, 27 Feb 2010 01:00:43 +0200
Alan McKinnon alan.mckin...@gmail.com wrote:

  Where I'm weak is the part where the custom script checks if the
  daemon is running, before the script itself starts.  That part would
  need to be something pretty fool proof... maybe just grep ps output
  for the daemon?  

I have a perl fastAGI script that launches in /etc/init.d/ I just
cribbed some code from something there... 

in my perl script:

log_file='Sys::Syslog', pid_file='/var/run/evolone_agi.pid';

Sys::Syslog is an interface to the UNIX syslog(3) program.

from /etc/init.d/evolone_agi

depend() {
need net asterisk postgresql-8.4
}

As for reading new information, there are a gazillion ways. Trap a
signal to reread the configs?

reload() {
ebegin Reloading evolone_agi configuration 
start-stop-daemon --signal 1 --pidfile /var/run/evolone_agi.pid 
eend $? Error reloading evolone_agi
}

.. for example.

Hope this helps. '-)


-- 
 |\  /||   |  ~ ~  
 | \/ ||---|  `|` ?
 ||ichael  |   |iggins\^ /
 michael.higgins[at]evolone[dot]org