Skip to content

Commit 5f53c21

Browse files
committed
Initial import of the RubySyslog server.
0 parents  commit 5f53c21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+6324
-0
lines changed

LICENSE

+674
Large diffs are not rendered by default.

README

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# The Ruby Syslog Server
2+
#
3+
# Author:: Jonathan Gnagy (mailto:[email protected])
4+
# Copyright:: Copyright (c) 2010
5+
# License:: Distributed under the GPLv3 ( http://www.gnu.org/licenses/gpl.html )
6+
#
7+
# Usage:
8+
# #!/usr/bin/env ruby
9+
# require 'parser'
10+
# require 'storage'
11+
# require 'server'
12+
# require 'yaml'
13+
#
14+
# config = YAML.load_file('config.yaml')
15+
#
16+
# server = RubySyslog::Server.new(config)
17+
# server.start
18+
#
19+
# while !server.stopped? or server.logs_queued? do
20+
# sleep(1)
21+
# server.process_logs
22+
# end
23+
#
24+
# server.shutdown

Rakefile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'active_record'
2+
require 'yaml'
3+
4+
task :default => :migrate
5+
6+
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
7+
task :migrate => :environment do
8+
ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
9+
end
10+
11+
task :environment do
12+
config = YAML::load_file('config.yaml')
13+
#puts config.to_yaml
14+
ActiveRecord::Base.establish_connection(config[:db])
15+
ActiveRecord::Base.logger = Logger.new(File.open('database.log', 'a'))
16+
end

config.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
:db:
2+
adapter: mysql
3+
database: syslog_development
4+
username: root
5+
#password:
6+
host: localhost
7+
pool: 15
8+
timeout: 5000
9+
:protocol: both
10+
:port: 9514
11+
:process_threads: 20
12+
:storage_threads: 10 # should be 1 for sqlite3
13+
:verbose: true

db/migrate/001_create_logs.rb

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class CreateLogs < ActiveRecord::Migration
2+
def self.up
3+
create_table :logs do |t|
4+
t.string :hostname
5+
t.text :msg
6+
t.integer :facility
7+
t.integer :severity
8+
9+
t.timestamps
10+
end
11+
12+
add_index :logs, [:hostname, :facility, :severity]
13+
end
14+
15+
def self.down
16+
drop_table :logs
17+
end
18+
end

doc/classes/CreateLogs.html

+152
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
<?xml version="1.0" encoding="iso-8859-1"?>
2+
<!DOCTYPE html
3+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5+
6+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7+
<head>
8+
<title>Class: CreateLogs</title>
9+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
11+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12+
<script type="text/javascript">
13+
// <![CDATA[
14+
15+
function popupCode( url ) {
16+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17+
}
18+
19+
function toggleCode( id ) {
20+
if ( document.getElementById )
21+
elem = document.getElementById( id );
22+
else if ( document.all )
23+
elem = eval( "document.all." + id );
24+
else
25+
return false;
26+
27+
elemStyle = elem.style;
28+
29+
if ( elemStyle.display != "block" ) {
30+
elemStyle.display = "block"
31+
} else {
32+
elemStyle.display = "none"
33+
}
34+
35+
return true;
36+
}
37+
38+
// Make codeblocks hidden by default
39+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40+
41+
// ]]>
42+
</script>
43+
44+
</head>
45+
<body>
46+
47+
48+
49+
<div id="classHeader">
50+
<table class="header-table">
51+
<tr class="top-aligned-row">
52+
<td><strong>Class</strong></td>
53+
<td class="class-name-in-header">CreateLogs</td>
54+
</tr>
55+
<tr class="top-aligned-row">
56+
<td><strong>In:</strong></td>
57+
<td>
58+
<a href="../files/db/migrate/001_create_logs_rb.html">
59+
db/migrate/001_create_logs.rb
60+
</a>
61+
<br />
62+
</td>
63+
</tr>
64+
65+
<tr class="top-aligned-row">
66+
<td><strong>Parent:</strong></td>
67+
<td>
68+
ActiveRecord::Migration
69+
</td>
70+
</tr>
71+
</table>
72+
</div>
73+
<!-- banner header -->
74+
75+
<div id="bodyContent">
76+
77+
78+
79+
<div id="contextContent">
80+
81+
82+
83+
</div>
84+
85+
<div id="method-list">
86+
<h3 class="section-bar">Methods</h3>
87+
88+
<div class="name-list">
89+
<a href="#M000002">down</a>&nbsp;&nbsp;
90+
<a href="#M000001">up</a>&nbsp;&nbsp;
91+
</div>
92+
</div>
93+
94+
</div>
95+
96+
97+
<!-- if includes -->
98+
99+
<div id="section">
100+
101+
102+
103+
104+
105+
106+
107+
108+
<!-- if method_list -->
109+
<div id="methods">
110+
<h3 class="section-bar">Public Class methods</h3>
111+
112+
<div id="method-M000002" class="method-detail">
113+
<a name="M000002"></a>
114+
115+
<div class="method-heading">
116+
<a href="CreateLogs.src/M000002.html" target="Code" class="method-signature"
117+
onclick="popupCode('CreateLogs.src/M000002.html');return false;">
118+
<span class="method-name">down</span><span class="method-args">()</span>
119+
</a>
120+
</div>
121+
122+
<div class="method-description">
123+
</div>
124+
</div>
125+
126+
<div id="method-M000001" class="method-detail">
127+
<a name="M000001"></a>
128+
129+
<div class="method-heading">
130+
<a href="CreateLogs.src/M000001.html" target="Code" class="method-signature"
131+
onclick="popupCode('CreateLogs.src/M000001.html');return false;">
132+
<span class="method-name">up</span><span class="method-args">()</span>
133+
</a>
134+
</div>
135+
136+
<div class="method-description">
137+
</div>
138+
</div>
139+
140+
141+
</div>
142+
143+
144+
</div>
145+
146+
147+
<div id="validator-badges">
148+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
149+
</div>
150+
151+
</body>
152+
</html>
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="iso-8859-1"?>
2+
<!DOCTYPE html
3+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5+
6+
<html>
7+
<head>
8+
<title>up (CreateLogs)</title>
9+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11+
</head>
12+
<body class="standalone-code">
13+
<pre><span class="ruby-comment cmt"># File db/migrate/001_create_logs.rb, line 2</span>
14+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">up</span>
15+
<span class="ruby-identifier">create_table</span> <span class="ruby-identifier">:logs</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
16+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">string</span> <span class="ruby-identifier">:hostname</span>
17+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">text</span> <span class="ruby-identifier">:msg</span>
18+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">integer</span> <span class="ruby-identifier">:facility</span>
19+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">integer</span> <span class="ruby-identifier">:severity</span>
20+
21+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">timestamps</span>
22+
<span class="ruby-keyword kw">end</span>
23+
24+
<span class="ruby-identifier">add_index</span> <span class="ruby-identifier">:logs</span>, [<span class="ruby-identifier">:hostname</span>, <span class="ruby-identifier">:facility</span>, <span class="ruby-identifier">:severity</span>]
25+
<span class="ruby-keyword kw">end</span></pre>
26+
</body>
27+
</html>
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="iso-8859-1"?>
2+
<!DOCTYPE html
3+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5+
6+
<html>
7+
<head>
8+
<title>down (CreateLogs)</title>
9+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11+
</head>
12+
<body class="standalone-code">
13+
<pre><span class="ruby-comment cmt"># File db/migrate/001_create_logs.rb, line 15</span>
14+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">down</span>
15+
<span class="ruby-identifier">drop_table</span> <span class="ruby-identifier">:logs</span>
16+
<span class="ruby-keyword kw">end</span></pre>
17+
</body>
18+
</html>

doc/classes/Log.html

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="iso-8859-1"?>
2+
<!DOCTYPE html
3+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5+
6+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7+
<head>
8+
<title>Class: Log</title>
9+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
11+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12+
<script type="text/javascript">
13+
// <![CDATA[
14+
15+
function popupCode( url ) {
16+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17+
}
18+
19+
function toggleCode( id ) {
20+
if ( document.getElementById )
21+
elem = document.getElementById( id );
22+
else if ( document.all )
23+
elem = eval( "document.all." + id );
24+
else
25+
return false;
26+
27+
elemStyle = elem.style;
28+
29+
if ( elemStyle.display != "block" ) {
30+
elemStyle.display = "block"
31+
} else {
32+
elemStyle.display = "none"
33+
}
34+
35+
return true;
36+
}
37+
38+
// Make codeblocks hidden by default
39+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40+
41+
// ]]>
42+
</script>
43+
44+
</head>
45+
<body>
46+
47+
48+
49+
<div id="classHeader">
50+
<table class="header-table">
51+
<tr class="top-aligned-row">
52+
<td><strong>Class</strong></td>
53+
<td class="class-name-in-header">Log</td>
54+
</tr>
55+
<tr class="top-aligned-row">
56+
<td><strong>In:</strong></td>
57+
<td>
58+
<a href="../files/models/log_rb.html">
59+
models/log.rb
60+
</a>
61+
<br />
62+
</td>
63+
</tr>
64+
65+
<tr class="top-aligned-row">
66+
<td><strong>Parent:</strong></td>
67+
<td>
68+
ActiveRecord::Base
69+
</td>
70+
</tr>
71+
</table>
72+
</div>
73+
<!-- banner header -->
74+
75+
<div id="bodyContent">
76+
77+
78+
79+
<div id="contextContent">
80+
81+
82+
83+
</div>
84+
85+
86+
</div>
87+
88+
89+
<!-- if includes -->
90+
91+
<div id="section">
92+
93+
94+
95+
96+
97+
98+
99+
100+
<!-- if method_list -->
101+
102+
103+
</div>
104+
105+
106+
<div id="validator-badges">
107+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
108+
</div>
109+
110+
</body>
111+
</html>

0 commit comments

Comments
 (0)