Using Housekeeper to Collect Device Data Howto¶
Sometimes it's required to collect and store additional data from equipment beyond those provided by basic functionality. We can store collected data in the custom fields or send notifications via any available channel, like email or telegram.
Solution¶
The Housekeeper
comes to the resque. It executed in the very end of the box discovery process and allows to run the user function, wrapped in handler.
Though some known restrictions exists and should be kept in mind:
- The fatal error during box discovery will stop whole box process and the function will not be run.
- Housekeeper doesn't extend the data model and cannot introduce new fields in the data model by itself.
Implementing handler¶
/opt/noc_custom/handlers/hks.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
Place the resulting code into /opt/noc_custom/handlers/hks.py
.
Registering the Handler¶
- Go to
Main
>Setup
>Handlers
menu. - Press
Add
button. Fill the fields:
Name
- any human-readable name which will be seen to the user.Handler
- full path to the handler (noc.custom.handlers.hks.hk_handler
).- Check
Allow Housekeeping
checkbox
Creating Capability¶
We will use capabilities to store the result.
- Go to
Inventory
>Setup
->Capabilities
menu. - Press
Add
button. Fill the fields:
Name
: FillManagement | VlanID
. Name must match theMGMT_VLAN_CAPS
value in the script.Description
: Let it be a Device management vlanType
: SelectInteger
Setting up Discovery¶
- Go to
Managed Object
>Setup
>Object Profiles
- Select proper profile for your managed object
- Select tab
Box
- Select our handler in the
HouseKeeping
combo box. - Press
Save
button.
Setting up a Notification Routing¶
- Go to
Main
>Setup
>Message Route
menu - Press
Add
button. - Fill the form:
Name
: any meaningful name for user.Message Type
: Notification- Match
Checking up¶
In the command line run
./noc discovery run -c hk box <name>
where <name>
is the managed object's name or id.