I'm having trouble thinking and implementing a way to do the following:
I have a systemd monitoring template which has 2 main triggers for any given discovered service. "The service has restarted" or "The service is not running". When a given host restarts, every single service trigger kicks off with an alert saying "service has restarted". This makes sense, the host restarts, so do the services.
My goal is to prevent the service trigger alerts from being generated if the host uptime is less than 10 minutes (the default timer for the "host restarted" trigger).
In other words, "Service has restarted" trigger should only be generated when the host uptime is more than 10 minutes.
So my initial thoughts were to use trigger dependencies, but those only create a dependency off another trigger. So I wouldn't want my "service has restarted" trigger to activate if the "host has restarted" trigger was also activated (thats the opposite of what I want). And as far as I am aware, the trigger dependencies do not have a "negate" or "not" function/operator built into them. So I couldn't say something like: "This trigger can only activate if this other trigger is currently inactive."
So my next thought was to edit the template discovery trigger prototype expression and change it from the following: last(/Systemd by Zabbix agent 2/systemd.service.uptime["{#UNIT.NAME}"])<10m to something like last(system.uptime)>10m AND last(/Systemd by Zabbix agent 2/systemd.service.uptime["{#UNIT.NAME}"])<10m. This isn't exact syntax, just the rough idea of what I was thinking of.
The problem is when I try to do the expression editor and include the item from another template, is errors out with:
Trigger prototype "{#UNIT.NAME}: has been restarted" belongs to templates with different linkages.
I assume that it wont let me link a prototype trigger with another templates item?
I am using the default "Linux Generic by Zabbix Agent" Template, and the following template for systemd:
https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/systemd?at=release/6.0
Overall, I definitely don't want to be going around to every host and creating custom triggers for every single service that compares the host uptime with the systemd service uptime. Maybe I could move the system.uptime template item from the "Generic Linux Template" to the Systemd template, but thats rather brute force.
Anyone got an ideas for what to do here?
Any better ways to solve my problem?
You may use items from different templates in triggers that are in another template. BUT the item templates need to be linked to the trigger template.
So in your case, you should do:
create a new, empty XYZ Template
link Generic Linux Template and Systemd Template to your XYZ template
now you can create triggers in your XYZ template that utilizes items from Generic Linux Template and Systemd Template
Related
My Jenkins UI takes parameter a list of files/folders along with wildcards from users that they wish to delete.
Jenkins then passes the files to be deleted across all hosts by invoking ansible-playbook.
My requirement is to prompt user on Jenkins for confirmation before deleting a file / folder.
Thus, how rm -rfi /tmp/moht /var/log*/data.dat prompts interactively asking the user confirmation before deleting the files; is what I Wish to prompt on Jenkins for each Host.
Thus, for the above I expect Jenkins to prompt like below:
Are you sure you want to delete
/tmp/moht
/var/log14Mar/data.dat
I'm aware of input function in Jenkins for prompt.
I'm also aware of an ansible command module that can be used to fire rm -rfi command.
I'm also aware of how to timeout or terminate the Jenkins Job upon user input. However, in this case I would love if the user input Yes / No could be sent back to the target host via ansible and action gets performed accordingly.
I understand that this may be too much an ask but other feasible solutions or suggestions are also appreciated.
Can you please suggest how can I achieve the requirement?
I strongly feel that using Jenkins as interactive tool is a bad idea. But if you really like to implement bad ideas with unsuitable tools, you can try to use matrix job [1] based on files you want to remove.
Jenkins will create a list of jobs with a job for each file you'd like to remove. You ask confirmation and then execute an Ansible playbook to remove a file.
[1] https://plugins.jenkins.io/matrix-project/
It's horribly inefficient and you should not do it like this.
How can I make an external job appear on a Jenkins dashboard more like a native Jenkins job, specifically including a progress 'bar'?
I've come across https://plugins.jenkins.io/external-monitor-job but this only appears to provide a way to say
My jobs has finished with this console output and this result code.
I would also like to see things such as current progress. Or to put it another way, I'd like my external job to be able to appear on something like https://kj187.github.io/dashing-jenkins_job/ in a similar manner to a native Jenkins job.
So is it possible to push more data than the external-monitor-job suggests?
Create a free style job and monitor the external process (print logs etc.) in the free style job - read the logs till logical conclusion in the freestyle job
What about pipeline view plugin?
Steps will be:
v1 (manual way)
create a job called monitoring_external_process inside pipeline view. This job performs a kind of ping looking the end of your process.
start your external process in a separate way.
go to jenkins monitoring_external_process job and press build.
a progress bar will be showed until the end of your external process.
v2 (automatic way)
create a job called monitoring_external_process inside pipeline view. This job performs a kind of ping looking the end of your process.
configure a webhook trigger or remote build for this job. This enable a public url to invoke the jenkins job. (See link reference #2)
configure your external process to perform an htttp request to the public url.
start your external process in a separate way.
Automatically your job will be started and progress bar will be showed until the end of your external process.
References:
(1) https://code-maven.com/jenkins-pipeline-hello-world
(2) https://jrichardsz.github.io/devops/devops-with-git-and-jenkins-using-webhooks
I occasionally want to get notified when a particular jenkins job that is building finishes. Is there any way to do this?
Scripting it through the API would be fine. I already have the jenkins IRC bot that notifies me of many things, so if I could just dynamically modify the running job build, that would be enough to do what I want -- I'm just having a hard time finding how to accomplish that.
AFAIK, you cannot change a job's config while it's running.
Here is an idea: Use a post-build step to check for an external resource status (like a file containing an action by text) and running an action based on the content of the file.
The external file can be modified while the build is running, so when the post-build is executed, it will follow the logic defined based on the content of the file.
I hope this helps.
You can use email notifier, It will send you an email
https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin
I have a requirement my below,
We have a build release server environment, which has currently linked with the Teamcity Build system and Kb system, etc. That means, in Teamcity, every build event changes (i.e., events like, build started, build finished, build succeed, build failed, build quality changes/pinned, etc.), it notifies/calls the release system web service with build details (the Xml data).
Now, we are trying to move to the TFS 2013 system instead of Teamcity and I am new to the TFS administration things. I have got a task to connect the release server and do the same job like Teamcity. Which means, in TFS system, on every build event changes (like, build started, build finished, build succeed, build failed, build quality changes, etc.), it should call the release system web service with TFS build Xml data so that I can update that in our database. Would you please tell me the method by which I can achieve that?
FYI,
I have tried with TFS alert notification as below. But, seems like it doesn’t allow to call web service from this section. It only allows to mail the details to specific users. Please let me know if I am wrong.
If it can be achievable through XMAL script, would you please provide some test XAML scripts how can I call the web service from this?
Thanks.
There are multiple ways to achieve this.
But if the alert types are sufficient for your needs, then going through the alert mechanism is the simple way.
You will just need to create a simple listener service to be notified of the desired event (you already suspected of a such mechanism) using alert mechanism's SOAP event feature.
Create a simple web service, having a method like below:
public void Notify(string eventXml, string tfsIdentityXml, SubscriptionInfo subscriptionInfo)
{
EventProcessor.Process(eventXml);
}
SubscriptionInfo class is defined in Microsoft.TeamFoundation.Framework.Server, but you can also use the override without it if available.
Then publish and make available this service, for example having the address: http://localhost:101/NotifyCorpService.svc
Then, you should add an alert for each event you want to be notified (or a single one if applicable using conditions together):
Create an Alert
Set Alert's property "Format" to "SOAP"
Set Alert's property "Send To" to "http://localhost:101/NotifyCorpService.svc"
Finally, you can use the "eventXml" and using its contents, call the web service you want in the code behind of the simple web service we created (NotifyCorpService in our example)
I have a build definition with a custom process parameter. If set to true, I'd like the build to queue up on a specific agent, essentially overriding any agent name that's set in the definition. I'd rather not use tags because I don't think they'll be used properly, plus this seems more dynamic in nature. I'm thinking this could be done in the build process template somehow. Just not sure how to accomplish it.
You can customize the build process template to look at your custom workflow argument, and change the value of the AgentSettings.Name prior to the Run On Agent activity.