Info Module

Alfred Botman

Compatibility:

Description

This module plays with registered custom variables.
When run by botman, this module will periodically collect the list of custom variables, and send them to alfred so he can register them for each botman. This allows other modules running on Alfred to have them synced and reuse them.

For example, a module might collect system inforations, and register them as custom variables.
Custom variables being sent to alfred, it would be possible to search for them using alfred.

Configuration

Alfred

You can add custom variables to be searchable as <pattern>.
These variables must be referenced inside the configuration file (/usr/local/etc/gotham/modules.conf.d/info.conf):

{
   "search_vars" : [
      "variable_name"
   ]
}


Query botmans through Alfred

It is possible to make Alfred able to query botmans for you by combining the power of the spam and rewrite modules.
You can add the following JSON object as a new rule of the rewrite module’s configuration file:

{
   "name" : ".info list",
   "filter" : ".info * list",
   "rule" : "sed -r 's/^.info *([^ ]*) list/.spam \\1 .info list/'",
   "description" : ".info <pattern> list"
}, {
   "name" : ".info get",
   "filter" : ".info * get *",
   "rule" : "sed -r 's/^.info *([^ ]*) get (.*)/.spam \\1 .info get \\2/'",
   "description" : ".info <pattern> get <variable>"
}


Commands

The .info command allows you to list every custom variables registered on the botman.
(11:35:51) guillaume.friloux@botnet.master.com: .info
(11:35:51) botman-xxxx: {
   "command":  ".info",
   "parameters":  "",
   "status":   "ok",
   "content":  [
      "version_ecore : 1.7.11_3",
      "version_kernel : 10.1-RELEASE",
      "tunnel_port : 0",
      "version_eet : 1.7.11_1",
      "zpool_status : DEGRADED",
      "version_eio : 1.7.11_3",
      "tunnel_pid : 0",
      "version_botman : 1.2.10_3",
      "sysinfo_serial_number : 928PR4J",
      "sysinfo_manufacturer : Dell Inc.",
      "sysinfo_product_name : OptiPlex 780",
      "version_maelstrom : 0.0.99_6",
      "version_eina : 1.7.11_1"
   ]
}
The .info get variable command allows you to retrieve the value of a given custom variable.
It only exists to make it easier to parse results, especially when using this command through the Spam module
(11:31:31) guillaume.friloux@botnet.master.com: .info get zpool_status
(11:31:31) botman-xxxx: zpool_status : DEGRADED