مثال لاستعلام SQL في أداة klsql2 المساعدة

يعرض هذا القسم مثالاً لاستعلام SQL، الذي يتم تنفيذه بواسطة أداة klsql2 المساعدة.

توضح الأمثلة التالية استعادة الأحداث التي حدثت في الأجهزة خلال السبعة أيام الماضية، وعرضًا للأحداث التي طُلبت وقت حدوثها، ويتم عرض الأحداث الأخيرة أولاً. ويتم عرض الأحداث الأخيرة أولاً.

مثال لبرنامج Microsoft SQL Server:‏

SELECT

/* event identifier */

e.nId,‏

 

/* time, when the event occurred */

e.tmRiseTime,‏

 

/* internal name of the event type */

e.strEventType,‏

 

/* displayed name of the event */

e.wstrEventTypeDisplayName,‏

 

/* displayed description of the event */

e.wstrDescription,‏

 

/* name of the group, where the device is located */

e.wstrGroupName,‏

 

/* displayed name of the device, on which the event occurred */

h.wstrDisplayName,‏

CAST(((h.nIp / 16777216) & 255) AS varchar(4)) + '.' +

CAST(((h.nIp / 65536) & 255) AS varchar(4)) + '.' +

CAST(((h.nIp / 256) & 255) AS varchar(4)) + '.' +

 

/* IP address of the device, on which the event occurred */

CAST(((h.nIp) & 255) AS varchar(4)) as strIp

FROM v_akpub_ev_event e

INNER JOIN v_akpub_host h ON h.nId=e.nHostId

WHERE e.tmRiseTime>=DATEADD(Day, -7, GETUTCDATE())

ORDER BY e.tmRiseTime DESC

مثال لبرنامج PostgreSQL:‏

SELECT

/* event identifier */

"e"."nId",

 

/* time, when the event occurred */

"e"."tmRiseTime",

 

/* internal name of the event type */

"e"."strEventType",

 

/* displayed name of the event */

"e"."wstrEventTypeDisplayName",

 

/* displayed description of the event */

"e"."wstrDescription",

 

/* displayed description of the event */

"e"."wstrGroupName",

 

/* displayed name of the device, on which the event occurred */

"h"."wstrDisplayName",

(

CAST((("h"."nIp" / 16777216 )& 255 ) AS VARCHAR(4)) || '.' ||

CAST((("h"."nIp" / 65536 )& 255 ) AS VARCHAR(4)) || '.' ||

CAST((("h"."nIp" / 256 )& 255 ) AS VARCHAR(4)) || '.' ||

/* IP address of the device, on which the event occurred */

CAST((("h"."nIp" )& 255 ) AS VARCHAR(4))

) AS "strIp"

FROM "v_akpub_ev_event" AS "e"

INNER JOIN "v_akpub_host" AS "h" ON "h"."nId" = "e"."nHostId"

WHERE "e"."tmRiseTime" >= NOW() AT TIME ZONE 'utc' + make_interval(days => CAST(-7 AS INT))

ORDER BY "e"."tmRiseTime" DESC ;

مثال لبرنامج MySQL أو MariaDB:‏

SELECT

/* event identifier */

`e`.‏`nId`,

 

/* time, when the event occurred */

`e`.‏`tmRiseTime`,

 

/* internal name of the event type */

`e`.‏`strEventType`,

 

/* displayed name of the event */

`e`.‏`wstrEventTypeDisplayName`,

 

/* displayed description of the event */

`e`.‏`wstrDescription`,

 

/* device group name */

`e`.‏`wstrGroupName`,

 

/* displayed name of the device, on which the event occurred */

`h`.‏`wstrDisplayName`,

CONCAT(

LEFT(CAST(((`h`.‏`nIp` DIV 1677721) & 255) AS CHAR), 4), '.',

LEFT(CAST(((`h`.‏`nIp` DIV 65536) & 255) AS CHAR), 4), '.',

LEFT(CAST(((`h`.‏`nIp` DIV 256) & 255) AS CHAR), 4), '.',

/* IP address of the device, on which the event occurred */

LEFT(CAST(((`h`.‏`nIp`) & 255) AS CHAR), 4)

) AS `strIp`

FROM `v_akpub_ev_event` AS `e`

INNER JOIN `v_akpub_host` AS `h` ON `h`.`nId` = `e`.‏`nHostId`

WHERE `e`.‏`tmRiseTime` >= ADDDATE( UTC_TIMESTAMP( ) , INTERVAL -7 DAY)

ORDER BY `e`.‏`tmRiseTime` DESC ;

انظر أيضًا:

تكوين تصدير الحدث إلى أنظمة SIEM

أعلى الصفحة