icinga2 - where to change client monitoring commands? - icinga

system ubuntu 16.04
On master node where icinga2 is installed
#ls /etc/icinga2/repository.d/hosts/WIN-U52321E0BAK/
disk C%3A.conf disk.conf icinga.conf load.conf ping4.conf
ping6.conf procs.conf swap.conf users.conf
All conf files have save "dummy" check_command on them for example
#cat load.conf
object Service "load" {
import "satellite-service"
check_command = "dummy"
host_name = "WIN-U52321E0BAK"
zone = "WIN-U52321E0BAK"
}
I cant understand from where dummy command is called and how to customize the checks for warning and critical threshold

The dummy command is defined in /usr/share/icinga2/include/command-plugins.conf, like so:
144 object CheckCommand "dummy" {
145 import "plugin-check-command"
146
147 command = [
148 PluginDir + "/check_dummy",
149 "$dummy_state$",
150 "$dummy_text$"
151 ]
152
153 vars.dummy_state = 0
154 vars.dummy_text = "Check was successful."
155 }
In order to modify the warn and crit levels, you set the custom variable at the host or service level. Using the example of ping, we see the default configuration in that same file:
36 template CheckCommand "ping-common" {
37 import "plugin-check-command"
38
39 command = [ PluginDir + "/check_ping" ]
40
41 arguments = {
42 "-H" = "$ping_address$"
43 "-w" = "$ping_wrta$,$ping_wpl$%"
44 "-c" = "$ping_crta$,$ping_cpl$%"
45 "-p" = "$ping_packets$"
46 "-t" = "$ping_timeout$"
47 }
48
49 vars.ping_wrta = 100
50 vars.ping_wpl = 5
51 vars.ping_crta = 200
52 vars.ping_cpl = 15
53 }
Here's the important bit:
49 vars.ping_wrta = 100
50 vars.ping_wpl = 5
51 vars.ping_crta = 200
52 vars.ping_cpl = 15
So: we go to our host or service definition, thusly (using /etc/icinga2/conf.d/host.conf and the NodeName/localhost definition which everybody has; comments removed):
18 object Host NodeName {
20 import "generic-host"
21
23 address = "127.0.0.1"
24 address6 = "::1"
25
27 vars.os = "Linux"
30 vars.http_vhosts["http"] = {
31 http_uri = "/"
32 }
37
39 vars.disks["disk"] = {
41 }
42 vars.disks["disk /"] = {
43 disk_partitions = "/"
44 }
45 }
And we insert before line 45 above to produce:
18 object Host NodeName {
20 import "generic-host"
21
23 address = "127.0.0.1"
24 address6 = "::1"
25
27 vars.os = "Linux"
30 vars.http_vhosts["http"] = {
31 http_uri = "/"
32 }
37
39 vars.disks["disk"] = {
41 }
42 vars.disks["disk /"] = {
43 disk_partitions = "/"
44 }
45 vars.ping_wrta = 50
46 vars.ping_wpl = 3
47 vars.ping_crta = 10
48 vars.ping_cpl = 2
49 }
...and you have successfully customized the check threshold. You can add those variables to a template or even a hostgroup (I think; better test that, I may be wrong).

Related

The right Jenkins job copyArtifact Permission syntax in groovy

I've searched and found many topics about adding copyArtifact permission to jenkins project programmatically, but I'm not able to get working with my groovy pipeline generator code.
Here is the block code where I'm generating my multipipeline job, trying to set copyArtifact permission at the same time.
24 multibranchPipelineJob("my_project") {
25 branchSources {
26 branchSource {
27 source {
28 git {
29 remote("my_repo")
30 credentialsId(${credential_id})
31 traits {
32 gitBranchDiscovery()
33 cleanBeforeCheckoutTrait {
34 extension {
35 deleteUntrackedNestedRepositories(false)
36 }
37 }
38 }
39 }
40 }
41 strategy {
42 defaultBranchPropertyStrategy {
43 props {
44 }
45 }
46 }
47 }
48 }
49 properties {
50 copyArtifactPermissionProperty {
51 projectNameList('*')
52 }
53 }
54 triggers {
55 periodic(5)
56 }
57 orphanedItemStrategy {
58 discardOldItems {
59 // numToKeep(20)
60 }
61 }
62 if ("jenkinsfile") {
63 factory {
64 workflowBranchProjectFactory {
65 scriptPath("jenkinsfile")
66 }
67 }
68 }
69 }
Jenkins keeps raising the error bellow :
ERROR: (pipeline_gen.groovy, line 50) No signature of method:
javaposse.jobdsl.dsl.helpers.properties.FolderPropertiesContext.copyArtifactPermissionProperty()
is applicable for argument types:
(structure$_run_closure1$_closure5$_closure7$_closure8$_closure10$_closure23)
values:
[structure$_run_closure1$_closure5$_closure7$_closure8$_closure10$_closure23#27252a3] > > Finished: FAILURE
The message says the the signature at line 50 is not good.
I've tried the following syntaxes :
this ==>
49 properties {
50 copyArtifactPermissionProperty {
51 projectNames('*')
52 }
53 }
this ==>
49 options {
50 copyArtifactPermission('*')
51 }
this ==>
49 properties {
50 copyArtifactPermission('*')
51 }
this ==>
49 properties ([
50 copyArtifactPermission('*'),
51 ])
But none up there works.
What the right groovy syntax to achieve this please?

Jenkins JobDSL ERROR: Found multiple extensions which provide method branchDiscoveryTrait with arguments []:

I'm using jenkins jobDSL plugin to generate my pipeline jobs from a groovy script, where I'm trying to create a multibranchPipelineJob as you can in the following line
17 multibranchPipelineJob("projects/${project_name}/${component_name}") {
18 branchSources {
19 branchSource {
20 source {
21 git {
22 remote(component.repository)
23 credentialsId(component.credentials)
24 traits {
25 branchDiscoveryTrait()
26 cleanBeforeCheckoutTrait()
27 }
28 }
29 }
30 strategy {
31 defaultBranchPropertyStrategy {
32 props {
33 }
34 }
35 }
36 }
37 }
38 triggers {
39 periodic(5)
40 }
41 orphanedItemStrategy {
42 discardOldItems {
43 // numToKeep(20)
44 }
45 }
46 if (component.jenkinsfile) {
47 factory {
48 workflowBranchProjectFactory {
49 scriptPath(component.jenkinsfile)
50 }
51 }
52 }
53 }
When the main pipeline job executing this code runs, it raises this (apparently know) error :
ERROR: Found multiple extensions which provide method
branchDiscoveryTrait with arguments []:
[[com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait,
jenkins.plugins.git.traits.BranchDiscoveryTrait,
org.jenkinsci.plugins.github_branch_source.BranchDiscoveryTrait]]
I've searched and see many results where people say that we should add #Symbol annotations to the traits implementations or to the relevant descriptors.
But I don't understand exactly what to do and where to place that #Symbol, people seem to say it solves the issue, but there is nowhere a good explanation and guidance to apply the fix.
should the modification be done in the plugin code or elsewhere?
I solved it by using the specific git scm class, and the correct syntax was :
17 multibranchPipelineJob("projects/${project_name}/${component_name}") {
18 branchSources {
19 branchSource {
20 source {
21 git {
22 remote(component.repository)
23 credentialsId(component.credentials)
24 traits {
25 gitBranchDiscovery()
26 cleanBeforeCheckoutTrait {
27 extension {
28 deleteUntrackedNestedRepositories(false)
29 }
30 }
31 }
32 }
33 }
34 strategy {
35 defaultBranchPropertyStrategy {
36 props {
37 }
38 }
39 }
40 }
41 }
42 triggers {
43 periodic(5)
44 }
45 orphanedItemStrategy {
46 discardOldItems {
47 // numToKeep(20)
48 }
49 }
50 if (component.jenkinsfile) {
51 factory {
52 workflowBranchProjectFactory {
53 scriptPath(component.jenkinsfile)
54 }
55 }
56 }
57 }

Concatenation AOB in Lua

I can get AOB from 4 bytes value (DWORD) using this function on Cheat Engine Lua:
local bt = dwordToByteTable(1075734118)
for i, v in ipairs(bt) do
print(i, string.format('%02x', v))
end
result = [[
1 66
2 66
3 1e
4 40
]]
but I want the result as '66 66 1e 40'.
How set the regex for this?.
If I have a table like this:
cd = {
1075734118,
1075734118,
1075996262,
1076953088,
1076651622,
1076953088,
1076835123
}
How I get AOB for each item on the table with output as no.1?
Found solution:
cd = { 1075734118, 1075734118, 1075996262, 1076953088, 1076651622, 1076953088, 1076835123 }
function byte2aob(b) return type(b)=='number' and b<256 and b>=0 and string.format('%02X',b) or '??' end
function aob2byte(a) a = tonumber(a,16) return type(a)=='number' and a <256 and a>=0 and a or -1 end
function imap(t,f) local s={} for i=1,#t do s[i]=f(t[i]) end return s end
function n2bt(n,t) t=type(t)=='string' and t or 'dword' return rawget(_G,t..'ToByteTable')(n) end
function t2aob(t,sep) return table.concat(imap(t,byte2aob),type(sep)=='string' and sep or ' ') end
function n2aob(n,t) return t2aob(n2bt(n,t)) end
for i = 1, #cd do
print(n2aob(cd[i],'dword'))
end
result = [[
66 66 1E 40
66 66 1E 40
66 66 22 40
00 00 31 40
66 66 2C 40
00 00 31 40
33 33 2F 40
]]
Try this code:
print((string.format("%08x",1075734118):reverse():gsub("(.)(.)","%2%1 ")))

Remote Connection like Browser Toolbox

I'm trying to interact with another open profile, which is a seperate process. Browser Toolbox does this. I was wondering how can I re-simulate this behavior? Without the prompt asking for "allow remote connection"?
My goal is to (1) find all open firefox process, (2) access each of its xpcom and figure out the profile name, (3) and if its a profile name Im interested in, Ill focus its most recent window.
I don't know but I'm getting somewhere by tracing it in MXR:
http://mxr.mozilla.org/mozilla-release/source/browser/devtools/framework/toolbox-process-window.js#11
11 let { debuggerSocketConnect, DebuggerClient } =
12 Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
13 let { ViewHelpers } =
14 Cu.import("resource:///modules/devtools/ViewHelpers.jsm", {});
15
16 /**
17 * Shortcuts for accessing various debugger preferences.
18 */
19 let Prefs = new ViewHelpers.Prefs("devtools.debugger", {
20 chromeDebuggingHost: ["Char", "chrome-debugging-host"],
21 chromeDebuggingPort: ["Int", "chrome-debugging-port"]
22 });
23
24 let gToolbox, gClient;
25
26 function connect() {
27 window.removeEventListener("load", connect);
28 // Initiate the connection
29 let transport = debuggerSocketConnect(
30 Prefs.chromeDebuggingHost,
31 Prefs.chromeDebuggingPort
32 );
33 gClient = new DebuggerClient(transport);
34 gClient.connect(() => {
35 let addonID = getParameterByName("addonID");
36
37 if (addonID) {
38 gClient.listAddons(({addons}) => {
39 let addonActor = addons.filter(addon => addon.id === addonID).pop();
40 openToolbox({ addonActor: addonActor.actor, title: addonActor.name });
41 });
42 } else {
43 gClient.listTabs(openToolbox);
44 }
45 });
46 }
47
I ran the profile and it looks like the pref ..-host is localhost and ..-port is 6080. I'm not sure how this helps target a specific profile though. Maybe on start of the browser toolbox it opened port 6080 to the opener profile. I'm not sure, but if its true, then you'll have to run code from within the target profile to open a port maybe.
Totally not sure though.
But port is opened here:
http://mxr.mozilla.org/mozilla-release/source/browser/devtools/framework/ToolboxProcess.jsm#107
106
107 BrowserToolboxProcess.prototype = {
108 /**
109 * Initializes the debugger server.
110 */
111 _initServer: function() {
112 dumpn("Initializing the chrome toolbox server.");
113
114 if (!this.loader) {
115 // Create a separate loader instance, so that we can be sure to receive a
116 // separate instance of the DebuggingServer from the rest of the devtools.
117 // This allows us to safely use the tools against even the actors and
118 // DebuggingServer itself, especially since we can mark this loader as
119 // invisible to the debugger (unlike the usual loader settings).
120 this.loader = new DevToolsLoader();
121 this.loader.invisibleToDebugger = true;
122 this.loader.main("devtools/server/main");
123 this.debuggerServer = this.loader.DebuggerServer;
124 dumpn("Created a separate loader instance for the DebuggerServer.");
125
126 // Forward interesting events.
127 this.debuggerServer.on("connectionchange", this.emit.bind(this));
128 }
129
130 if (!this.debuggerServer.initialized) {
131 this.debuggerServer.init();
132 this.debuggerServer.addBrowserActors();
133 dumpn("initialized and added the browser actors for the DebuggerServer.");
134 }
135
136 this.debuggerServer.openListener(Prefs.chromeDebuggingPort);
137
138 dumpn("Finished initializing the chrome toolbox server.");
139 dumpn("Started listening on port: " + Prefs.chromeDebuggingPort);
140 },
141

why is code not executing on return from Future in Dart program

Could someone please explain to me why in the following code (using r25630 Windows), the value of iInsertTot at line 241 is null, or more to the point, why is line 234 ("return iInsertTot;") not executed and therefore at line 241, iInsertTot is null. The value of iInsertTot at lines 231/232 is an integer. While I can and probably should code this differently, I thought that I would try and see if it worked, because my understanding of Futures and Chaining was that it would work. I have used “return” in a similar way before and it worked, but I was returning null in those cases (eg. line 201 below).
/// The problem lines are :
233 fUpdateTotalsTable().then((_) {
234 return iInsertTot;
235 });
While running in the debugger, it appears that line 234 “return iInsertTot;” is never actually executed. Running from command line has the same result.
The method being called on line 233 (fUpdateTotalsTable) is something I am just in the process of adding, and it consists basically of sync code at this stage. However, the debugger appears to go through it correctly.
I have included the method “fUpdateTotalsTable()” (line 1076) just in case that is causing a problem.
Lines 236 to 245 have just been added, however just in case that code is invalid I have commented those lines out and run with the same problem occurring.
218 /*
219 * Process Inserts
220 */
221 }).then((_) {
222 sCheckpoint = "fProcessMainInserts";
223 ogPrintLine.fPrintForce ("Processing database ......");
224 int iMaxInserts = int.parse(lsInput[I_MAX_INSERTS]);
225 print ("");
226 return fProcessMainInserts(iMaxInserts, oStopwatch);
227 /*
228 * Update the 'totals' table with the value of Inserts
229 */
230 }).then((int iReturnVal) {
231 int iInsertTot = iReturnVal;
232 sCheckpoint = "fUpdateTotalsTable (insert value)";
233 fUpdateTotalsTable().then((_) {
234 return iInsertTot;
235 });
236 /*
237 * Display totals for inserts
238 */
239 }).then((int iInsertTot) {
240 ogTotals.fPrintTotals(
241 "${iInsertTot} rows inserted - Inserts completed",
242 iInsertTot, oStopwatch.elapsedMilliseconds);
243
244 return null;
245 /*
192 /*
193 * Clear main table if selected
194 */
195 }).then((tReturnVal) {
196 if (tReturnVal)
197 ogPrintLine.fPrintForce("Random Keys Cleared");
198 sCheckpoint = "Clear Table ${S_TABLE_NAME}";
199 bool tClearTable = (lsInput[I_CLEAR_YN] == "y");
200 if (!tFirstInstance)
201 return null;
202 return fClearTable(tClearTable, S_TABLE_NAME);
203
204 /*
205 * Update control row to increment count of instances started
206 */
207 }).then((_) {
1073 /*
1074 * Update totals table with values from inserts and updates
1075 */
1076 async.Future<bool> fUpdateTotalsTable() {
1077 async.Completer<bool> oCompleter = new async.Completer<bool>();
1078
1079 String sCcyValue = ogCcy.fCcyIntToString(ogTotals.iTotAmt);
1080
1081 print ("\n********* Total = ${sCcyValue} \n");
1082
1083 oCompleter.complete(true);
1084 return oCompleter.future;
1085 }
Your function L230-235 does not return anything and that's why your iInsertTot is null L239. To make it work you have to add a return at line 233.
231 int iInsertTot = iReturnVal;
232 sCheckpoint = "fUpdateTotalsTable (insert value)";
233 return fUpdateTotalsTable().then((_) {
234 return iInsertTot;
235 });

Resources