Fail2ban add more info to email notificationd - fail2ban

I'd like to append the relevant fail2ban log entry to the notification email I already receive for any given incident.
Does anybody know how this can be done?

It depends on what information you would like - you may edit the appropriate action.d configuration file's actionban segment by copying the .conf version to a .local version which will override the .conf version as per the fail2ban documentation, and edit it to include whatever information you would like. For example, I have personally amended my sendmail-whois.conf (which is the main sendmail action I use - you could do likewise with sendmail.conf however if you use that for example) by copying it to sendmail-whois.local which I then edited to include the server hostname on the 'From:' line.
You could also include commands to be executed with their output passed to the email to be sent, as long as you follow the correct syntax and fully qualify the path to the relevant commands - for example, you will see that the sendmail-whois action configuration contains the line, within the actionban segment;
`/usr/bin/whois <ip>`\n
Note, as I have mentioned above - the full path to the relevant command is included (in this case, for whois), and the entire command with its options must be delimited by backquotes. the \n at the end of the line indicates that a new line be printed following this one in the output.
Hope that clarifies things for you!

Related

Paramter as File path in DataStage

I just starting with DataStage, developing a project to process files I'm getting an strange error when the variable is mapped from a sequence job to parallel job, if I check the path in the error message the path exist and the file is there.. Any insight that can help to solve this problem. I'd really appreciate.. Below you can see with the pictures how the job is implemented and the error.
Thanks in Advance
The white space between your file path and the : in the error message are suspicious. Copy the file path directly from the log and paste into an editor that you can do character examination. You are likely having whitespace issues when looking to the path.
Please indicate what you are doing to the file path in the User Variables activity. The log appears to contain a valid Windows pathname, and reports "no such file or directory". Can you please validate that the file does indeed exist at that location? If it does not, then your ls | awk | tr pipeline or your sequence parameter TestFile_$DestinationPath may need some work.
I ran into the same situation where the file name being passed from the sequencer to the job looks to resolve correctly, but it gives the same error of file not found. Even though I copy the resolved name (taken from job log of the job) and open that path/file, it opens successfully. However, you do not see that DS is adding an extra "space" to the end of the resolved parameter value in the job. If you were to switch the input file stage from specific file to file pattern and just add * to the end of your file name, you will see that DS is trying to resolve the parameter value plus a space plus an *. For example, your sequencer is passing file name as "D:\abc.txt", but the job will see it as "D:\abc.txt *".
Actual job log entry of the job is:
ls: File or directory "D:\abc.txt *" is not found
The fix that worked for me is to do an Exchange of "0D" to "FF" in the User Variable stage. For some reason, DS was adding a carriage return in the User Variable stage. I wrote the file name to a text file to see what the value is being passed along the way and it always showed up as the correct value with no special characters added throughout my sequencer. By adding this Exchange in the User Variable expression, it worked for me as what you are expecting (passing the true file name value to the next job and able to read the file successfully). There is no need to actually switch to file pattern, but this was needed for debugging purposes to see the value actually being resolved in the job.

How do I format jenkins build server emails so that the content is not all on the same line?

I have used hudson in that past and am very happy with it. It seemed to work well.
I recently installed jenkins and set up the editable email plug in.
Jenkins Version: 1.513
Email-ext plugin version: 2.28
Unfortunately when I try to add other tokens/over ride the default email it just appends all the tokens to the same line.
This is confusing. I have the email set up for html.
Any hints on how to format this nicer?
The default email sent (not the editable one) works ok, but I would like more useful information.
Unfortunately the format of this email makes it close to useless.
here is my editable content:
$BUILD_TAG
$BUILD_ID
$SVN_REVISION
$CHANGES
$CAUSE
$DEFAULT_CONTENT
$WARNINGS_NEW
$WARNINGS_COUNT
Here is the email received:
jenkins-DotNet-43 2013-05-13_16-09-40 7481 [kevin] -help layout Started by an SCM change DotNet - Build # 43 - Successful: Check console output at http://[buildserver]:8080/job/DotNet/43/ to view the results. [kevin] -help layout Started by an SCM change [...truncated 142 lines...] CopyFilesToOutputDirectory: Copying file from "obj\Release\Model.Wpf.dll" to "bin\Release\Model.Wpf.dll". Model.Wpf -> C:\Jenkins.jenkins\jobs\DotNet\workspace\dotnet\Messenger\Model\Model.Generic\bin\Release\Model.Wpf.dll Copying file from "obj\Release\Model.Wpf.pdb" to "bin\Release\Model.Wpf.pdb". Done Building Project "C:\Jenkins.jenkins\jobs\DotNet\workspace\dotnet\Messenger\Model\Model.Ge
EDIT
Note: when I put in "< BR >" entries between items they are separated by linefeeds in the email. Unfortunately though within the tokens themselves (like the change list) the are NO line separators - for example multiple commits are listed all on one line.
The content is there, but it is difficult to decipher. It seems there is a bug in the mail plugin or some other related system.
You already noticed that you need to actually use HTML line breaks between tokens so they don't show up on the same line, so I'll just answer the part about the multiple change log entries on the same line.
From the Content Token Reference, bold emphasis mine:
${CHANGES, showPaths, showDependencies, format, pathFormat}
Displays the changes since the last build.
showDependencies - if true, changes to projects this build depends on are shown.
Defaults to false.
showPaths - if true, the paths modified by a commit are shown.
Defaults to false.
format - for each commit listed, a string containing %X, where %X is one of %a for author, %d for date, %m for message, %p for paths,
or %r for revision. Not all revision systems support %d and %r. If
specified, showPaths is ignored.
Defaults to "[%a] %m\n".
pathFormat - a string containing %p to indicate how to print paths.
Defaults to "\t%p\n".
The unparameterized ${CHANGES} token is set up for display in a plain text email. You need to configure it so it displays properly in an HTML environment.
Example: <ul>${CHANGES, format="<li>[%a] %m</li>"}</ul>
One may try
mimeType:'HTML/text'
with the emailext plugin and use HTML <br> tag for new lines.
Surprisingly mimeType:'text/html' didn't work in my case whereas mimeType:'HTML/text' did.

Programmatically change text config files in Linux with minimal effort

I am looking for a tool that would ease the modification of text configuration files for tasks like:
Set ForwardAgent yes on /etc/ssh/ssh_config
Append HGUSER to AcceptEnv in /etc/ssh/sshd_config (that's more complex as it does accept several params, if yours is not alread there it should add it)
Most important:
running it several times should have no side effects.
if something looks weird, it should complain (for example if you find the same line several times in a file, or if the expected syntax does not match).
Is there any linux tool that can easily be used to automate things like this?
The whole point is to be able to write these config patches somewhere so you can deploy them on several machines or on a new machine when needed.
I would certainly do this with bash scripting. Here is a great tutorial.
http://linuxconfig.org/Bash_scripting_Tutorial
to change a line in a file you could do something like:
check the file exists
grep for the value you want to change - error if it appears multiple times or something
use sed to change that line
to append something to a file
check if file exists
grep to ensure it hasn't been appended to already
echo whatever >> file - the double greater than appends to a file
with each of these I would make a backup copy of the file first, just in case something goes wrong
You might want to have a look at the Unified Configuration Interface (UCI) used in Embedded Linux systems. If you have the flexibility to adapt the UCI format for your config files, this is pretty similar to what you are looking for.

how can we identify notepad file?

how can we identify notepad files which is created in two computer, is there a any way to get any information about in which computer it was created.Or whether it is build in xp or linux.
If you right click on the file, you should be able to see the permissions and attributes of the file.
Check at the end of the line. Under GNU/Linux lines end with \n (ascii: 0x0A) while under Miscrosoft W$ndos it is \r\n (ascii: 0x0D 0x0A).
Wikipedia: https://en.wikipedia.org/wiki/Newline
found this: http://bit.ly/J258Mr
for identifying a word document but some of the info is relevant
To see on which computer the document had been created, open the Word
document in a hex editor and look for "PID_GUID". This is followed by
a globally unique identifier that, depending upon the version of Word
used, may contain the MAC address of the system on which the file was
created.
Checking the user properties (as already mentioned) is a good way to
see who the creator of the original file was...so, if the document was
not created from scratch and was instead originally created on another
system, then the user information will be for the original file.
Another way to locate the "culprit" in this case is to parse the
contents of the NTUSER.DAT files for each user on each computer. While
this sounds like a lot of work, it really isn't...b/c you're only
looking for a couple of pieces of information. Specifically, you're
interested in the MRU keys for the version of Word being used, as well
as perhaps the RecentDocs keys."
The one thing I can think on the top of my mind is inspecting the newline characters on your file - I'm assuming your files do have multiple lines. If the file was generated using Windows then a newline would be characterized by the combination of carriage return and line feed characters (CR+LF) whereas a simple line feed (LF) would be a hint that the file was generated in a Linux machine.
Right click one the file--> Details . You can see the computer name where it was created and the date.

Emacs: Is there a way to generate a skeleton ChangeLog from diff?

I'd like to partly automate creation of GNU-style ChangeLog entries when working with source code in version control. The add-changelog-entry-other-window works with one file at a time and you have to visit the file to use it.
What I'd like to see instead is to have some command that would take an output of diff -u -p (or have integration with VC modes so it could process svn diff etc) and to create all the skeleton entries at once.
For example, if svn status shows
D file1.c
M file2.c
A file3.c
the command would create
2009-09-05 My Name <my.email>
* file1.c: Removed.
* file2.c: WRITE YOUR CHANGES HERE
* file3.c: New.
Better yet, if it could parse the changed files in some languages to an extent so it could offer:
* file2.c (new_function): New function.
(deleted_function): Removed.
(changed_function): WRITE YOUR CHANGES HERE
I have found this feature in Emacs manual, but I don't see how I could apply it here.
Any suggestions? Thanks.
EDIT: One answer suggested vc-update-change-log. Unfortunately it only supports CVS and it creates ChangeLog entries by querying the already-commited VC logs. Thus even if it supported svn and others, it would be impossible to commit the changes and the ChangeLog in the same commit.
EDIT2: Apparently add-changelog-entry-other-window (C-x 4 a) works not only from visited file but from diff hunk involving that file too. (Source) This is almost what I am looking for. This together with elisp loop to iterate through all hunks should solve it.
There is a function vc-update-change-log that automatically generates change log entries from the version control log entries.
diff-add-change-log-entries-other-window is documented to do exactly what you mentioned in EDIT2:
diff-add-change-log-entries-other-window is an interactive compiled
Lisp function in `diff-mode.el'.
(diff-add-change-log-entries-other-window)
Iterate through the current diff and create ChangeLog entries.
I.e. like `add-change-log-entry-other-window' but applied to all hunks.
Unfortunately, it doesn't work very well for, say, new files: it doesn't even include the filenames of such files in the skeletal changelog entry.
You might have better luck with gcc's mklog script, which you can get from http://gcc.gnu.org/viewcvs/gcc/trunk/contrib/mklog.
I don't know of a function that does this, but it should be easy to implement. Basically, you want to
get the changed files
for each file, call add-change-log
"Find change log file, and add an entry for today and an item for this file.
Optional arg WHOAMI (interactive prefix) non-nil means prompt for user
name and email (stored in `add-log-full-name' and `add-log-mailing-address').
Second arg FILE-NAME is file name of the change log.
If nil, use the value of `change-log-default-name'.
Third arg OTHER-WINDOW non-nil means visit in other window.
Fourth arg NEW-ENTRY non-nil means always create a new entry at the front;
never append to an existing entry. Option `add-log-keep-changes-together'
otherwise affects whether a new entry is created.
Option `add-log-always-start-new-record' non-nil means always create a
new record, even when the last record was made on the same date and by
the same person.
The change log file can start with a copyright notice and a copying
permission notice. The first blank line indicates the end of these
notices.
Today's date is calculated according to `add-log-time-zone-rule' if
non-nil, otherwise in local time."
so the magic code is going to look something like
(apply 'make-magic-change-log-entry changed-files-list)
and make-magic-change-log-entry simply curries the add-change-log function so that the only argument is file-name — you set the other ones.
I've written a function to do something similar to what you were talking about. You can get the code at http://www.emacswiki.org/emacs/log-edit-fill