{"id":1294,"date":"2009-10-12T20:55:34","date_gmt":"2009-10-13T01:55:34","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=1294"},"modified":"2013-02-05T10:16:43","modified_gmt":"2013-02-05T15:16:43","slug":"using-nagios","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=1294","title":{"rendered":"Using Nagios"},"content":{"rendered":"<div class='toc wptoc'>\n<h2>Contents<\/h2>\n<ol class='toc-odd level-1'>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Terminology\">Terminology<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Soft_and_Hard_States\">Soft and Hard States<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Configuration\">Configuration<\/a>\n\t\t\t\t<ol class='toc-odd level-3'>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#etcnagiosnagios.cfg\">\/etc\/nagios\/nagios.cfg<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t<\/ol>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Web_Interfaces\">Web Interfaces<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Plugins\">Plugins<\/a>\n\t\t\t\t<ol class='toc-odd level-3'>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_ping\">check_ping<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_tcp\">check_tcp<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_pop_check_spop_check_imap_check_simap\">check_pop, check_spop, check_imap, check_simap<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_smtp\">check_smtp<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_ftp\">check_ftp<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_dhcp\">check_dhcp<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_nagios\">check_nagios<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_http\">check_http<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_mysql\">check_mysql<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_pgsql\">check_pgsql<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_oracle\">check_oracle<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_swap\">check_swap<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_ide_smart\">check_ide_smart<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_disk\">check_disk<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_disk_smb\">check_disk_smb<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_disk_1\">check_disk<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#check_procs\">check_procs<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#Monitor_Logged_In_User\">Monitor Logged In User<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t<\/ol>\n<\/ol>\n\t\t\t<li>\n\t\t\t\t<a href=\"#References\">References<\/a>\n\t\t\t<\/li>\n<\/ol>\n<\/div>\n<div class='wptoc-end'>&nbsp;<\/div>\n<span id=\"Terminology\"><h2>Terminology<\/h2><\/span>\n<p>* Commands<br \/>\n* Time periods<br \/>\n* Contacts and Contact Groups<br \/>\n* Host<br \/>\n* Services<br \/>\n* Host and service escalations<\/p>\n<span id=\"Soft_and_Hard_States\"><h2>Soft and Hard States<\/h2><\/span>\n<p>* Defines how many retries before escalate soft to hard state<\/p>\n<span id=\"Configuration\"><h2>Configuration<\/h2><\/span>\n<span id=\"etcnagiosnagios.cfg\"><h3>\/etc\/nagios\/nagios.cfg<\/h3><\/span>\n<span id=\"Web_Interfaces\"><h2>Web Interfaces<\/h2><\/span>\n<p>* Tactical Overview<br \/>\n* Status Map<br \/>\n* Host information<\/p>\n<span id=\"Plugins\"><h2>Plugins<\/h2><\/span>\n<span id=\"check_ping\"><h3>check_ping<\/h3><\/span>\n<pre lang=\"bash\">\r\n# Command. -H: host, \r\n# -w: warn, wrta: warn return time average, wpl%: warn packet loss percentage\r\n# -c: cirtical, -crta: critial return time average, cpl%: critical packet loss percentage\r\n# -p packet, -t timeout\r\n# -4|-6: ipv4 or ipv6\r\ncheck_ping -H <host_address> -w <wrta>,<wpl>% -c <crta>,<cpl>% [-p packets] [-t timeout] [-4|-6]\r\n\r\n# For example, ping localhost with 5 packets, \r\n# warn if 1 packet returns in 3 seconds, \r\n# Output critical if 0 packet returns in 5 seconds:\r\n$ check_ping -H localhost -w 3000.0,80% -c 5000.0,100% -p 5\r\nPING OK - Packet loss = 0%, RTA = 0.06 ms|rta=0.058000ms;3000.000000;5000.000000;0.000000 pl=0%;80;100;0\r\n<\/pre>\n<span id=\"check_tcp\"><h3>check_tcp<\/h3><\/span>\n<pre lang=\"bash\">\r\ncheck_tcp|check_udp -H host -p port [-w <warning >] [-c <critical >]\r\n           [-s <send string>] [-e <expect string>] [-q <quit string>]\r\n           [-A] [-m <maximum bytes>] [-d <delay>] [-t <timeout>]\r\n           [-r <refuse state>] [-M <mismatch state>] [-v] [-4|-6] \r\n           [-j] [-D <days to cert expiry>] [-S] [-E]\r\n\r\n# For example, check localhost on port 80\r\ncheck_tcp -H localhost -p 80\r\nTCP OK - 0.000 second response time on port 80|time=0.000220s;;;0.000000;10.000000\r\n<\/pre>\n<span id=\"check_pop_check_spop_check_imap_check_simap\"><h3>check_pop, check_spop, check_imap, check_simap<\/h3><\/span>\n<p>* Similar to check_tcp<\/p>\n<pre lang=\"bash\">\r\n<\/pre>\n<span id=\"check_smtp\"><h3>check_smtp<\/h3><\/span>\n<p>* Similar to check_tcp<br \/>\n* Port defaults to 25 <\/p>\n<pre lang=\"bash\">\r\ncheck_smtp -H host [-p port] [-C command] [-R response] [-f from addr]\r\n           [-F hostname] [-A authtype \u2013U authuser \u2013P authpass]\r\n           [-w <warning time>] [-c <critical time>] [-t timeout]\r\n           [-S] [-D days] [-n] [-4|-6]\r\ncheck_smtp -H smtp.my.com -p 25\r\n<\/pre>\n<span id=\"check_ftp\"><h3>check_ftp<\/h3><\/span>\n<p>* Similar to check_tcp<br \/>\n* Port defaults to 21 ot 990 for ssl<br \/>\n* Expect standard FTP welcome message<\/p>\n<pre lang=\"bash\">\r\ncheck_ftp -H ftp.my.com\r\n<\/pre>\n<span id=\"check_dhcp\"><h3>check_dhcp<\/h3><\/span>\n<span id=\"check_nagios\"><h3>check_nagios<\/h3><\/span>\n<span id=\"check_http\"><h3>check_http<\/h3><\/span>\n<pre lang=\"bash\">\r\ncheck_http -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\r\n           [-w <warning time>] [-c <critical time>] [-t <timeout>]  \r\n           [-L] [-a auth] [-f <ok | warn | critcal | follow>]  \r\n           [-e <expect>] [-s string] [-l]  \r\n           [-r <regex> | -R <regex>] [-P string]\r\n           [-m <min_pg_size>:<max_pg_size>]  \r\n           [-4|-6] [-N] [-M <age>] [-A string] [-k string] [-S]  \r\n           [-C <age>] [-T <content-type>]\r\n# Examples\r\ncheck_http -H www.yahoo.com -p 80\r\ncheck_http -H coe-soa-1 -p 9900 -u \/ms\/index.do\r\n<\/pre>\n<span id=\"check_mysql\"><h3>check_mysql<\/h3><\/span>\n<pre lang=\"bash\">\r\ncheck_mysql [-H host] [-d database] [-P port]\r\n            [-u user] [-p password] [-S]\r\n\r\ncheck_mysql_query -q SQL_query [-w <warn>] [-c <crit>] [-d database]\r\n                  [-H host] [-P port] [-u user] [-p password]\r\n<\/pre>\n<span id=\"check_pgsql\"><h3>check_pgsql<\/h3><\/span>\n<pre lang=\"bash\">\r\n check_pgsql [-H <host>] [-P <port>] [-w <warn>] [-c <crit>]\r\n             [-t <timeout>] [-d <database>] [-l <logname>]  \r\n             [-p <password>]\r\n<\/pre>\n<span id=\"check_oracle\"><h3>check_oracle<\/h3><\/span>\n<p>* Need Oracle client installation (tnsping)<\/p>\n<pre lang=\"bash\">\r\ncheck_oracle --tns <ORACLE_SID>\r\n             --db <ORACLE_SID>\r\n             --oranames <Hostname>\r\n             --login <ORACLE_SID>\r\n             --cache <ORACLE_SID> <USER> <PASS> <CRITICAL> <WARNING>\r\n             --tablespace <ORACLE_SID> <USER> <PASS>\r\n                          <TABLESPACE> <CRITICAL> <WARNING>\r\n<\/pre>\n<span id=\"check_swap\"><h3>check_swap<\/h3><\/span>\n<p>Check virtual memory.<\/p>\n<pre lang=\"bash\">\r\ncheck_swap [-a] [-v] -w limit -c limit\r\n# -a: all\r\n# -w limit: warn if swap fall below limit\r\n# -c limit: critical if swap fall below limit\r\n<\/pre>\n<span id=\"check_ide_smart\"><h3>check_ide_smart<\/h3><\/span>\n<pre lang=\"bash\">\r\ncheck_ide_smart [-d <device>] [-i] [-q] [-1] [-O] [-n]\r\n<\/pre>\n<span id=\"check_disk\"><h3>check_disk<\/h3><\/span>\n<p>Check disk space.<\/p>\n<pre lang=\"bash\">\r\ncheck_disk \r\n  -w limit # warn if below limit\r\n  -c limit  # critical if below limit\r\n  [-W limit] # warn if inode below limit\r\n  [-K limit] # critical if inode below limit\r\n  {-p path # -p path or partition, can be repeated\r\n              | -x device} # -x exclude path\r\n  [-C] # clear thresholds\r\n  [-E] # only checks for exact path as specified by -p\r\n  [-e] # displays errors only\r\n  [-g group ] \r\n  [-k] # kb\r\n  [-l] # check local file system only\r\n  [-M] # displays mount point instead of path\r\n  [-m] # mb\r\n  [-r path ] # regex for path\/partition, can be repeated\r\n  [-R path ] # as -r but case insensitive\r\n  [-t timeout] # in seconds, default to 10\r\n  [-u unit] #  bytes, kB, MB, GB, TB, default to MB\r\n  [-v] # verbose\r\n  [-X type] # exclude file type, can be repeated\r\n\r\n# Examples\r\ncheck_disk -w 500 -c 10 -p \/tmp\r\nDISK OK - free space: \/tmp 4449 MB (96% inode=99%);| \/tmp=140MB;4340;4830;0;4840\r\n<\/pre>\n<span id=\"check_disk_smb\"><h3>check_disk_smb<\/h3><\/span>\n<p>Check disk space on remote shares.<\/p>\n<pre lang=\"bash\">\r\ncheck_disk_smb -H <host> -s <share> -u <user> -p <password> \r\n      -w <warn> -c <crit> [-W <workgroup>] [-P <port>]\r\n<\/pre>\n<span id=\"check_disk_1\"><h3>check_disk<\/h3><\/span>\n<p>Check system load.<\/p>\n<pre lang=\"bash\">\r\ncheck_load \r\n  [-r] # divide load average by number of CPUs\r\n  -w WLOAD1,WLOAD5,WLOAD15 # warn if load averages exceed 1, 5, 15 min averages\r\n  -c CLOAD1,CLOAD5,CLOAD15 # critical if load averages exceed 1, 5,, 15 min averages\r\n\r\n# Example, warn if 1min load average exceeds 10, 5min 8, 15min 5\r\n# critical if 1min load average exceeds 15, 5min 10, 15min 8\r\ncheck_load -w 10.0,8.0,5.0 -c 15.0,10.0,8.0\r\n<\/pre>\n<span id=\"check_procs\"><h3>check_procs<\/h3><\/span>\n<pre lang=\"bash\">\r\ncheck_procs \r\n  -w <range> # warn if outside range\r\n  -c <range>  # critical if outside range\r\n  [-m metric] # metric type: PROCS, VSZ, RSS, CPU, ELAPSED\r\n  [-s state] # only scan for processes with one or more status flags form ps command\r\n  [-p ppid] # only scan for child processes of parent ppid \r\n  [-u user] # only scan for user or user id\r\n  [-r rss] # only scan for processes with rss higher than indicated\r\n  [-z vsz] # only scan for processes with vsz higher than indicated\r\n  [-P %cpu] # only scan for processes with pcpu higher than indicated\r\n  [-a argument-array] # only scan for processes with args that contain string\r\n  [-C command] # only scan for exact matches of command\r\n  [-t timeout] # timeout\r\n  [-v]\r\n\r\n# Example\r\n# Alert if CPU of any processes over 10% or 20%\r\ncheck_procs -w 10 -c 20 --metric=CPU\r\n<\/pre>\n<span id=\"Monitor_Logged_In_User\"><h3>Monitor Logged In User<\/h3><\/span>\n<pre lang=\"bash\">\r\ncheck_users -w limit -c limit\r\n\r\n# Example, warn if one user logged in, critical if 1 user logged in\r\ncheck_users -w 0 -c 1\r\n#USERS WARNING - 1 users currently logged in |users=1;0;1;0\r\n<\/pre>\n<span id=\"References\"><h1>References<\/h1><\/span>\n<p><a href=\"http:\/\/www.debianhelp.co.uk\/nagiosinstall.htm\">http:\/\/www.debianhelp.co.uk\/nagiosinstall.htm<\/a><br \/>\nLearning Nagios 3.0: A Detailed Tutorial to Setting Up, Configuring, and Managing This Easy and Effective System Monitoring Software by Wojciech Kocjan<br \/>\n<a href=\"http:\/\/nagios.sourceforge.net\/docs\/3_0\/toc.html\">http:\/\/nagios.sourceforge.net\/docs\/3_0\/toc.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Terminology * Commands * Time periods * Contacts and Contact Groups * Host * Services * Host and service escalations Soft and Hard States * Defines how many retries before escalate soft to hard state Configuration \/etc\/nagios\/nagios.cfg Web Interfaces * &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=1294\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[62],"tags":[63],"class_list":["post-1294","post","type-post","status-publish","format-standard","hentry","category-infra","tag-nagios"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-kS","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1294"}],"version-history":[{"count":7,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1294\/revisions"}],"predecessor-version":[{"id":7185,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1294\/revisions\/7185"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}