-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.grading.py
42 lines (28 loc) · 1.01 KB
/
2.grading.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/env python
# Story:
# Using the sysctl tool, set the system wide file descriptor limit to 131070 and ensure that the value is applied on boot.
from shell import ex, pipe_all
from tool import *
class Run(Router):
def check(self):
if self.platform.startswith('Ubuntu'): sysctl = '/sbin/sysctl'
else: sysctl = '/usr/sbin/sysctl'
out = pipe_all(['{} -a'.format(sysctl), 'grep "fs\.file-max =.*"']).stdout()
for l in out.splitlines():
k, v = l.strip().split(' = ')
if v == '131070':
return True
else:
return False
def common(self):
r1 = self.check()
assert ex('systemctl stop systemd-sysctl.service').re() == 0
assert ex('systemctl start systemd-sysctl.service').re() == 0
if self.check() and r1: success()
else: fail()
def Ubuntu(self):
r1 = self.check()
assert ex('start procps').re() == 0
if self.check() and r1: success()
else: fail()
Run()