first commit

This commit is contained in:
2026-04-09 13:05:27 +02:00
commit 3bbd7d6413
3084 changed files with 84284 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
const triggername = context.panel.elements.find(e => e.id === "triggername")?.value;
const exp = context.panel.elements.find(e => e.id === "expression")?.value;
async function ejecutarPeticion() {
async function getToken() {
let token = null;
const res = await fetch("http://localhost:8080/api_jsonrpc.php", {
method: "GET",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0",
method: "user.login",
params: {
username: "Admin",
password: "zabbix"
},
id: 1
})
});
const data = await res.json();
token = data.result;
return token;
}
let token = await getToken();
let petition = await fetch("http://localhost:8080/api_jsonrpc.php", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + token
},
body: JSON.stringify({
jsonrpc: 2.0,
method: "trigger.create",
params: {
description: triggername,
expression: exp,
},
id: 1
})
});
return petition;
}
return ejecutarPeticion();