[SQL] New Machines in Inventory (Last 10 days)
Lists all machine fields for all computers that have created a new inventory record in the last 10 days. This can be used as a filter or email notification as well.
select *, UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(LAST_SYNC) as LAST_SYNC_TIME,
UNIX_TIMESTAMP(MACHINE.LAST_SYNC) as LAST_SYNC_SECONDS
from ORG1.MACHINE
where (DATE(NOW() - INTERVAL 10 DAY) < DATE(MACHINE.CREATED))
0 Comments
[ + ] Show comments
Answers (11)
Please log in to answer
Posted by:
RichB
14 years ago
Posted by:
errinf
14 years ago
Posted by:
GillySpy
14 years ago
* means, all columns from all tables involved.
If you refer to the download archive section you will see a schema for each database. The tables you are interested in are likely in the org schema (not the kbsys schema)
From your example request:
MACHINE.NAME - Host name of pc
MACHINE.IP - IP used to do the last inventory
MACHINE.USER - username (more accurate then USER_NAME)
Then you would rewrite the query. Here's a rewrite of the first line:
If you refer to the download archive section you will see a schema for each database. The tables you are interested in are likely in the org schema (not the kbsys schema)
From your example request:
MACHINE.NAME - Host name of pc
MACHINE.IP - IP used to do the last inventory
MACHINE.USER - username (more accurate then USER_NAME)
Then you would rewrite the query. Here's a rewrite of the first line:
select MACHINE.NAME,
MACHINE.IP,
MACHINE.USER,
UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(LAST_SYNC) as LAST_SYNC_TIME,
UNIX_TIMESTAMP(MACHINE.LAST_SYNC) as LAST_SYNC_SECONDS
Posted by:
errinf
14 years ago
Posted by:
GillySpy
14 years ago
UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(LAST_SYNC) is how many seconds ago it synced. You could just use MACHINE.LAST_SYNC if you want the timestamp instead.
UNIX_TIMESTAMP(MACHINE.LAST_SYNC) as LAST_SYNC_SECONDS is the time in seconds since '1970-01-01 00:00:00' UTC -- so probably not very useful to you.
The only reason I included those is they were in the first post.
The only reason the first poster included those is because they are the way our reports, forms, email alerts, filters, etc query the data and turn that into "10s" or "1d".
UNIX_TIMESTAMP(MACHINE.LAST_SYNC) as LAST_SYNC_SECONDS is the time in seconds since '1970-01-01 00:00:00' UTC -- so probably not very useful to you.
The only reason I included those is they were in the first post.
The only reason the first poster included those is because they are the way our reports, forms, email alerts, filters, etc query the data and turn that into "10s" or "1d".
Posted by:
dtuttle
14 years ago
We use this
As a filter to assign a label to a computer, in our case after today (the 30th of March). We use this right now for a few software items that don't upgrade well, so we can start putting it on new computers.
select MACHINE.*, UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(LAST_SYNC) as LAST_SYNC_TIME,
UNIX_TIMESTAMP(MACHINE.LAST_SYNC) as LAST_SYNC_SECONDS
FROM MACHINE
WHERE DATE(CREATED) > DATE('2010-03-30 12:00:00')
As a filter to assign a label to a computer, in our case after today (the 30th of March). We use this right now for a few software items that don't upgrade well, so we can start putting it on new computers.
Posted by:
mlathrop
14 years ago
Posted by:
DContreras
14 years ago
Could someone show me how to get the machine model added to the report?
ORIGINAL: mlathrop
Cool report. Could someone show me how to get the machine model added to the report?
MACHINE.CS_MODEL is the field for model. MACHINE.CS_MANUFACTURER is the field for Manufacturer. You can add these two fields in the select statement 'select MACHINE.NAME, MACHINE.CS_MODEL, MACHINE.CS_MANUFACTURER from MACHINE.....'
Dan
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.