Plugin Development
QNotifier supports user defined plugins to extend its capability. With this ability you can monitor and alert on pretty much anything on your system.
Location
- User generated plugins should be placed in /var/lib/qnotifier/plugins
Plugin Structure
- A plugin must subclass Qnotifier::Plugin and contain a main method and an initializer.
Here's a basic plugin that counts the number of processes on the system:
module Qnotifier
class Iostat < Qnotifier::Plugin
def main
processes = ps -ef
if processes
process_count = processes.split("/n").count
stat("Count", process_count)
report("Count", process_count)
if process_count > 100
alert("Count", "There are more than 100 processes running")
else
reset_alert("Count", "There are now under 100 processes running")
end
else
Qnotifier.log.error "Couldn't get output from the ps command"
end
end
end
end
Methods:
stat(key, value)
Will update the stat for key with value on the server. Value is a text field that will appear next to the property in the stats portion of the client.
report(key, value)
Will create a datapoint for graphs for the associated key. Value is a float or integer.
alert(key, message)
Sends a push notification for the specified key with the message string.
reset_alert(key, message)
Resets an alert, key must match the alert that it is associated with.
put(key, value)
Puts a value string in the saved variables to be retrieved on a subsequent run by get.
get(key)
Retrieves a stored value by key.
Submit your plugin to support@qnotifier.com if you feel like sharing it with others!