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++."
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.
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++.
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.
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.
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.
- 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.
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.
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.
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."
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.
This can then be pasted eg:
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.
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.
"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.
1. Plugins, Plugin Manager, Show Plugin Manager and “Document Monitor” form "Available."
2. Notepad++ will prompt you to restart itself.
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.
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.
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:
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.