htmon-agent 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22ca80734468bbba8b7128f91382ef355e4c1771
4
- data.tar.gz: 253453a217bfd31411829f06dfcb36bbbdb34ae7
3
+ metadata.gz: 151e5abf20a4ecff462a0754648c2b8c6be5c034
4
+ data.tar.gz: c7bf46b420084d8561b72c42108a51bdae31751d
5
5
  SHA512:
6
- metadata.gz: 69aa62359783648f70dc0d674b927511b120605c96ea8726f8457e6776a6f11a341b471313b3f5a3187ae97f8b6c3b8d7704281520c60541151f51d2e0a70048
7
- data.tar.gz: b594ed8078e96d79735dc1e8e1985ccaab492cc405837aa55f389804ea07d2d1424bd16a4173aec3ecf2b78db41af5bebe033bdecc95c01a8f840a8e8abd08c9
6
+ metadata.gz: 0f45355c6e13e88f42d7e017cd853fb1722a4c86625bc1855a89d1fe8b371527e546ea553a7df86117ddcf2aa0a5046b5e24c4ba597f8b485a15204914731cd0
7
+ data.tar.gz: 5c43697c9f8b3ed2fbc44dc38baf43c5fc60b89803a31ec08104e5406aa87b3425c93c29b70694b58e592d0f41c3b30fbd83ddc28995dcaca68f8f1bba738c9c
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Htmon::Agent
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/htmon/agent`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Http Monitoring Agent - Compatible with Htmon ...
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,17 +20,53 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ The binary will create a loop, with should started by using systemd or any other kind of init system.
24
+
25
+ ```bash
26
+ htmon-agent --config /tmp/htmon-agent.conf --api http://basic:auth@htmon.to:3000
27
+ ```
28
+
29
+ The config could looks like the following snipped.
30
+
31
+ ```ruby
32
+ schema = load_schema
33
+
34
+ check interval: 2.seconds do |url|
35
+ push url: :keepalive, expires_after: 10.seconds
36
+ end
37
+
38
+ schema["htmon_processes"].to_a.each do |process|
39
+ check interval: 1.minute do |url|
40
+ push metric: "process::#{process}",
41
+ expires_after: 2.minutes,
42
+ value: `pgrep -fla #{process.inspect} | grep -v pgrep | wc -l`.strip
43
+ end
44
+ end
45
+ ```
46
+
47
+ Sample service file:
26
48
 
27
- ## Development
49
+ ```bash
50
+ >>> systemctl cat htmon-agent
28
51
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
52
+ # /etc/systemd/system/htmon-agent.service
53
+ [Unit]
54
+ Description=Htmon Agent
55
+ After=network-online.target
30
56
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+ [Service]
58
+ User=root
59
+ ExecStart=/usr/bin/htmon-agent --config /etc/htmon-agent.conf --api http://test:moo@rails.moo.gl:3000
60
+ RestartSec=60
61
+ Restart=always
62
+
63
+ [Install]
64
+ WantedBy=multi-user.target
65
+ ```
32
66
 
33
67
  ## Contributing
34
68
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/htmon-agent.
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/timmyArch/htmon-agent.
36
70
 
37
71
 
38
72
  ## License
@@ -1,5 +1,5 @@
1
1
  module Htmon
2
2
  module Agent
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
data/lib/htmon/agent.rb CHANGED
@@ -45,6 +45,11 @@ def check interval: 60, &block
45
45
  Htmon::Agent.checks << Htmon::Agent::Check.new(block, interval)
46
46
  end
47
47
 
48
+ def load_schema hostname: `hostname`
49
+ JSON.parse RestClient.get(Htmon::Agent.remote+
50
+ "schema?"+({hostname: hostname}).to_param)
51
+ end
52
+
48
53
  def push url: nil, metric: nil, expires_after: nil, value: nil,
49
54
  hostname: `hostname`.strip
50
55
  logger = Logger.new(STDOUT)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htmon-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Foerster
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-10 00:00:00.000000000 Z
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler