1 -- Authors: Voker57 <voker57@gmail.com>
2 -- License: Public domain
3 -- Last Changed: Unknown
7 -- %drives - list of currently connected drives
9 -- by Voker57 <voker57@gmail.com>
16 local settings
=table.join(statusd
.get_config("drives"), defaults
)
20 local function get_drives()
21 local lsres
= io
.popen("ls /dev/sd* | sort")
25 local function update_drives()
26 local drives_list
= get_drives()
27 local drive_table
= {}
28 for drive
in drives_list
do
29 if drive
:match("/([^/]+)$") then
30 local drive_name
= drive
:match("/([^/]+)$")
31 local drive_base
= drive_name
:sub(1,3)
32 local drive_partition
= drive_name
:sub(4,-1)
33 if drive_table
[drive_base
] then
34 table.insert(drive_table
[drive_base
], drive_partition
)
36 drive_table
[drive_base
] = {drive_partition
}
40 local result_table
= {}
41 for drive
, partitions
in pairs(drive_table
) do
44 for k
,i
in pairs(partitions
) do
50 result
= result
.."["..parts
:sub(1,-2).."]"
52 table.insert(result_table
, result
)
54 table.sort(result_table
)
55 statusd
.inform("drives", table.concat(result_table
, " "))
56 drives_timer
:set(settings
.update_interval
, update_drives
)
60 drives_timer
=statusd
.create_timer()