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
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/server-status/status_command.rb', line 14
def to_script
parts = []
if @options.os
parts << "lsb_release -d | cut -f2"
end
if @options.uptime
parts << "cat /proc/uptime | cut -d\" \" -f1"
end
if @options.load
parts << "cat /proc/loadavg | cut -d\" \" -f -3"
end
if @options.disk
parts << "df -h | awk '/\\/$/' | sed 's/ \\+/ /g' | cut -d\" \" -f5"
end
if @options.inode
parts << "df -hi | awk '/\\/$/' | sed 's/ \\+/ /g' | cut -d\" \" -f5"
end
if @options.memory
parts << "cat /proc/meminfo | grep -P '^(MemTotal|MemAvailable|MemFree|Cached|Buffers):'"
end
if @options.clock_drift
parts << "ntpdate -q pool.ntp.org | head -1 | cut -d \" \" -f 6 | sed \"s/.$//\""
end
if @options.pkg_updates
parts << "cat /etc/motd || cat /var/run/motd.dynamic || true"
end
if @options.reboot_required
parts << "if [ -f /var/run/reboot-required ]; then echo 1 ; fi"
end
parts.join("\necho '#{SEPARATOR}'\n")
end
|