15 |
rodolico |
1 |
/* find all routers and the software installed on them */
|
|
|
2 |
select
|
|
|
3 |
device.device_id device_id,
|
|
|
4 |
device.name device,
|
|
|
5 |
software.package_name package,
|
|
|
6 |
software.description description,
|
|
|
7 |
software_version.version version
|
|
|
8 |
from
|
|
|
9 |
device
|
|
|
10 |
join device_type using (device_type_id)
|
|
|
11 |
join installed_packages using (device_id)
|
|
|
12 |
join software using (software_id)
|
|
|
13 |
join software_version using (software_version_id)
|
|
|
14 |
where
|
|
|
15 |
device_type.name = 'Router'
|
|
|
16 |
and device.removed_date is null
|
|
|
17 |
and installed_packages.removed_date is null
|
|
|
18 |
;
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
select
|
|
|
22 |
device.device_id device_id,
|
|
|
23 |
device.name device,
|
|
|
24 |
device_type.device_type_id,
|
|
|
25 |
device_type.name device_type,
|
|
|
26 |
software.package_name package,
|
|
|
27 |
software.description description,
|
|
|
28 |
software_version.version version
|
|
|
29 |
from
|
|
|
30 |
device
|
|
|
31 |
join device_type using (device_type_id)
|
|
|
32 |
join installed_packages using (device_id)
|
|
|
33 |
join software using (software_id)
|
|
|
34 |
join software_version using (software_version_id)
|
|
|
35 |
where
|
|
|
36 |
software.package_name in ('ipfire','core-upgrade')
|
|
|
37 |
and device.removed_date is null
|
|
|
38 |
and installed_packages.removed_date is null
|
|
|
39 |
;
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
select distinct(device.device_id)
|
|
|
43 |
from
|
|
|
44 |
device
|
|
|
45 |
join device_operating_system using (device_id)
|
|
|
46 |
join operating_system using (operating_system_id)
|
|
|
47 |
where
|
|
|
48 |
operating_system.kernel like '%ipfire%';
|
|
|
49 |
|
|
|
50 |
select
|
|
|
51 |
device.name as 'Device',
|
|
|
52 |
client.name as 'Client',
|
|
|
53 |
maintenance_task.description as 'Task',
|
|
|
54 |
maintenance_schedule.schedule as schedule,
|
|
|
55 |
date_format(max(maintenance_performed.maintenance_date),'%Y-%m-%d') as 'Last Performed',
|
|
|
56 |
date_format(adddate(max(maintenance_performed.maintenance_date),maintenance_schedule.schedule),'%Y-%m-%d') as 'Next Due'
|
|
|
57 |
from
|
|
|
58 |
maintenance_schedule join maintenance_task using (maintenance_task_id)
|
|
|
59 |
join device using (device_id)
|
|
|
60 |
join maintenance_performed using (maintenance_task_id,device_id)
|
|
|
61 |
join site using (site_id)
|
|
|
62 |
join client using (client_id)
|
|
|
63 |
where
|
|
|
64 |
maintenance_schedule.removed_date is null
|
|
|
65 |
and device.removed_date is null
|
|
|
66 |
group by
|
|
|
67 |
device.name,
|
|
|
68 |
maintenance_task.description
|
|
|
69 |
order by
|
|
|
70 |
client.name,
|
|
|
71 |
device.name,
|
|
|
72 |
maintenance_task.description
|
|
|
73 |
;
|
|
|
74 |
|
|
|
75 |
select
|
|
|
76 |
device_type.name as 'Type',
|
|
|
77 |
device.name as Device,
|
|
|
78 |
concat( client.name, ' - ',site.name) as Site,
|
|
|
79 |
count(maintenance_schedule.maintenance_schedule_id) as 'Maintenance'
|
|
|
80 |
from
|
|
|
81 |
device
|
|
|
82 |
join device_type using (device_type_id)
|
|
|
83 |
join site using (site_id)
|
|
|
84 |
join client using (client_id)
|
|
|
85 |
left outer join maintenance_schedule using (device_id)
|
|
|
86 |
where
|
|
|
87 |
device_type.device_type_id in (1,2,9)
|
|
|
88 |
and device.removed_date is null
|
|
|
89 |
group by device_id;
|