-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f1b8110
Showing
18 changed files
with
1,672 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.50727</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{2276C92F-8444-47B4-B3C9-AF507C41BB98}</ProjectGuid> | ||
<OutputType>WinExe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Fantail.SyslogServer</RootNamespace> | ||
<AssemblyName>Fantail.SyslogServer</AssemblyName> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Configuration.Install" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Management" /> | ||
<Reference Include="System.ServiceProcess" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="MemoryBuffer.cs" /> | ||
<Compile Include="ProjectInstaller.cs"> | ||
<SubType>Component</SubType> | ||
</Compile> | ||
<Compile Include="ProjectInstaller.Designer.cs"> | ||
<DependentUpon>ProjectInstaller.cs</DependentUpon> | ||
</Compile> | ||
<Compile Include="SqlUpdater.cs" /> | ||
<Compile Include="SyslogListener.cs" /> | ||
<Compile Include="SyslogService.cs"> | ||
<SubType>Component</SubType> | ||
</Compile> | ||
<Compile Include="SyslogService.Designer.cs"> | ||
<DependentUpon>SyslogService.cs</DependentUpon> | ||
</Compile> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="ProjectInstaller.resx"> | ||
<SubType>Designer</SubType> | ||
<DependentUpon>ProjectInstaller.cs</DependentUpon> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
Fantail.SyslogServer | ||
==================== | ||
|
||
Fantail Technology Ltd ( www.fantail.net.nz ) | ||
|
||
Designed by Chris Guthrey & David Husselmann | ||
Developed by David Husselmann for Fantail Technology Ltd | ||
|
||
[email protected] | ||
[email protected] | ||
|
||
Copyright (c) 2007, Fantail Technology Ltd | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
* Neither the name of Fantail Technology Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/// | ||
/// Fantail.SyslogServer | ||
/// ==================== | ||
/// | ||
/// Fantail Technology Ltd ( www.fantail.net.nz ) | ||
/// | ||
/// Designed by Chris Guthrey & David Husselmann | ||
/// Developed by David Husselmann for Fantail Technology Ltd | ||
/// | ||
/// [email protected] | ||
/// [email protected] | ||
/// | ||
/// Copyright (c) 2007, Fantail Technology Ltd | ||
/// | ||
/// All rights reserved. | ||
/// | ||
/// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
/// | ||
/// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
/// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
/// * Neither the name of Fantail Technology Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
/// | ||
/// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
/// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
/// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
/// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
/// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
/// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
/// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
/// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
/// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
/// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
/// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE | ||
/// | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Fantail.Libraries.Syslog; | ||
using System.Timers; | ||
using System.Threading; | ||
|
||
namespace Fantail.Libraries.Syslog { | ||
/// <summary> | ||
/// This class takes care of buffering incoming syslog messages in memory | ||
/// and submitting them to the SqlUpdater in batches, rather than keeping the database | ||
/// occupied with drip-fed messages. | ||
/// </summary> | ||
public class MemoryBuffer { | ||
private List<SyslogMessage> buffer = new List<SyslogMessage>(); | ||
private TimeSpan commitInterval; | ||
private System.Timers.Timer timer = new System.Timers.Timer(); | ||
private SqlUpdater sqlUpdater; | ||
private Mutex bufferLock = new Mutex(false); | ||
|
||
/// <summary> | ||
/// Creates a new instance of the MemoryBuffer class. | ||
/// </summary> | ||
/// <param name="commitInterval">Specifies the interval at which message batches should be committed to the database.</param> | ||
/// <param name="sqlUpdater">The pre-initialised SqlUpdater to which messages should be submitted.</param> | ||
public MemoryBuffer(TimeSpan commitInterval, SqlUpdater sqlUpdater) { | ||
this.commitInterval = commitInterval; | ||
this.timer.Interval = commitInterval.TotalMilliseconds; | ||
this.sqlUpdater = sqlUpdater; | ||
this.timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); | ||
this.timer.Enabled = true; | ||
} | ||
|
||
void timer_Elapsed(object sender, ElapsedEventArgs e) { | ||
Flush(); | ||
} | ||
|
||
/// <summary> | ||
/// Posts a new message to the buffer, for committing to the database when the internal timer elapses. | ||
/// </summary> | ||
/// <param name="sm">The syslog message to be submitted.</param> | ||
public void PushMessage(SyslogMessage sm) { | ||
bufferLock.WaitOne(); | ||
buffer.Add(sm); | ||
bufferLock.ReleaseMutex(); | ||
} | ||
|
||
/// <summary> | ||
/// Flushes the buffer. This method can be called by the user to ensure that final in-memory entries are | ||
/// written to the database. | ||
/// </summary> | ||
public void Flush() { | ||
bufferLock.WaitOne(); | ||
try { | ||
if (sqlUpdater.SaveMessage(buffer)) { | ||
buffer.Clear(); | ||
} | ||
} finally { | ||
bufferLock.ReleaseMutex(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/// | ||
/// Fantail.SyslogServer | ||
/// ==================== | ||
/// | ||
/// Fantail Technology Ltd ( www.fantail.net.nz ) | ||
/// | ||
/// Designed by Chris Guthrey & David Husselmann | ||
/// Developed by David Husselmann for Fantail Technology Ltd | ||
/// | ||
/// [email protected] | ||
/// [email protected] | ||
/// | ||
/// Copyright (c) 2007, Fantail Technology Ltd | ||
/// | ||
/// All rights reserved. | ||
/// | ||
/// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
/// | ||
/// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
/// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
/// * Neither the name of Fantail Technology Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
/// | ||
/// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
/// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
/// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
/// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
/// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
/// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
/// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
/// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
/// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
/// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
/// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE | ||
/// | ||
using System.Collections.Generic; | ||
using System.ServiceProcess; | ||
using System.Text; | ||
|
||
namespace Fantail.SyslogServer { | ||
static class Program { | ||
static void Main() { | ||
ServiceBase[] ServicesToRun; | ||
|
||
ServicesToRun = new ServiceBase[] { new SyslogService() }; | ||
|
||
ServiceBase.Run(ServicesToRun); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Configuration.Install; | ||
|
||
namespace Fantail.SyslogServer { | ||
[RunInstaller(true)] | ||
public partial class ProjectInstaller : Installer { | ||
public ProjectInstaller() { | ||
InitializeComponent(); | ||
} | ||
|
||
private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e) { | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.