Running your K1-scripts periodically is a great feature for solving different task all over your to do list. If don't want the script engine to start if there is no target pc online & connected to your K1 here is something for you:
Scenario:
You have a K1-Script which is running periodically to all your Ubuntu devices to check their updates. The script engine should only start if there are Ubuntu devices online & connected to your K1.
What is the main function?
If you implement this solution the K1 will automatically Enable or Disable the script. The SQL task will have minor impact to the system performance than the script engine testing every device connection.
How?
You need to create two SQL-TicketRules which are running for example every 15 minutes:
Enable Rule:
Please change the highlighted parts with ID's of your environment.
Select SQL:
SELECT * FROM (
SELECT COUNT(LABEL.ID)
FROM ((ORG1.MACHINE MACHINE
INNER JOIN KBSYS.SMMP_CONNECTION SMMP_CONNECTION
ON (MACHINE.KUID = SMMP_CONNECTION.KUID))
INNER JOIN ORG1.MACHINE_LABEL_JT MACHINE_LABEL_JT
ON (MACHINE_LABEL_JT.MACHINE_ID = MACHINE.ID))
INNER JOIN ORG1.LABEL LABEL ON (LABEL.ID = MACHINE_LABEL_JT.LABEL_ID)
WHERE (LABEL.ID = **YOURLABELIDHERE**) AND (SMMP_CONNECTION.CLIENT_CONNECTED = 1)
) as x
WHERE `COUNT(LABEL.ID)` = 1
Run update Query:
UPDATE KBOT SET ENABLED = '1' WHERE ID = **YOURSCRIPTIDHERE**
Disable Rule:
Please change the highlighted parts with ID's of your environment.
Select SQL:
SELECT * FROM (
SELECT COUNT(LABEL.ID)
FROM ((ORG1.MACHINE MACHINE
INNER JOIN KBSYS.SMMP_CONNECTION SMMP_CONNECTION
ON (MACHINE.KUID = SMMP_CONNECTION.KUID))
INNER JOIN ORG1.MACHINE_LABEL_JT MACHINE_LABEL_JT
ON (MACHINE_LABEL_JT.MACHINE_ID = MACHINE.ID))
INNER JOIN ORG1.LABEL LABEL ON (LABEL.ID = MACHINE_LABEL_JT.LABEL_ID)
WHERE (LABEL.ID = **YOURLABELIDHERE**) AND (SMMP_CONNECTION.CLIENT_CONNECTED = 1)
) as x
WHERE `COUNT(LABEL.ID)` = 0
Run update Query:
UPDATE KBOT SET ENABLED = '1' WHERE ID = **YOURSCRIPTIDHERE**
**edit**
Thanks to Steve: If you want it quicker you can create a label only for this if you are using the smartlabel wizard:
Comments