Thursday, April 20, 2017

logrotate -- Use YYYYMMDD (ISO 8601) format and the name won't change

Quick, which file contains records from 18 April 2017 ?

syslog
syslog.1
syslog.2.gz
syslog.3.gz
syslog.4.gz
syslog.5.gz
or how about here?:

syslog
syslog-20170417.gz
syslog-20170418.gz
syslog-20170419.gz
syslog-20170420

With the first set, it depends on today's date, because rotating the logs means 3 -> 4, 2 -> 3, 1 -> 2, and the most recent -> .1, and whatever answer you came up with today will be different next week.

And if you archive or back up your log files, either you need to rename or they will be overwriting each other.

Logrotate already has a feature for this called 'dateext'; just add this to /etc/logrotate.conf :

diff --git a/logrotate.conf b/logrotate.conf
index 436713d..436f10d 100644
--- a/logrotate.conf
+++ b/logrotate.conf
@@ -1,13 +1,14 @@
 # see "man logrotate" for details
 # rotate log files weekly
 weekly
+dateext

to make it take effect globally.  You can also do it on a per- log-file type basis.
See man logrotate for more details.

Do this on every new system and you won't have this problem in the future
(that's why I wrote this post, so I don't forget).

This will take effect at next rotation time.  Existing files will not be affected, so you'll have to take care of those yourself.

Why YYYYMMDD format?
This is the right thing, it's the standard; it's an International Standard.
You don't have to worry about which side of the ocean you're on to figure out when 04/05/2017 refers to.
Dates in this format also naturally sort; ever see a bunch of file or folder names like 31jan17, 01feb17 15apr17, and have to sort them for processing ?  With a YYYYMMDD format that problem goes away.  It's unambiguous.



More here:  ISO 8601 - Wikipedia

Wednesday, May 11, 2016

FiOS Actiontec MI424WR-GEN3I router

Just recording a datapoint on what my current version is:

Firmware Version:40.21.18
Model Name:MI424WR-GEN3I
Hardware Version:I
Serial Number:CSXI3430506051
Physical Connection Type:Coax
Broadband Connection Type:

Still seeing these messages hourly:

May 10 18:02:21 2016 System Log CWMP Periodic Inform 204 No Content
May 10 18:02:17 2016 System Log CWMP Periodic Inform challenge response with 200 OK from server
May 10 18:02:16 2016 System Log CWMP Periodic Inform initial 401 challenge
May 9 18:02:21 2016 System Log CWMP Periodic Inform 204 No Content
May 9 18:02:17 2016 System Log CWMP Periodic Inform challenge response with 200 OK from server
May 9 18:02:16 2016 System Log CWMP Periodic Inform initial 401 challenge
May 8 18:02:22 2016 System Log CWMP Periodic Inform 204 No Content
May 8 18:02:18 2016 System Log CWMP Periodic Inform challenge response with 200 OK from server
May 8 18:02:16 2016 System Log CWMP Periodic Inform initial 401 challenge

This is apparently " CPE WAN Management Protocol (CWMP)", part of the TR-069 standard; the spec is 200+ pages.

There are a number of Open Source implementations, the github repo at
seems to be the most active.

Something you could install on your OpenWRT router.

Wednesday, March 11, 2015

OSX / Mac Screen Capture Tricks

Quick way to capture just a window: Cmd-shift-4
you can drag out an rectangle,
or press space bar (icon will change to camera)
window below will change blue, click on it to get the whole window.
Press 'esc' to cancel.

Screen shot of entire screen:  Cmd-shift-3
if you have multiple monitors,
a .png file for each.

These create a .png file on your desktop.

If you hold down ctrl, it is only copied to the clipboard.  Then, you can paste it to preview (New from clipboard) or other graphics program.

There is also a Grab utility (in /Applications/Utilities) included with OS X:
Cons:   creates .tiff files only (not as convenient for me)(easily converted with Preview, just Save As..  and change the format)
Pros:  timed capture allows you to get pulldowns, also mouse pointer can be included (see Preferences..)


Some of these tricks from (orginal article no longer available):
Wayback machine: usingmac.com/2008/12/21/mac-screen-capture-tricks

even more tricks here:
http://www.tekrevue.com/tip/how-to-customize-screenshot-options-in-mac-os-x/

 - change folder where files go
 - change format (for example, to jpg, gif, tif, etc)
 - remove drop shadow
 - change file name (so it's not "Screen Shot")

Most of these start with
defaults write com.apple.screencapture 

be sure to do
killall SystemUIServer

for them to take effect.

Sunday, November 9, 2014

Google Cloud Print -- getting offline printers back online (for Chromebook, or other devices)

Quick Fix: scroll to Solution below.

What it is:  Google Cloud Print is a great way to share your printers with someone else; all you need is the Chrome browser.

A friend needs to print something?
They could send you the file, you could save it, open it and hope it looks the same, doesn't contain any malware, you have the same program and version, and then print it.  Or they could install the necessary drivers, software, and then come over and configure a new printer.
Or, you can just share the printer with them (like you do any google doc),
and it will appear in their list of printers available to them (at least from Chrome).
No additional software to install,
no special configuration,
just select that printer in the list of available printers.

Visiting an office or campus, and don't have access to the network printers, don't have the drivers available, etc. ?
Having someone share their printer via google cloud print is an easy way for you to print something there and not bother them every time.  If you don't have a printer, or want to pay for some high-quality output, you can also print directly to a Fedex/kinkos office (and probably other commercial print services) ("Print to Fedex Office" is already available when you print from Chrome).

You don't even have to be on the same network, so you can print on the printer at work while you're at home or on the road, or vice versa.  Some newer printers come "Cloud print enabled", other (older dumb, or directly attached) printers will need to have a Chrome browser running on a computer that can print to that printer (and is shared with you).  An old or cheap computer could be set up to run chrome and be the office "print server", saving everyone one else from having to all install the

Sharing printers via google cloud print may be the only way to print from a Chromebook or Android (direct printing, not by emailing files or photos), because the printer may not support this device or have "drivers" available (stupid manufacturers should use common open protocols, not proprietary device-specific controls).

Symptom:

Occasionally, the printer goes offline.  After months of working fine, it stopped, and said "Printer offline for 10 days", even though it was on, and I had printed to it (minutes before) from the computer where I had shared it.  "Cloud Printers"
showed it as offline, but refreshing did not change the status.
One thing that would probably work is removing, and then adding the printer again to Google Cloud Print (and then probably having to share it again with everyone).  I was starting down this route, and the first step to adding a printer is to go to Chrome settings, find Google Cloud Print (fastest way is to just type "print" into the Search settings box), and then click the Manage button.

Solution:

Just viewing the devices listed in Google Cloud Print brought the printer back online.
In fact I heard the printer wake up and it commenced to printing the queued document.
Here's a shortcut to that section in your settings:
  -- you'll need to copy and paste it manually (browser security reasons),
or search in settings for "printers".

Now, go the the "Cloud Printers" link above, or if you have the tab open already click refresh, and now it should be online.


If you are using Windows and want to print from other programs, there is "Cloud Printer" software (available from Google).

Why does the printer go offline?  I don't know.
Did this work for you?
Let me know.

Update 2016-02-21This has been reported as a bug at the link below. To vote for it to get fixed, please go to the link and click the star icon near the upper left corner of the webpage. You need to be signed into your Google account to vote. 
https://bugs.chromium.org/p/chromium/issues/detail?id=588462 

Thursday, March 20, 2014

Shell history: Set HISTTIMEFORMAT to save & see when you executed commands

this is a really useful setting that I didn't know about until a couple years ago.

HISTTIMEFORMAT='%F %T '

So used to it now, I get annoyed when I create a new account/login and don't have it.

Why:  ability to correlate system artifacts with commands.
There's a file here, when/how did I create it?
Now in the shell, 'history' will show the time of commands; which may help you track down when you created (or deleted) a file, etc.

Some issues:

  • if you start a new shell, and it ends after this one, $HISTFILE can get overwritten.
    Problem if you like to have lots of shells & windows at the same time.
  • after a while, with a lot of history, only the last $HISTSIZE (or HISTFILESIZE) commands will be saved.
  • your $HISTFILE contains unix epoch times, so not easily read or grep'd directly.
    (However, you can easily save and load with history -w / -r )
  • recorded time is not retroactive.  All previous commands prior will have the time when you first set HISTTIMEFORMAT, so start today!
I have solutions to most of these, so each of my screen windows have their own history, also emacs, xterm shells,  and a per-directory history as well.
How many commands?  121859 (just one system, my main laptop last 2.5 years usage),
this doesn't count a few other development systems.

Seems like a lot, but that's only ~133 commands per day average.


... So what is the ideal system audit trail ?