Shinken packs¶
What are Packs?¶
Packs are a small subset of configuration files, templates or pictures about a subject, like Linux or windows. It’s designed to be a “pack” about how to monitor a specific subject. Everyone can contribute by creating and sending their how packs to the Shinken community website.
Technically, it’s a zip file with configuration files and some pictures or templates in it.
Let take a simple example with a linux pack, with only a CPU and a memory services checks. Files between [] are optional.
- templates.cfg -> define the host template for the “linux” tag
- commands.cfg -> define commands for getting CPU and Memory information, like by snmp for example.
- linux.pack -> json file that describe your pack
- [discovery.cfg] -> if you got a discovery rule for a “linux” (like a nmap based one), you can add it
- services/
- services/cpu.cfg -> Your two services. They must apply to the “linux” host tag!
- services/memory.cfg
- [images/sets/tag.png] -> if you want to put a linux logo for all linux host tagged host, it’s here. (size = 40x40px, in png format)
- [templates/pnp/check_cpu.php] -> if your check_cpu command got a PNP4 template
- [templates/graphite/check_cpu.graph] -> same, but for graphite
What does a .pack file looks like ?¶
It’s a json file that describe your “pack”. It will give it its name, where it should be installed, and if need give some macros provided by the host tags so it will be easier to configure in the SkonfUI.
Let use our previous Linux sample:
{
"name":"linux",
"description":"Standard linux checks, like CPU, RAM and disk space. Checks are done by SNMP.",
"path":"os/",
"macros":{
"_SNMPCOMMUNITY": {"type":"string",
"description":"The read snmp community allowed on the linux server"
},
"_LOAD_WARN": {"type":"string",
"description": "Value for starting warning state for the load average at 1m,5m,15m"
},
"_LOAD_CRIT": {"type":"string",
"description": "Value for starting critical state for the load average at 1m,5m,15m"
},
"_MEM_WARN": {"type":"percent",
"description": "Warning level for used disk space"
},
"_MEM_CRIT": {"type":"percent",
"description": "Critical level for used disk space"
},
"_CPU_WARN": {"type":"percent",
"description": "Warning level for the CPU usage"
}
}
}
Name and description are quite easy to understand. Path is where this pack will be installed on the etc/packs directory for the user (and where it will be push in the community website). It can be a full path, like os/unix/ if you want.
Macros is a hash map of macro names with two values: type and description. Type can be in “string” or “percent” from now. It will give a simple input in SkonfUI for the SNMPCOMMUNITY macro for example, but a “slider” for warning/critical values (so a value between 0 and 100, integer).
How to create a zip pack from a configuration directory?¶
If you push a valid .pack in the configuration directory in etc/packs, you will be able to create a zip pack with the shinken-packs command. Let use again our linux sample. For example, the configuration directory with templates.cfg, commands.cfg, discovery.cfg, the linux.pack file and the services directory is in etc/packs/os/linux.
shinken-packs -c -s /var/lib/shinken/share -p etc/packs/os/linux/linux.pack
It will generate the file /tmp/linux.zip for you. All you need to give to the shinken-packs command is the .pack path, and in option the share path where you have your images and templates directory. The command will automatically parse this directory and take the good image set by looking a the pack name (like configured in the .pack file) and took each template that is available for your commands in the commands.cfg file.
You are done. Your zip pack is done and available in /tmp/linux.zip Congrats! :)