| 41 |
rodolico |
1 |
|
|
|
2 |
/* now, load the attributes */
|
|
|
3 |
|
|
|
4 |
/*
|
|
|
5 |
this is a big kludge, but since it is only run once, I did not bother optimizing it.
|
|
|
6 |
basically, get all the attributes which are used by devices which are systems
|
|
|
7 |
and add them to the attribute table
|
|
|
8 |
*/
|
|
|
9 |
insert into attribute ( name,attribute_category_id,added,removed)
|
|
|
10 |
select
|
|
|
11 |
camp.attrib.name,
|
|
|
12 |
attribute_category.attribute_category_id,
|
|
|
13 |
date(camp.attrib.added_date),
|
|
|
14 |
date(camp.attrib.removed_date)
|
|
|
15 |
from
|
|
|
16 |
camp.attrib
|
|
|
17 |
join camp2.attribute_category
|
|
|
18 |
where
|
|
|
19 |
attribute_category.name = 'device'
|
|
|
20 |
and camp.attrib.attrib_id in (
|
|
|
21 |
select distinct
|
|
|
22 |
attrib_id
|
|
|
23 |
from
|
|
|
24 |
camp.device_attrib
|
|
|
25 |
where
|
|
|
26 |
camp.device_attrib.device_id in
|
|
|
27 |
(
|
|
|
28 |
select
|
|
|
29 |
device_id
|
|
|
30 |
from
|
|
|
31 |
camp.device
|
|
|
32 |
join camp.device_type using (device_type_id)
|
|
|
33 |
where
|
|
|
34 |
device_type.show_as_system = 'Y'
|
|
|
35 |
)
|
|
|
36 |
)
|
|
|
37 |
and camp.attrib.name not in (
|
|
|
38 |
select
|
|
|
39 |
attribute.name
|
|
|
40 |
from
|
|
|
41 |
attribute
|
|
|
42 |
join attribute_category using (attribute_category_id)
|
|
|
43 |
where
|
|
|
44 |
attribute_category.name = 'device'
|
|
|
45 |
);
|
|
|
46 |
|
|
|
47 |
/*
|
|
|
48 |
now, load the values for the devices. NOTE: we should clean up data coming in since sysinfo
|
|
|
49 |
brings in values which are only slightly different for memory and cpu speed.
|
|
|
50 |
*/
|
|
|
51 |
|
|
|
52 |
insert into attribute_value( attribute_id,table_id,value,added,removed)
|
|
|
53 |
select
|
|
|
54 |
camp2.attribute.attribute_id,
|
|
|
55 |
camp.device_attrib.device_id,
|
|
|
56 |
camp.device_attrib.value,
|
|
|
57 |
date( camp.device_attrib.added_date ) added,
|
|
|
58 |
date( camp.device_attrib.removed_date ) removed
|
|
|
59 |
from
|
|
|
60 |
camp.device_attrib
|
|
|
61 |
join camp.attrib on (camp.device_attrib.attrib_id = camp.attrib.attrib_id)
|
|
|
62 |
join camp2.attribute on (camp.attrib.name = camp2.attribute.name)
|
|
|
63 |
join camp2.temp on ( camp.device_attrib.device_id = camp2.temp.old_device_id )
|
|
|
64 |
join camp2.device on (camp2.device.name = camp2.temp.device_name)
|
|
|
65 |
;
|
|
|
66 |
|
|
|
67 |
/*
|
|
|
68 |
select * from view_attribute_device order by device,attribute,added limit 10;
|
|
|
69 |
*/
|