Clarity Service Management

A useful Service Desk Manager tool: Notepad++

By Kyle_R posted 09-17-2014 01:04 AM

  

Hello Everyone,

 

We all have our "kit bag" of utilities to tackle Administration tasks. The list is large and long, and it is possible to specialise in these alone.

 

I'll touch on one that *I* use more than any other - a text editor for large files.

This is invaluable for reviewing that mass of data that comes out of Service Desk Manager logging. By "mass", I mean large log files, complex trace/debug logging, component logging, performance logging . . . actually, I probably don't need to explain this further, as most of you will have run headfirst into the wonderful world of SDM logs.

 

I'll be talking about Service Desk Manager, but the gist is applicable to many products.

 

My "go to" text editor is "Notepad++."

Notepad++ icon.png

There are many other text editors available, and you're free to use any of them. This one though has been serving me well in particular because:

  • Easy to use - doesn't have a steep learning curve like some editors.
  • Handles very large log files. (MS Notepad does not.)
  • Good Search functions.
  • Syntax highlighting.
  • Lots of plugins for times when base functionality doesn't cut it.
  • Active user base and community. Very popular globally. Maintained and improved.
  • Notepad++ itself lists its key features here.
  • Plain text - no unexpected special characters added.

 

Notepad++ Scenarios

 

Find all matching text strings within file/s

 

Example: Search SDM /log/stdlog.* files for "FATAL" error and see what else is near them.

 

1) From Windows Explorer, select the files you wish to view, right click and "Edit with Notepad++".

Both files will open in Notepad++.

Notepad++ opening files.png

2) Use "Cntrl F" to bring up the Find window and enter "fatal" in "Find what."

Choose "Find All in All Opened Documents" to search both documents at once.

Notepad++ Find.png

TIP: Note there is also a "Count" function available.

 

3) The results are displayed in the "Find" window at the bottom of the screen. Clicking on the line in this window will take you straight to the location in the file.

You can now begin trouble-shooting around that error - in this case a memory allocation error.

Notepad++ Fatal Find results.png


TIP: Searching ApplyPTF patches "<server name>.HIS" file for the string "PTF Wizard" will show all patches applied for CA products.

 

Find text strings within files without opening them

 

Example: An error has appeared for a user with the string "Could not fetch Event information Error." You remember that this may be recorded in a customisation, but can't recall where.

 

1) From within Notepad++, use Cntrl F and click "Find in Files."

2) Enter in the string you wish to search in "Find what" - you don't need quotes around it.

Choose the directory of your modifications. It would typically be your SDM directory/site/mods.

Note: If you know if you are searching in ".HTMPL" or ".SPL" then you may enter that in "Filters."

Choose "In all sub-folders."

Search mode is "Normal."

 

Find All will now show all files and their locations where this message is referenced.

You can just as easily search other files for other strings.

 

It is particularly useful for browser errors which give a code extract.

Again, clicking on the "Find result" line will bring up the file at the right line.

 

Notepad++ Search results find in files 2.png

PRO TIPS:

  • Powerful "regular expressions" are available here. This is a very powerful, albeit higher learning curve, way to do more complex searches. Check the internet for guides.
  • "Extended" search allows for search and replace of non-printing characters like carriage returns such as \n and \r.

 

Compare two files for differences - a crash course in "plugins."

 

Example: Service Desk Manager would not start, until the prior NX.env file was restored. Now you wish to know what is different between the old and new NX.env files.

 

1) For this, you'll need to load a plugin. Notepad++ is great for the number and quality of plugins available to achieve particular tasks.

The first time, go to the top menu Plugins, Plugins Manager, Show Plugins Manager, and choose "Compare" from the "Available" tab.

2) Open the two documents that you wish to compare.

TIP: It is best to give them distinct names. I like to work with "GOOD_" and "BAD_" so that I know which is which.

3) From Plugins, choose "Compare" and then "Compare" again.

Notepad++ Compare.png

4) Results will now be displayed, with differences marked for lines which are present in one file but not the other, or which have different text.

There is also a "Navigation" bar at the right, to show where differences lie in the overall documents.

There will be "false" readings - but at an acceptable number.

 

TIP: "Page down" moves both screens at once, which is useful. You can break this link under "View, Synchronise Vertical Scrolling."

 

Two examples of  differences are shown below. The "CANCHK" option is installed on one and not the other. And there is a different date of deinstall for an option.

Notepad++ Compare results 1.png

Moving on, there are many differences in this file, including one case of what appears to be file corruption, with a garbage character shown in the file.

As SDM reads NX.env at startup, this possibly may be sufficient to explain the difference - although further review would be required to confirm this, of course.

Notepad++ Compare results 2.png

 

Only keep the files open that you need - "Close all BUT this"

 

A quick tip, but if you open up a file, and don't need the others, you can get rid of the other tabs by right clicking the tab and choosing "Close all BUT this."

Notepad++ Close all BUT this.png

 

Go to a specific line in a file

 

Sometimes you are fortunate enough to have a browser error which lists the specific file and line where the problem is occurring. You can go straight to that line number.

Example: Error at line 325 in detail_in.htmpl. File not found.

 

Use "Cntrl G" to go to line 325 in this file. You can then see if that file exists, or check out the problem further.

 

 

TIP: The problem is not always *at* the line number given. Often it is just before, as it exits the previous section of code.

 

Use "Alt" for block text selection

 

Another quick one, but hold down the "Alt" key while dragging the mouse cursor lets you do block text selection, which is useful for pulling multiple lines of pieces of data out.

Notepad++ block selection.png

This can then be pasted eg:

2767 milliseconds

9696 milliseconds

9697 milliseconds

9697 milliseconds

 

TIP: Same functionality exists in MS Word.

 

FTP upload and download

 

This lets you connect to an FTP server to upload and download files directly from within Notepad++.

Example: Support files are at:

ftp://supportftp.ca.com/<site id>/<case number>/files_from_customer

ftp://supportftp.ca.com/<site id>/<case number>files_from_ca

 

I won't go through this example, as I honestly haven't used it (regular command prompt FTP works just fine for me, or Filezilla on special occassions).

However, it is worth noting that it is there.

Go to: Plugins, NppFTP, click on the "gear wheel" and enter in your settings.

 

Notepad++ FTP settings.png

 

 

View text files in friendly format

 

One feature that makes reading files "easy on the eyes" is the ability to flag the contents as seen by an editor. For example, use the Languages, "HTML" view to view your HTML files.

 

Notepad++ Language.png

 

"Tail" logging to see logs update in nearly real time

This is a great favourite of system administrators. The old UNIX favourite has been approximated as "Document Monitor" in Notepad++.

Have your logs scroll by on the screen, as you watch for particular messages.

 

Example: Get to a point a click before a "known problem" in the web client interface, turn on the Document Monitor, click within the web client to trigger the problem and see what is written at precisely that time.

 

First time:

1. Plugins, Plugin Manager, Show Plugin Manager and “Document Monitor” form "Available."

2. Notepad++ will prompt you to restart itself.

To activate:

3. Select Plugins and Document Monitor, "Start to monitor.” This will update the tail every three seconds.

 

TIP: Combine it with syntax highlighting - see next section - and you can have "FATAL" errors and other messages that are of interest to you highlighted in real time.

CAUTION: Some versions of Notepad++ did not handle this feature well. The earlier versions and the most recent versions are all good to my knowledge.


Syntax highlighting - using "User Defined Language" to colour code messages

 

This has changed a bit between versions (I'm writing against Notepad v6.6.7), but you can highlight key text by setting up a Document Map. This uses the same "Defined Language" as for the "friendly" view mentioned above, except that you can customise it to the issue you are facing at the time.

 

TIP: Don't go overboard with highlighting. A few key phrases are easier to handle than a rainbow.

PROTIP: Combine it with Document Monitor to track specific issues in real time.

 

But first, the "easy way" of highlighting text is simply to highlight a phrase that you're interested in on-screen, and all instances of that phrase will automatically be highlighted - no setup needed.

 

Enabling User Defined Language, AKA "coloured keywords."

1. Begin with a small document with samples of the phrases you wish to find in it. Do NOT start with your 5Gb text file, as this will lead to slow performance while you build the map.

2. Language, "Define your language." (Also available as a button at the top of screen with the lightning bolt).

3. Create New and give it a name. Eg "SDM."

4. Under "Keyword Lists" enter all of the keywords that you wish to define. Eg:

 

Group 1 - Important SDM messages. Foreground colour orange. Bold.

ERROR

 

Group 2 - Critical SDM messages. Foreground colour yellow, background red. Bold.

FATAL died SEVERE_ERROR EXIT RESTART

 

Group 3 - SDM messages of interest to a particular problem. Foreground colour bright blue. Bold.

"milliseconds to complete" "The following statement took"

 

Note that phrases must be entered in double-quotes.  I recommend "bold" for all text to make it stand out.

 

Notepad++ User Defined Language.png

 

5. Simply close the window to complete - use the "X" at the top.

6. Turn it on by Languages, and "SDM" will be right down the bottom in the User Defined section at the bottom.

 

Here is the result:

Notepad++ User Defined Language Results.png

 

One thing it doesn't do well

 

Or at least, I don't think it does. Notepad++ is excellent at searching files for text strings, but if you then want to go and search those results, the procedure is:

1) Go to Find Results pane and "Cntrl A" to select all.

2) Open a "New" tab. Paste in the results.

3) Run your second search against that. Repeat as needed.

 

You can get around this by using Regular Expressions to do something like the "NEAR" phrase, but it's more trouble than it's worth for me to remember.

If anyone has a workaround or this is updated into the product, let me know.

But really, this is a very small concern compared to the majority of the work that I do successfully with Notepad++.

 

A bunch of miscellaneous tips

 

Going to throw some together here:

  • Macros - Useful for repeated actions.  See the "Macro" menu.
  • Sessions - Use a File Save/Load Session to tag and then open up a group of files that you work on. For example, you may save NX.env, <server name>.his and web.cfg as a session called "SDM environment files."
  • View files side-by-side, instead of tabbed view. Right click the tab and either "Move" or "Clone."
  • See the "Notepad++ Cheat Sheet" at the bottom of resources for a handy list of shortcut keys grouped by function.
  • "Find and Replace" is useful.
  • There is a Tetris clone plug-in called "Falling Bricks." But it is very basic and won't improve your life. :-)

 

I hope this overview helps you to better tackle those large text files, and ease your system administration.

 

Please add comments, further text editor tips or a "Like" at top right.

 

Thanks, Kyle_R.

26 comments
3 views

Comments

02-18-2018 09:38 PM

I've always used the "Alt" key for block text copying and deleting. (See: Use "Alt" for block text selection)

 

I hadn't thought about using it for insertions.

 

Thanks for a new use case for an old favourite!

 

Kyle_R.

02-16-2018 06:12 AM

Thanks for the reminder on the Alt key function.  I always have to use the Help function for a quick refresher on key combinations.

02-16-2018 05:58 AM

If you want to paste any kind of characters into several lines at once, position the cursor into the first line, press the ALT key and drag the cursor to the last line where you want to do the input. Than insert the character or the clipboard content and voila you're done. This also works if you want to delete any columns!

 

 

Delete any columns:

 

Cheers

Christoph 

10-09-2017 01:24 AM

Thanks Enrique! Kyle.

10-09-2017 01:24 AM

Thanks Don - mentioned that under the Solutions heading. Yeah - wall of text, I know. Thanks, Kyle.

10-05-2017 08:36 AM

You can also change the Preferences > Backup option (uncheck) to forget the open files in the last session, so simply closing the program closes all open files and the next execution starts with a clean session.

 

10-05-2017 07:42 AM

There is a Close All in the File menu option.

 

Don

10-05-2017 12:07 AM

Is there a way to "Close All" files in Notepad++?

 

Why yes, yes there is!

 

Regular Notepad++ users will have noticed that it is easy to accumulate open files as you work on them.

It is often needed to clean house at the end or start of a session to a clean slate of no open tabs.

 

You may individually close the tabs of course with the "X" or use the existing Close functions on the right mouse button to:

  • Close (current tab)
  • Close All BUT This
  • Close All to the Left
  • Close All to the Right

 

But oddly there is no:

  • Close All

 

 

 

Solution

The functionality to do this is already in Notepad++. 

Instead of being on the mouse right-click menu, it is by default available on the File menu or as a hotkey.

 

The Default hotkey combination is Cntrl + Shift + W. Use this, and all of the tabs are closed!

 

 

Ask me why "Close All" is not on the right click menu where all of the other "Close" items are, go on . . .

 

I don't know. 

 

 

Still, it is not an intuitive string to remember, nor easy to stretch the fingers to click that combination, so if you want to change it to something easier to remember such as Cntrl + Shift + C (C for "Close" - easy to remember), then you may through the Shortcut Mapper.

 

1. Open Shortcut Mapper from Settings.

 

 

2. Double-click "Close All" to edit the key.

 

 

3.  Choose your preferred hotkey string, being careful not to wipe out something else, in particular the commonly used "Cntrl + C".

 

 

And there you have it - an easy way to close all of those pages that are open.

 

Just like manually closing a tab, it will still prompt if there is unsaved information.

Now that you have  Shortcut Mapper open, you may want to have a look at some of the other information here. Some powerful stuff!

 

 

 

Now you may want to ask me what that Ampersand (&) is about in the Shortcut "Name" field.

 

Don't know the answer to that either. It's got something to do with the Menu system.

 

And that's as good an answer as you're going to get from me now on that one!

If someone knows a good use for it, feel free to respond.

 

Thanks, Kyle_R.

08-21-2017 09:34 PM

Thanks for the feedback Enrique.

 

If people aren't familiar with the power of RegEx, the above link goes to the Notepad++ site which has more helpful links off to RegEx tutorials, including a RegEx Quick Start Guide.

 

If you can find the time, a small worked example and screenshot of one of your simplest "bread and butter" queries from Notepad++ would be appreciated.

 

This post actually lives in the public CA Communities "Service Management" space. When you see it elsewhere, it is because it has been Shared. 

And yes, I've sometimes regretted not putting it into a more generic location, as I agree that Notepad++ is useful across the board!

 

Thanks, Kyle_R.

08-18-2017 11:20 AM

Another useful function in Notepad++ specifically to scan logs for related messages is the Regular Expressions support. You can use RegEx to filter the FAILURE or SUCCESS messages your are tracking based on a second and/or condition.

 

I'm glad to see this extensive discussion on Notepad++ in the Experts Forurm, albeit not in the primary space I review. I will forward this discussion link to the Security EF.

08-17-2017 09:38 PM

Use the 32-bit Installer for Notepad++ to get Plug-In Manager

 

I'm including a useful note from EdRoyston that he made in another location, that I hope he doesn't mind me using.

 

I can confirm that the 32 bit version of Notepad is the way to go at the moment, because of the Plug-In Manager.

 

- - - 

The Plug-in Manager is unfortunately not available for the 64-bit version of Notepad++.

This makes updating some of the plugins (and getting new ones) a little more difficult.

Also, the "non-install" version of Notepad++ is useful when you are working on client workstations/servers where you can't install anything but are required to edit text documents and need something a little more than ordinary Notepad.

There are some useful XML plugins available that are really great for pretty-printing code. When you are hacking away at configuration files and REST queries for CA products, this sort of "help" comes in handy. The JSON output formatter is also very useful as well.

- - - 

 

Thanks, Kyle_R.

03-13-2017 07:25 PM

Security Alert: Upgrade to Notepad v7.3.3 to avoid CIA hacking issue

 

Please upgrade to the latest version of Notepad v7.3.3 (at time of this post) to avoid the CIA hacking issue.

 

Notepad++ Fix CIA Hacking Issue 

 

Notepad++ also has an Auto-Update for patches as well.

 

Thanks, Kyle_R.

07-22-2016 12:51 AM

Tip: Using Notepad++ to suppress lines

 

Typically you use Notepadd++ to Search and show lines of key importance.

 

But sometimes you wish to do the opposite. You wish to exclude lines that are not important.

 

Here's how you do that.

 

Example: Do not show any line with "SIGNIFICANT" as the message level type.

 

 

1) Cntrl H to bring up Search and Replace.

 

2) Your keyword/s are placed between the dots eg For "SIGNIFICANT" it is:

 

                    .*SIGNIFICANT.*\r?\n

 

3) Nothing is placed on "Replace with."

 

4) (Optional) Match case.

 

5) Use Regular expression.

 

6) Click "Replace All."

 

 

 

WARNING: Data will be lost if you then Save the file. Work in a Copy only to prevent against data loss.

 

TIP: Once you have put your Search condition in, it is available for later use from the dropdown arrow another time.

 

And here is how a sample file ends up with all SIGNIFICANT level messages removed:

 

 

Thanks, Kyle_R.

06-02-2016 10:07 PM

Tip: Using Notepad++ as a “Notepad with sections”

 

Just a quick tip that I came across for using Notepad++ as a quick notepad.

We’ve all found it useful to jot down items in MS Notepad. This is a great utility tool when you just want a quick text file. It’s everywhere, easy to use, doesn’t put in any weird formatting and gets the job done.

 

But you may find a use for the following Notepad++ “Hack” (What we we used to call “Tips” in the old days).

 

You can use Notepad++ with Language “XML” to write text with expandable and collapsable sections.

 

1. From Notepad++, make a new file and choose Language, XML.

 

2. Write out your notes using XML tags for the headings eg:

 

text

text

 

 

text

text

 

 

3. You may now expand and collapse sections as you wish with the "+" and "-" symbols.

 

 

 

Now I’ll admit that this isn’t the greatest text editor in the world, but it may find a place for quick long notes on a server, which suit breaking up into sections.

 

Indentation

You may use select and "Tab" to indent a section.

 

Alternatively, there are Notepad++ plugins that give better use of indentation through keystrokes, such the "XML Tools" plugin.

 

1. Open Plugin Manager in Notepad++

Plugins, Plugin Manager, Show Plugin Manager.

2. Install XML Tools plugin

Search "XML Tools" from the "Available" option then click in install.

3a. Now you may use the shortcut keys CTRL+ALT+SHIFT+B to indent all of lines automatically.

3b. Or check under Plugins, XML Tools, Pretty Print (Text indent) for a different effect.

 

 

If you've found any other good uses for Notepad++, please share them here.

 

Thanks, Kyle_R.

08-05-2015 07:59 PM

Hello Michael_Mueller, looks like you got your wish on " interested in syntax highlighting for majic and spell". Please see the entry from James above. Thanks, Kyle.

08-05-2015 07:55 PM

Thanks James,

 

Really great to see that my original post has led to you laying out the features of another great tool and use cases. Couldn't hope for better. :-)

 

I know some of that stuff can be done in Notepad++ as well, but horses for courses as they say. Your example of the macro SPL editing is great.

 

I may even have to give TextPad another go. I've used it before, but got stuck in my ways with Notepad++ because it does what I need, day in and day out, with analysing SDM log files.

 

Thanks, Kyle_R.

08-05-2015 07:49 PM

Thanks Tiago,

 

You're welcome. You've got a great selection of tools listed there, so I recommend that people check out your link.

 

Kyle_R.

08-05-2015 10:11 AM

Awesome.

08-04-2015 10:15 PM

My personal favourite for large files is Textpad (https://www.textpad.com).  Like Notepad++, it handles the largest 'stdlog' file with ease, does syntax colouring, and has an excellent 'block select' mode that I use regularly for editing large 'pdm_load' files.  It includes a file comparison tool - but a rather dated one based on Unix 'diff'. For serious file comparison I turn to 'Compare It' (more on that shortly).  My two favourite features, however are: the ability to refresh the display from the current copy of the file (Alt F-R is burned into my muscle memory from years of watching 'stdlog's) and an excellent regular expression facility which is brilliant for doing things like concatenating all the split records in a 'pdm_extract'. 

 

Textpad is also extremely handly for editing spel - just define the file extensions '.maj' and '.spl' as alternatives for '.cpp' and apply the C++ syntax coloring.  Unlike Notepad++, there is a license fee for Textpad, but it's repaid my investment (made 10 years ago) many times over.

 

And for macros - well, here's my recipe for avoiding eyestrain:

 

1. define the file extension '.mac' as indicating 'C++' (in addition to '.spl' and '.maj').

2. pdm_extract -f "select * from Spell_Macro where sym like 'your sym here'" > yoursym_V01.mac.

3. Open 'yoursym_V01.mac' in textpad, select the line that contains the macro fragment.

4. Run a Textpad macro that changes the Regular Expression '\\\\0012' to '\n' on the selected text (need to escape the '\\' in '\\0012').

5. Escape the leading double quote of the 'fragment' and the spel code is now multi-line and has C++ syntax colouring applied.

6. When your edits are done, select the spel fragment and run a Textpad macro to change regex '\n' back to '\\0012'.  Remove the escape from the front of the fragment string.  Save as 'yoursym_V02.mac'.

7. pdm_load -vf yoursym_V02.mac

 

As for file comparison, I was so impressed with 'Compare It' (http://www.grigsoft.com/wincmp3.htm) that I bought a license within days of downloading it, and have used it ever since.  I recently used 'Compare It' to scan for and re-apply a large number of htmpl customisations as part of an upgrade project and it made the task almost enjoyable (yes, I really do need to get out more).

 

Have fun...

James

08-04-2015 03:52 PM

11-11-2014 11:39 PM

Thank you Kyle.

Excellent!

11-11-2014 08:55 PM

I've added a further Notepad++ tip here: Communities: Syntax highlighting for Perl and many other languages.

 

This tip is particularly good for pasting in code snippets into CA Communities in a specific language that the Communities Syntax highlighting does not support out-of-the-box, such as Perl. E.g.

 

#!/usr/local/bin/perl 

 

$count = 0; 

while (<stdin>) { 

    @w = split; 

    $count++; 

    for ($i=0; $i<=$#w; $i++) { 

  $s[$i] += $w[$i]; 

    } 

} 

 

 

for ($i=0; $i<=$#w; $i++) { 

    print $s[$i]/$count, "\t"; 

} 

print "\n"; 

 

 

Thanks, Kyle_R.

09-17-2014 11:15 AM

I use Notepad++ quite extensively (For far more than SDM too) but never really looked into the plugins a whole lot. Had no idea there was a Compare module (I currently use WinMerge for that, but going to check this out to see if thats one less app to have around). Document Monitor also looks promising, currently using the microsoft log viewer for this but if NP++ can handle it too that'd be great, it can sometimes take awhile to open large files that NP++ generally handles better.

09-17-2014 06:44 AM

This is great, thank you!  I already use it for some things, but wow - I'll be using it for much more now.

Tammy

09-17-2014 04:08 AM

This is perfect information. Thanks a lot.

I would be very interested in syntax highlighting for majic and spell

09-17-2014 03:52 AM

Great write up. Thanks Kyle