Re: [Snmptt-users] spool file
Brought to you by:
alex_b
|
From: Jim A. <ji...@ji...> - 2014-02-19 14:47:46
|
Andrew,
when replying please make sure you include
snm...@li... as a recipient so everyone reading the
list can chip in or benefit.
The content you have pasted there is just the end of the
/usr/sbin/snmptthandler file (note the mismatched close curly-bracket at
the end).
I would think the relevant section you need to edit is this one:--
my $spoolfile = $spool_directory.'#snmptt-trap-'.$s_pad.$usec_pad;
unless (open SPOOL, ">$spoolfile")
{
if ($DEBUGGING >= 1)
{
print "Could not write to file file $spoolfile! Trap
will be lost!\n";
}
die "Could not write to file $spoolfile! Trap will be lost!\n";
}
print SPOOL time()."\n";
while (defined(my $line = <>))
{
print SPOOL $line;
if ($DEBUGGING >= 1)
{
# Print out item passed from snmptrapd
print $line."\n";
}
}
So I guess you could add a similar section of code beginning something like
:-
my $spoolfilebak =
/var/spool/snmptt-backup/.'#snmptt-trap-'.$s_pad.$usec_pad;
and so on..
If your perl coding skills are as bad as mine though, it might take a bit
of experimentation to get it working nicely.
Note there doesn't seem to be a line:-
close (SPOOL);
anywhere. I would add one if you're going to re-use the SPOOL filehandle.
That's probably about the limit of how much I can help you without studying
the PERL documentation, which you might as well do rather than me... ;-)
Personally I'd only hack the code like this as a last resort. Does DEBUG
really not give you what you need?
Cheers,
Jim
On 19 February 2014 13:43, andrewarnier <and...@gm...> wrote:
> Hi jim,
>
> If stop the snmptt daemon , I can't get trap from device
>
> Can you give me more hint on how to modify snmptthandler saves the spool
> files in /var/spool/snmptt/ and other directory (for example :
> /var/spool/snmpttbackup/) ?
>
>
>
> Thank you in advance for your attention to this matter.
>
> Andrew
>
>
>
>
>
>
>
> My /usr/sbin/snmptthandler as follows :
>
>
>
>
>
>
> ##############################################################################
>
>
>
> if( open( CONFIG, $configfile ) ) {
>
> close CONFIG;
>
> $cfg = new Config::IniFiles( -file => $configfile);
>
> }
>
> else
>
> {
>
> if ($DEBUGGING >= 1) {
>
> print "Config file ($configfile) could not be loaded\n";
>
> }
>
> warn "Config file ($configfile) could not be loaded\n";
>
> exit(1);
>
> }
>
>
>
> if (! $cfg)
>
> {
>
> if ($DEBUGGING >= 1) {
>
> print "Error in config file - please check the syntax in
> the config file\n";
>
> }
>
> exit(1);
>
> }
>
>
>
> # DaemonMode
>
> $spool_directory = $cfg->val('DaemonMode', 'spool_directory');
>
>
>
> # Debugging
>
> if ($debugcmdline == 0) {
>
> $DEBUGGING = $cfg->val('Debugging', 'DEBUGGING');
>
> }
>
> if ($debugfilecmdline == 0) {
>
> $DEBUGGING_FILE = $cfg->val('Debugging',
> 'DEBUGGING_FILE_HANDLER');
>
> }
>
>
>
> $cfg->Delete;
>
>
>
> #
>
> # Defaults Start
>
> #
>
> if (! defined ($spool_directory)) { $spool_directory = ''} ;
>
> if (! defined ($DEBUGGING)) { $DEBUGGING = 0} ;
>
> if (! defined ($DEBUGGING_FILE)) { $DEBUGGING_FILE = ''} ;
>
> #
>
> # Defaults End
>
> #
>
>
>
>
>
> # print "Config file loaded\n";
>
>
>
> #
>
> # Load config file end
>
> #
>
>
> ##############################################################################
>
> }
>
>
>
>
>
>
>
>
>
> *From:* ave...@gm... [mailto:ave...@gm...] *On Behalf Of *Jim
> Avery
> *Sent:* Wednesday, February 19, 2014 5:10 PM
> *To:* andrewarnier
> *Cc:* snm...@li...
> *Subject:* Re: [Snmptt-users] spool file
>
>
>
> Andrew,
>
>
>
> It's actually snmptrapd which writes the files to the spool directory
> (when it runs the traphandler script. See /etc/snmp/snmptrapd.conf where I
> expect you'll find the line:
>
> traphandle default /usr/sbin/snmptthandler
>
> The snmptt daemon picks up the files from the spool directory and
> processes them.
>
>
>
> So. If you want the files not to disappear, you will need to stop the
> snmptt daemon! Alternatively I guess you could edit the snmptthandler
> script so that it saves the files off to some other directory as well as
> writing them to /var/spool/snmptt/. Depending on what you want to do, you
> could instead maybe consider enabling DEBUG for snmptt to get it to write
> to a log file (edit /etc/snmp/snmptt.ini to set the various DEBUGGING
> directives).
>
>
>
> I hope that helps.
>
>
>
> Cheers,
>
>
>
> Jim
>
>
>
>
>
> On 19 February 2014 07:06, andrewarnier <and...@gm...> wrote:
>
> Hi all,
>
> How to save the spool file that in /var/spool/snmptt?
>
> When I want to check the spool file from /var/spool/snmptt as follow :
>
> $ ls /var/spool/snmptt/ -l
>
> total 32
>
> -rw-r--r-- 1 root root 225 Feb 19 13:54 #snmptt-trap-1392789268878986
>
> -rw-r--r-- 1 root root 341 Feb 19 13:54 #snmptt-trap-1392789271066066
>
> -rw-r--r-- 1 root root 344 Feb 19 13:54 #snmptt-trap-1392789271143350
>
> -rw-r--r-- 1 root root 343 Feb 19 13:54 #snmptt-trap-1392789271235676
>
> -rw-r--r-- 1 root root 347 Feb 19 13:54 #snmptt-trap-1392789271312078
>
> -rw-r--r-- 1 root root 342 Feb 19 13:54 #snmptt-trap-1392789271389099
>
> -rw-r--r-- 1 root root 343 Feb 19 13:54 #snmptt-trap-1392789271481903
>
> -rw-r--r-- 1 root root 345 Feb 19 13:54 #snmptt-trap-1392789271573539
>
>
>
>
>
> I find the setting in snmptt.ini
>
> # Directory to read received traps from. Ex: /var/spool/snmptt/
>
> # Don't forget the trailing slash!
>
> spool_directory = /var/spool/snmptt/
>
>
>
> # Amount of time in seconds to sleep between processing spool files
>
> sleep =5
>
>
>
> after 5 sec the spool file will disappear , how to setting to save the
> spool
> file ?
>
>
>
>
>
>
>
>
>
> Andrew
>
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
> _______________________________________________
> Snmptt-users mailing list
> Snm...@li...
> https://lists.sourceforge.net/lists/listinfo/snmptt-users
>
>
>
|