Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
picomon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
arn
picomon
Commits
96909d62
Commit
96909d62
authored
Aug 23, 2014
by
Jonathan Michalon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to choose the config file
parent
852ab9cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
9 deletions
+26
-9
picomon.py
picomon.py
+26
-9
No files found.
picomon.py
View file @
96909d62
...
...
@@ -2,8 +2,10 @@ import concurrent.futures
import
signal
import
argparse
import
logging
import
importlib
import
sys
import
os
from
time
import
sleep
import
config
as
user_config
from
lib
import
config
from
lib
import
mails
from
datetime
import
datetime
,
timedelta
...
...
@@ -46,14 +48,6 @@ def alarm_handler(signum, frame):
if
__name__
==
'__main__'
:
# register signal handling
signal
.
signal
(
signal
.
SIGUSR1
,
usr1_handler
)
signal
.
signal
(
signal
.
SIGALRM
,
alarm_handler
)
# register report signal interval
if
config
.
emails
.
report
.
every
>
0
:
signal
.
setitimer
(
signal
.
ITIMER_REAL
,
config
.
emails
.
report
.
every
,
config
.
emails
.
report
.
every
)
# Parse command line
parser
=
argparse
.
ArgumentParser
()
...
...
@@ -64,14 +58,37 @@ if __name__ == '__main__':
parser
.
add_argument
(
"-D"
,
"--debug"
,
help
=
"Set verbosity to DEBUG"
,
action
=
"store_true"
)
parser
.
add_argument
(
"-c"
,
"--config"
,
help
=
"Set config file (defauts to config.py)"
,
default
=
'config.py'
)
args
=
parser
.
parse_args
()
# import config file module
try
:
sys
.
path
.
append
(
os
.
path
.
dirname
(
args
.
config
))
filename
=
os
.
path
.
basename
(
args
.
config
)
base
,
ext
=
os
.
path
.
splitext
(
filename
)
importlib
.
import_module
(
base
)
except
ImportError
as
e
:
logging
.
critical
(
"Cannot load config from '%s': %s"
%
(
args
.
config
,
str
(
e
)))
sys
.
exit
(
1
)
# Configure logging
logging
.
basicConfig
(
format
=
'%(asctime)s %(levelname)s: %(message)s'
,
level
=
config
.
verb_level
)
if
args
.
debug
:
logging
.
getLogger
().
setLevel
(
'DEBUG'
)
# register signal handling
signal
.
signal
(
signal
.
SIGUSR1
,
usr1_handler
)
signal
.
signal
(
signal
.
SIGALRM
,
alarm_handler
)
# register report signal interval
if
config
.
emails
.
report
.
every
>
0
:
signal
.
setitimer
(
signal
.
ITIMER_REAL
,
config
.
emails
.
report
.
every
,
config
.
emails
.
report
.
every
)
# do the actual polling
with
concurrent
.
futures
.
ThreadPoolExecutor
(
max_workers
=
5
)
as
executor
:
def
runner
(
check
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment