All Projects → abohmeed → Cronmanager

abohmeed / Cronmanager

A tool for monitoring Linux cron jobs duration and exit status using Node Exporter and Prometheus. Written in Go.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Cronmanager

Awesome Prometheus Alerts
🚨 Collection of Prometheus alerting rules
Stars: ✭ 3,323 (+19447.06%)
Mutual labels:  prometheus, alert
Promtotwilio
Send text messages for Prometheus alerts using Twilio
Stars: ✭ 28 (+64.71%)
Mutual labels:  prometheus, alert
Prometheus
A docker-compose stack for Prometheus monitoring
Stars: ✭ 3,383 (+19800%)
Mutual labels:  prometheus, alert
Slo Generator
Easy setup a service level objective using prometheus
Stars: ✭ 91 (+435.29%)
Mutual labels:  prometheus, alert
Prometheusalert
Prometheus Alert是开源的运维告警中心消息转发系统,支持主流的监控系统Prometheus,Zabbix,日志系统Graylog和数据可视化系统Grafana发出的预警消息,支持钉钉,微信,华为云短信,腾讯云短信,腾讯云电话,阿里云短信,阿里云电话等
Stars: ✭ 822 (+4735.29%)
Mutual labels:  prometheus, alert
Snmp exporter
SNMP Exporter for Prometheus
Stars: ✭ 705 (+4047.06%)
Mutual labels:  prometheus
Fcalertview
FCAlertView is a Flat Customizable AlertView for iOS (Written in Objective C)
Stars: ✭ 777 (+4470.59%)
Mutual labels:  alert
Wmzdialog
功能最多样式最多的弹窗,支持普通/微信底部/日期/地区/日历/选择/编辑/分享/菜单/自定义弹窗等,支持多种动画,链式编程调用(Pop-up windows with the most functions and styles, support normal/WeChat bottom/date/region/calendar/select/edit/share/menu/custom pop-up windows, etc., support multiple animations, chain programming calls)
Stars: ✭ 673 (+3858.82%)
Mutual labels:  alert
Spug
开源运维平台:面向中小型企业设计的轻量级无Agent的自动化运维平台,整合了主机管理、主机批量执行、主机在线终端、文件在线上传下载、应用发布部署、在线任务计划、配置中心、监控、报警等一系列功能。
Stars: ✭ 6,810 (+39958.82%)
Mutual labels:  alert
Ebpf exporter
Prometheus exporter for custom eBPF metrics
Stars: ✭ 829 (+4776.47%)
Mutual labels:  prometheus
Prometheus
Kubernetes Setup for Prometheus and Grafana
Stars: ✭ 824 (+4747.06%)
Mutual labels:  prometheus
Ansible Prometheus
Deploy Prometheus monitoring system
Stars: ✭ 758 (+4358.82%)
Mutual labels:  prometheus
Grpc By Example Java
A collection of useful/essential gRPC Java Examples
Stars: ✭ 709 (+4070.59%)
Mutual labels:  prometheus
Lcactionsheet
一款简约而不失强大的 ActionSheet,微博、微信和 QQ 都采用了极其类似的样式,完全支持 Swift。
Stars: ✭ 809 (+4658.82%)
Mutual labels:  alert
Unsee
Alert dashboard for Prometheus Alertmanager
Stars: ✭ 700 (+4017.65%)
Mutual labels:  prometheus
Django Prometheus
Export Django monitoring metrics for Prometheus.io
Stars: ✭ 823 (+4741.18%)
Mutual labels:  prometheus
Fftoast
A very powerful iOS message notifications and AlertView extensions. It can be easily realized from the top of the screen, the bottom of the screen and the middle of the screen pops up a notification. You can easily customize the pop-up View.
Stars: ✭ 649 (+3717.65%)
Mutual labels:  alert
Notie
🔔 a clean and simple notification, input, and selection suite for javascript, with no dependencies
Stars: ✭ 6,170 (+36194.12%)
Mutual labels:  alert
Spring Petclinic Microservices
Distributed version of Spring Petclinic built with Spring Cloud
Stars: ✭ 814 (+4688.24%)
Mutual labels:  prometheus
Promgen
Promgen is a configuration file generator for Prometheus
Stars: ✭ 754 (+4335.29%)
Mutual labels:  prometheus

Description

CronManager is a tool written in Go that is used as a wrapper to start cron job. The application does the following:

  1. Executes the command
  2. Measures the command execution time
  3. Examines the command exit status The tool uses Node Exporter's TextFile collector to publish the alert to Prometheus.

Requirements

For the tool to work correctly, you need to have Prometheus node exporter installed on the machine with the textfile collector enabled and the directory specified. For example, the node exporter command should be run as follows:

/opt/prometheus/exporters/node_exporter_current/node_exporter --collector.conntrack --collector.diskstats --collector.entropy --collector.filefd --collector.filesystem --collector.loadavg --collector.mdadm --collector.meminfo --collector.netdev --collector.netstat --collector.stat --collector.time --collector.vmstat --web.listen-address=0.0.0.0:9100 --log.level=info --collector.textfile --collector.textfile.directory=/opt/prometheus/exporters/dist/textfile

You can also provide custom collector textfile location using environment variable COLLECTOR_TEXTFILE_PATH

EXPORT COLLECTOR_TEXTFILE_PATH = /custom/path/to/textfile
/opt/prometheus/exporters/node_exporter_current/node_exporter --collector.conntrack --collector.diskstats --collector.entropy --collector.filefd --collector.filesystem --collector.loadavg --collector.mdadm --collector.meminfo --collector.netdev --collector.netstat --collector.stat --collector.time --collector.vmstat --web.listen-address=0.0.0.0:9100 --log.level=info --collector.textfile --collector.textfile.directory=$COLLECTOR_TEXTFILE_PATH

Installation

Build the binary:

env GOOS=linux go build -o cronmanager

Move the program to a directory in your $PATH

sudo mv cronmanager /usr/local/bin/

Usage

The program can be used as follows:

cronmanager -c command -n jobname [ -t time in seconds ] [ -l log file ]

The commandis the only mandatory argument. Notice that you cannot a bash shell or any of its shell built-ins as the command. So, the following examples will not work:

cronmanager -c "echo 'hello' > somefile"
cronmanager -c "command1; command2; command3"

The expected command is a binary file with optional arguments. For example, the following are valid commands for cronmanager:

cronmanager -c "/usr/bin/php /var/www/webdir/console broadcast:entities:updated -e project -l 20000"
cronmanager -c "/usr/bin/python3 /path/to/python_script.py"

Options

-c: The command to execute (required). This parameter is required. Please see the Usage section for caveats.

-n: The job name (required). It's a good practice to append _cron to the job name for easier distinction when viewing the alerts on Prometheus or Graffana.

-t: the time in seconds after which cronmanager will alert that the job is taking more than it should. The default is 3600 seconds (1 hour).

-l: the log file were you want the cron job to write its output. The default is that any output is trashed.

Notice that if don't specify -n followed by a name, the command will default to "Generic" as the job name.

Alerting

For the tool to work, the /opt/prometheus/exporters/dist/textfile/path must exist on the machine with permissions for the user running cronmanager to write to it. This is the default path where the exporter files exist.

Once cronmanager starts a job, it will wait for the specified seconds (using -t or the default 3600 seconds). If the cron is still running, cronmanager writes to a file under the exporters path. The file name consists of the job name followed by the .prom extension. For example, if you run the command like this cronmanager -c "some_command some_arguments" -n "myjob" the following file will be created: /opt/prometheus/exporters/dist/textfile/myjob.prom. The contents of the file are as follows:

# TYPE cron_job gauge
cron_job{"name=cron1","dimension=failed"} 0
cron_job{"name=cron1","dimension=delayed"} 0
cron_job{"name=cron1","dimension=duration"} 10

The numbers change to 1 depending on the issue found with the cron job (delayed/failed or both).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].