Home > developer > content development > Add Monitors
Adding a monitor is specific to each component. These steps are very generic and only give an overview of what to do if a new monitor needs to be added to a component:
Go to the pack where you want to add the monitor.
:monitors => {
'Log' => {:description => 'Log',
:source => '',
:chart => {'min' => 0, 'unit' => ''},
:cmd => 'check_logfiles!logtomcat!#{cmd_options[:logfile]}!#{cmd_options[:warningpattern]}!#{cmd_options[:criticalpattern]}',
:cmd_line => '/opt/nagios/libexec/check_logfiles --noprotocol --tag=$ARG1$ --logfile=$ARG2$ --warningpattern="$ARG3$" --criticalpattern="$ARG4$"'
:cmd_options => {
'logfile' => '/var/log/tomcat6/catalina.out',
'warningpattern' => 'WARNING',
'criticalpattern' => 'CRITICAL'
}, :metrics => {
'logtomcat_lines' => metric(:unit => 'lines', :description => 'Scanned Lines', :dstype => 'GAUGE'),
'logtomcat_warnings' => metric(:unit => 'warnings', :description => 'Warnings', :dstype => 'GAUGE'),
'logtomcat_criticals' => metric(:unit => 'criticals', :description => 'Criticals', :dstype => 'GAUGE'),
'logtomcat_unknowns' => metric(:unit => 'unknowns', :description => 'Unknowns', :dstype => 'GAUGE')
}, :thresholds => {
'CriticalLogException' => threshold('15m', 'avg', 'logtomcat_criticals', trigger('>=', 1, 15, 1), reset('<', 1, 15, 1)),
}
},
}
For adding to existing directories :
“template/default”
in Zookeeper Oneops pack in the zookeeper component and add your script file with the extension of filename.extn.erb
"packer/components/cookbooks/zookeeper/recipes/add.rb"
. This is used to copy your .erb
file in the /opt/nagios/libexec
and nagios will read from there.template "/opt/nagios/libexec/check_zk.py" do
source "check_zk.py.erb"
mode 0755
owner "oneops"
group "oneops"
end
check_zk.py
is the name of the script.
"packs/platform/zookeeper.rb"
'zookeepernode' => {:description => 'ZookeeperNode',
:source => '',
:chart => {'min' => '0', 'max' => '100', 'unit' => 'Percent'},
:cmd => 'check_zk',
:cmd_line => '/opt/nagios/libexec/check_zk.py',
:metrics => {
'up' => metric(:unit => '%', :description => 'Percent Up'),
},
:thresholds => {
'ZookeeperProcessDown' => threshold('1m', 'avg', 'up', trigger('<', 90, 1, 1), reset('>', 90, 1, 1))
}
}
LOG Format:
if [ $ec != 0 ]; then
echo "$1 down |up=0"
else
echo "$1 up |up=100"
fi