Skip to content

Commit 5d12a43

Browse files
committed
First commit
0 parents  commit 5d12a43

22 files changed

+1151
-0
lines changed

.gitignore

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
5+
# C extensions
6+
*.so
7+
compilation/
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
47+
# Translations
48+
*.mo
49+
*.pot
50+
51+
# Django stuff:
52+
*.log
53+
54+
# Sphinx documentation
55+
docs/_build/
56+
57+
# PyBuilder
58+
target/

Output/amon-agent-1.1.exe

7.88 MB
Binary file not shown.

Output/amon-agent.exe

7.88 MB
Binary file not shown.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Amon Monitoring Agent for Windows
2+
3+
## Build
4+
5+
```
6+
pyinstaller.exe --onefile --icon=amon.ico --version-file=version.txt amonagent/amon-agent.py
7+
```

amon-agent.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Main]
2+
amon_url=
3+
server_key=

amon-agent.iss

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
; Script generated by the Inno Setup Script Wizard.
2+
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
3+
4+
#define NSSM "nssm.exe"
5+
#define AmonServiceName "AmonAgent"
6+
#define AmonApp "amon-agent.exe"
7+
8+
9+
[Setup]
10+
; NOTE: The value of AppId uniquely identifies this application.
11+
; Do not use the same AppId value in installers for other applications.
12+
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
13+
AppId={{33541FBB-1B7C-4C64-8902-420ACE513DF9}
14+
AppName=amon-agent
15+
AppVersion=1.1
16+
;AppVerName=amon-agent 1.0
17+
AppPublisher=Simplistic LLC
18+
AppPublisherURL=https://amon.cx
19+
AppSupportURL=https://amon.cx
20+
AppUpdatesURL=https://amon.cx
21+
DefaultDirName={pf}\AmonAgent
22+
DefaultGroupName=amon-agent
23+
OutputBaseFilename=amon-agent-1.1
24+
Compression=lzma
25+
SolidCompression=yes
26+
WizardImageFile=welcome.bmp
27+
DisableDirPage=auto
28+
DisableProgramGroupPage=yes
29+
CloseApplications=yes
30+
RestartApplications=yes
31+
AlwaysRestart=no
32+
UninstallDisplayIcon={app}\amon-agent.exe
33+
PrivilegesRequired=admin
34+
35+
[Languages]
36+
Name: "english"; MessagesFile: "compiler:Default.isl"
37+
38+
[Files]
39+
Source: "dist\amon-agent.exe"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
40+
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
41+
Source: "nssm.exe"; DestDir: "{app}"
42+
Source: "amon-agent.ini"; DestDir: "{app}"; Permissions: everyone-full;
43+
44+
[INI]
45+
Filename: {app}\amon-agent.ini; Section: Main; Key: amon_url; String: {code:GetAmonUrl}
46+
Filename: {app}\amon-agent.ini; Section: Main; Key: server_key; String: {code:GetKey}
47+
48+
[Icons]
49+
Name: "{group}\amon-agent"; Filename: "{app}\amon-agent.exe"
50+
51+
52+
53+
[Run]
54+
; post-install
55+
Filename: "{sys}\msiexec.exe"; Parameters: "/package ""{app}\{#AmonApp}"" /qn /norestart /nocloseapplications /passive"; Flags: shellexec waituntilterminated;
56+
Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall add rule name=""AmonAgent Out"" program=""{app}\{#AmonApp}"" dir=out action=allow enable=yes"; Flags: runhidden;
57+
Filename: "{app}\{#NSSM}"; Parameters: "install {#AmonServiceName} ""{app}\{#AmonApp}"" "; Flags: runhidden;
58+
Filename: "{app}\{#NSSM}"; Parameters: "set {#AmonServiceName} AppDirectory {app}"; Flags: runhidden;
59+
Filename: "{app}\{#NSSM}"; Parameters: "set {#AmonServiceName} AppStdout {userappdata}\Amon\amon.log"; Flags: runhidden;
60+
Filename: "{app}\{#NSSM}"; Parameters: "set {#AmonServiceName} AppStderr {userappdata}\Amon\amon.log"; Flags: runhidden;
61+
Filename: "{app}\{#NSSM}"; Parameters: "start {#AmonServiceName}"; Flags: runhidden;
62+
63+
64+
[UninstallDelete]
65+
Type: filesandordirs; Name: "{app}"
66+
67+
68+
[UninstallRun]
69+
; pre-uninstall
70+
Filename: "{app}\{#NSSM}"; Parameters: "stop {#AmonServiceName}"; Flags: runhidden;
71+
Filename: "{app}\{#NSSM}"; Parameters: "remove {#AmonServiceName} confirm"; Flags: runhidden;
72+
73+
[InstallDelete]
74+
Type: files; Name: "{app}\amon-agent.exe"
75+
76+
[Code]
77+
var
78+
UserPage: TInputQueryWizardPage;
79+
80+
procedure InitializeWizard;
81+
begin
82+
{ Create the pages }
83+
UserPage := CreateInputQueryPage(wpWelcome,
84+
'Amon Information', '',
85+
'Please specify the URL where your Amon instance is running and the agent server key, then click Next.');
86+
UserPage.Add('Amon URL:', False);
87+
UserPage.Add('Server Key:', False);
88+
89+
UserPage.Values[0] := GetIniString('Main', 'amon_url', '', WizardDirValue + '\amon-agent.ini');
90+
UserPage.Values[1] := GetIniString('Main', 'server_key', '', WizardDirValue + '\amon-agent.ini');
91+
end;
92+
93+
function GetAmonUrl(Param: String): string;
94+
begin
95+
result := UserPage.Values[0];
96+
end;
97+
98+
function GetKey(Param: String): string;
99+
begin
100+
result := UserPage.Values[1];
101+
end;
102+
103+
104+
function GetUninstallString: string;
105+
var
106+
sUnInstPath: string;
107+
sUnInstallString: String;
108+
begin
109+
Result := '';
110+
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\33541FBB-1B7C-4C64-8902-420ACE513DF9_is1'); //Your App GUID/ID
111+
sUnInstallString := '';
112+
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
113+
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
114+
Result := sUnInstallString;
115+
end;
116+
117+
function IsUpgrade: Boolean;
118+
begin
119+
Result := (GetUninstallString() <> '');
120+
end;
121+
122+
function InitializeSetup: Boolean;
123+
var
124+
V: Integer;
125+
iResultCode: Integer;
126+
sUnInstallString: string;
127+
begin
128+
Result := True; // in case when no previous version is found
129+
if RegValueExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\33541FBB-1B7C-4C64-8902-420ACE513DF9_is1', 'UninstallString') then //Your App GUID/ID
130+
begin
131+
V := MsgBox(ExpandConstant('An old version of the Amon Agent was detected. Do you want to uninstall it?'), mbInformation, MB_YESNO); //Custom Message if App installed
132+
if V = IDYES then
133+
begin
134+
sUnInstallString := GetUninstallString();
135+
sUnInstallString := RemoveQuotes(sUnInstallString);
136+
Exec(ExpandConstant(sUnInstallString), '', '', SW_SHOW, ewWaitUntilTerminated, iResultCode);
137+
Result := True; //if you want to proceed after uninstall
138+
//Exit; //if you want to quit after uninstall
139+
end
140+
else
141+
Result := False; //when older version present and not uninstalled
142+
end;
143+
end;

amon.ico

97.3 KB
Binary file not shown.

amonagent/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '1.1'

amonagent/amon-agent.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/python
2+
import logging
3+
import sys, time
4+
import os.path
5+
6+
if __package__ is None and not hasattr(sys, "frozen"):
7+
# It is a direct call to __main__.py
8+
9+
path = os.path.realpath(os.path.abspath(__file__))
10+
sys.path.append(os.path.dirname(os.path.dirname(path)))
11+
12+
try:
13+
import amonagent
14+
except:
15+
print 'amonagent is not installed'
16+
sys.exit()
17+
18+
from amonagent import __version__
19+
from amonagent.runner import Runner
20+
from amonagent.remote import Remote
21+
from amonagent.settings import settings
22+
23+
if __name__ == "__main__":
24+
remote = Remote()
25+
runner = Runner()
26+
remote.save_system_info(runner.info())
27+
28+
while True:
29+
runner = Runner()
30+
stats = {
31+
'system': runner.system(),
32+
'processes': runner.processes(),
33+
}
34+
remote.save_system_stats(stats)
35+
time.sleep(settings.SYSTEM_CHECK_PERIOD)

0 commit comments

Comments
 (0)