Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4c2642d
Showing
13 changed files
with
537 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
blib* | ||
Makefile | ||
Makefile.old | ||
Build | ||
Build.bat | ||
_build* | ||
pm_to_blib* | ||
*.tar.gz | ||
.lwpcookies | ||
cover_db | ||
pod2htm*.tmp | ||
POE-Component-NetSNMP-agent-* | ||
.*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/perl | ||
use strict; | ||
use warnings; | ||
use Module::Build; | ||
|
||
my $builder = Module::Build->new( | ||
module_name => 'POE::Component::NetSNMP::agent', | ||
license => 'perl', | ||
dist_author => 'Sebastien Aperghis-Tramoni <sebastien@aperghis.net>', | ||
dist_version_from => 'lib/POE/Component/NetSNMP/agent.pm', | ||
requires => { | ||
'NetSNMP::agent' => 0, | ||
'POE' => 0, | ||
'SNMP' => 0, | ||
}, | ||
build_requires => { | ||
'Test::More' => 0, | ||
}, | ||
add_to_cleanup => [ 'POE-Component-NetSNMP-agent-*' ], | ||
); | ||
|
||
$builder->create_build_script(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Revision history for POE-Component-NetSNMP-agent | ||
|
||
0.100 2011.06.xx (SAPER) | ||
First version, released on an unsuspecting world. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
MANIFEST | ||
Build.PL | ||
Makefile.PL | ||
README | ||
Changes | ||
lib/POE/Component/NetSNMP/agent.pm | ||
t/00-load.t | ||
t/90-pod.t | ||
t/91-pod-coverage.t | ||
t/95-manifest.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/perl | ||
use strict; | ||
use warnings; | ||
use ExtUtils::MakeMaker; | ||
|
||
WriteMakefile( | ||
NAME => 'POE::Component::NetSNMP::agent', | ||
LICENSE => 'perl', | ||
AUTHOR => 'Sebastien Aperghis-Tramoni <sebastien@aperghis.net>', | ||
VERSION_FROM => 'lib/POE/Component/NetSNMP/agent.pm', | ||
ABSTRACT_FROM => 'lib/POE/Component/NetSNMP/agent.pm', | ||
PREREQ_PM => { | ||
# prereqs | ||
'NetSNMP::agent' => 0, | ||
'POE' => 0, | ||
'SNMP' => 0, | ||
|
||
# build/test prereqs | ||
'Test::More' => 0, | ||
}, | ||
PL_FILES => {}, | ||
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, | ||
clean => { FILES => 'POE-Component-NetSNMP-agent-*' }, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
NAME | ||
|
||
POE::Component::NetSNMP::agent - AgentX clients with NetSNMP::agent and POE | ||
|
||
|
||
DESCRIPTION | ||
|
||
This module is a thin wrapper around "NetSNMP::agent" to use it within a | ||
"POE"-based program. | ||
|
||
|
||
INSTALLATION | ||
|
||
To install this module, run the following commands: | ||
|
||
perl Makefile.PL | ||
make | ||
make test | ||
make install | ||
|
||
Alternatively, to install with Module::Build, you can use the | ||
following commands: | ||
|
||
perl Build.PL | ||
./Build | ||
./Build test | ||
./Build install | ||
|
||
|
||
SUPPORT | ||
|
||
You can find documentation for this module with the perldoc command. | ||
|
||
perldoc POE::Component::NetSNMP::agent | ||
|
||
You can also look for information at: | ||
|
||
* RT: CPAN's request tracker (report bugs here) | ||
https://rt.cpan.org/Public/Dist/Display.html?Name=POE-Component-NetSNMP-agent | ||
|
||
* AnnoCPAN: Annotated CPAN documentation | ||
http://annocpan.org/dist/POE-Component-NetSNMP-agent | ||
|
||
* CPAN Ratings | ||
http://cpanratings.perl.org/d/POE-Component-NetSNMP-agent | ||
|
||
* Search CPAN | ||
http://search.cpan.org/dist/POE-Component-NetSNMP-agent/ | ||
|
||
|
||
AUTHOR | ||
|
||
Sebastien Aperghis-Tramoni "<sebastien at aperghis.net>" | ||
|
||
|
||
LICENSE AND COPYRIGHT | ||
|
||
Copyright 2011 Sebastien Aperghis-Tramoni. | ||
|
||
This program is free software; you can redistribute it and/or modify it | ||
under the terms of either: the GNU General Public License as published | ||
by the Free Software Foundation; or the Artistic License. | ||
|
||
See http://dev.perl.org/licenses/ for more information. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/perl | ||
use strict; | ||
use NetSNMP::agent; | ||
use NetSNMP::ASN; | ||
use POE qw< Component::NetSNMP::agent >; | ||
|
||
|
||
use constant { | ||
AGENT_OID => "1.3.6.1.4.1.32272", | ||
}; | ||
|
||
POE::Component::NetSNMP::agent->spawn( | ||
Alias => "snmp_agent", | ||
AgentOID => AGENT_OID, | ||
AgentX => 1, | ||
Callback => \&agent_handler, | ||
); | ||
|
||
POE::Kernel->run; | ||
exit; | ||
|
||
sub agent_handler { | ||
my ($kernel, $heap, $args) = @_[ KERNEL, HEAP, ARG1 ]; | ||
my ($handler, $reg_info, $request_info, $requests) = @$args; | ||
|
||
# the rest of the code works like a pure NetSNMP::agent callback | ||
my $mode = $request_info->getMode; | ||
|
||
for (my $request = $requests; $request; $request = $request->next) { | ||
if ($mode == MODE_GET) { | ||
$request->setValue(ASN_OCTET_STR, "hello"); | ||
} | ||
elsif ($mode == MODE_GETNEXT) { | ||
$request->setOID(AGENT_OID.".1"); | ||
$request->setValue(ASN_OCTET_STR, "hello"); | ||
} | ||
else { | ||
# ... | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/perl | ||
use strict; | ||
use NetSNMP::agent; | ||
use NetSNMP::ASN; | ||
use POE qw< Component::NetSNMP::agent >; | ||
|
||
|
||
use constant { | ||
AGENT_OID => "1.3.6.1.4.1.32272", | ||
}; | ||
|
||
my $agent = POE::Component::NetSNMP::agent->spawn( | ||
Alias => "snmp_agent", | ||
AgentOID => AGENT_OID, | ||
AgentX => 1, | ||
Callback => "agent_handler", | ||
); | ||
|
||
POE::Session->create( | ||
inline_states => { | ||
_start => sub { | ||
$_[KERNEL]->post($agent => register => "agent_handler"); | ||
}, | ||
agent_handler => \&agent_handler, | ||
}, | ||
); | ||
|
||
POE::Kernel->run; | ||
exit; | ||
|
||
sub agent_handler { | ||
my ($kernel, $heap, $args) = @_[ KERNEL, HEAP, ARG1 ]; | ||
my ($handler, $reg_info, $request_info, $requests) = @$args; | ||
|
||
# the rest of the code works like a pure NetSNMP::agent callback | ||
my $mode = $request_info->getMode; | ||
|
||
for (my $request = $requests; $request; $request = $request->next) { | ||
if ($mode == MODE_GET) { | ||
$request->setValue(ASN_OCTET_STR, "hello"); | ||
} | ||
elsif ($mode == MODE_GETNEXT) { | ||
$request->setOID(AGENT_OID.".1"); | ||
$request->setValue(ASN_OCTET_STR, "hello"); | ||
} | ||
else { | ||
# ... | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.