{"id":16660430,"url":"https://github.com/killme2008/clj.monitor","last_synced_at":"2025-09-07T21:03:35.507Z","repository":{"id":3265417,"uuid":"4304415","full_name":"killme2008/clj.monitor","owner":"killme2008","description":"Monitoring applications in clojure based on clojure-control.","archived":false,"fork":false,"pushed_at":"2012-05-12T14:16:05.000Z","size":145,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T18:56:04.072Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/killme2008.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-12T05:39:19.000Z","updated_at":"2015-11-05T01:44:24.000Z","dependencies_parsed_at":"2022-09-10T23:02:16.048Z","dependency_job_id":null,"html_url":"https://github.com/killme2008/clj.monitor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/killme2008/clj.monitor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/killme2008%2Fclj.monitor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/killme2008%2Fclj.monitor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/killme2008%2Fclj.monitor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/killme2008%2Fclj.monitor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/killme2008","download_url":"https://codeload.github.com/killme2008/clj.monitor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/killme2008%2Fclj.monitor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262460689,"owners_count":23314799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T10:29:13.932Z","updated_at":"2025-06-28T16:40:07.465Z","avatar_url":"https://github.com/killme2008.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"#Introduction\n\nMonitoring applications in clojure based on [clojure-control](https://github.com/killme2008/clojure-control/).\n\n#Leiningen dependency\n\n    [clj.monitor \"1.0.0-beta\"]\n\n#Setup SSH\n\nYou must install a ssh agent on the machine where your `clj.monitor` runs on.\nAnd then ,you must setup ssh to make sure logining your monitored application server  from  `clj.monitor` machine without typing password.Please see [HOWTO: set up ssh keys](http://pkeck.myweb.uga.edu/ssh/).\n\n#Getting started\n\nUse `clj.monitor` in your clojure ns:\n\n    \t (ns clj.monitor.example\n             (:use [clj.monitor.core]\n                      [control.core]\n                      [clj.monitor.tasks]))\n\n\nFirst,we define a cluster using [clojure-control](https://github.com/killme2008/clojure-control/) `defcluster`:\n\n\t\t (defcluster mysql\n\t\t    :clients [{:user \"deploy\" :host \"mysql.app.com\"}])\n\nSecond,we define a monitor for `mysql` cluster:\n\n        (defmonitor mysql-monitor\n\t\t     ;;Tasks to monitor mysql,we just ping mysql and make sure that average load in 5 minutes is less than 3\n    \t\t :tasks [(ping-mysql \"root\" \"password\")\n                         (system-load :5 3)]\n\t\t\t ;;Mysql clusters for monitoring\n\t\t\t :clusters [:mysql])\n\nThe  `mysql-monitor` try to ping mysql with `root` and `passowrd` and get average system load in 5 minutes,and execute the task on `mysql` cluster.\n\nAt last,start the monitors:\n\n        (start-monitors\n             :cron \"* 0/5 * * * ?\"\n             :alerts [(mail :from \"alert@app.com\" :to \"yourname@app.com\")]\n             :monitors [mysql-monitor])\n\nIf pinging mysql fails or mysql machine's average load in 5 minutes is greater than 3,it will send an alert email to address `yourname@app.com` from ` alert@app.com`.Monitors will run every five minutes set by `* 0/5 * * * ?` -- a crontab-like string using [Quartz](http://quartz-scheduler.org/).\n\nThe alert message is like:\n      \n      [Alert]:\n\t  {:msyql-monitor\n\t    {\"(system-load :5 3)\"    {\"mysql.app.com\" false},\n         \"(ping-mysql \"root\" \"password)\"    {\"msyql.app.com\" true}}}\n\nIt means that system load in 5 minutes is greater than 3(`false`),but mysql is still alive(`true`).\n\n#Pre-defined tasks and alerts\n\n##Tasks\n\n* (ping-mysql \"user\" \"pass\"): `mysqladmin -u user -p'pass' ping`, make sure that returns mysql is alive.\n* (mysql-slave-status \"user\" \"pass\"): `mysql -u user -p'pass' -e 'show slave status\\G'` ,and make sure that it returns two `YES`.\n* (count-process \"process\" min): `ps aux |grep [process] |grep -v -c grep`,make sure the returned number is greater than min.\n* (service-status \"app\" sudo \"error\"): `sudo /etc/init.d/app status` ,make sure the returned output doesn't contains the error string.`sudo` is a boolean value to set whether running with sudo.\n* (ping-redis \"redis://host:port\"): use redis ping command to ping redis,make sure it returns `PONG`.\n* (system-load kind max): `uptime`,  the `kind` is `:1`,`:5` or `:15`,make sure that system average load in 1,5,15 minutes is less than max value.\n\nYou can define your own tasks by `deftask` in clojure-control,pelase see [Define tasks](https://github.com/killme2008/clojure-control/wiki/Define-tasks).\n\n##Alerts\n\n* (mail :from from :to to [:subject subject :body body]): send alert messages as email.When you set body,the email body will be replaced by your setting instead of alert messages.\n* (console): write alert messages to console\n* (log):  write alert messages to log using tools.logging.\n\nYou can install your own alert function by `clj.monitor.alerts/install-alert-fn`:\n\n    \t  (use '[clj.monitor.alerts :only [install-alert-fn]])\n          (install-alert-fn :name (fn [rt \u0026 args] (println rt)))\n\n#API document\n\n* [API document](http://fnil.net/clj.monitor)\n\n#License\n\nMIT licensed,the same with [clojure-control](https://github.com/killme2008/clojure-control/).\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkillme2008%2Fclj.monitor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkillme2008%2Fclj.monitor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkillme2008%2Fclj.monitor/lists"}