source: ocsinventory-agent/trunk/fuentes/lib/Ocsinventory/Agent/Modules/Example.pm @ 468

Last change on this file since 468 was 468, checked in by mabarracus, 4 years ago

Copyt trusty code

File size: 2.6 KB
Line 
1###############################################################################
2## OCSINVENTORY-NG
3## Copyleft Guillaume PROTET 2010
4## Web : http://www.ocsinventory-ng.org
5##
6## This code is open source and may be copied and modified as long as the source
7## code is always made freely available.
8## Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
9################################################################################
10
11package Ocsinventory::Agent::Modules::Example;
12
13
14sub new {
15   my $name="example";   #Set the name of your module here
16
17   my (undef,$context) = @_;
18   my $self = {};
19
20   #Create a special logger for the module
21   $self->{logger} = new Ocsinventory::Logger ({
22            config => $context->{config}
23   });
24
25   $self->{logger}->{header}="[$name]";
26
27   $self->{context}=$context;
28
29   $self->{structure}= {
30                        name => $name,
31                        start_handler => $name."_start_handler",    #or undef if don't use this hook
32                        prolog_writer => $name."_prolog_writer",    #or undef if don't use this hook 
33                        prolog_reader => $name."_prolog_reader",    #or undef if don't use this hook 
34                        inventory_handler => $name."_inventory_handler",    #or undef if don't use this hook
35                        end_handler => $name."_end_handler"    #or undef if don't use this hook
36   };
37 
38   bless $self;
39}
40
41
42
43######### Hook methods ############
44
45sub example_start_handler {     #Use this hook to test prerequisites needed by module and disble it if needed
46   my $self = shift;
47   my $logger = $self->{logger};
48   
49   $logger->debug("Yeah you are in example_start_handler :)");
50   my $prerequisites = 1 ;
51
52   if ( $prerequisites == 0 ) { 
53        $self->{disabled} = 1; #Use this to disable the module
54        $logger->debug("Humm my prerequisites are not OK...disabling module :( :( ");
55   }
56}
57
58
59sub example_prolog_writer {     #Use this hook to add information the prolog XML
60   my $self = shift;
61   my $logger = $self->{logger};
62   
63   $logger->debug("Yeah you are in example_prolog_writer :)");
64
65}
66
67
68sub example_prolog_reader {     #Use this hook to read the answer from OCS server
69   my $self = shift;
70   my $logger = $self->{logger};
71   
72   $logger->debug("Yeah you are in example_prolog_reader :)");
73
74}
75
76
77sub example_inventory_handler {         #Use this hook to add or modify entries in the inventory XML
78   my $self = shift;
79   my $logger = $self->{logger};
80   
81   $logger->debug("Yeah you are in example_inventory_handler :)");
82
83}
84
85
86sub example_end_handler {               #Use this hook to add treatments before the end of agent launch
87   my $self = shift;
88   my $logger = $self->{logger};
89   
90   $logger->debug("Yeah you are in example_end_handler :)");
91
92}
93
941;
Note: See TracBrowser for help on using the repository browser.