Solaris

cgrep — a grep enhancement to show preceding lines

0

Solaris grep has no way to print­ing the lines sur­round­ing a match. Yet my most com­mon use of grep is to locate par­tic­u­lar strings in a log file, with the goal of look­ing at the log mes­sages pre­vi­ous to them. There is a sim­ple solu­tion for this. And also, please note, I did not write any of the code linked here. Just post­ing it to help oth­ers find it.

(more…)

Install sudo on Solaris 10 (intel, x86)

0

Instruc­tions on installing and con­fig­ur­ing sudo on Solaris 10. It is really easy.
(more…)

Solaris troubleshooting

1

Some quick notes that I will expand at some point. This is based on data requests Ora­cle Sup­ported requested while trou­bleshoot­ing a boot issue on a Sun V440.
(more…)

System uptime in Python

0

Here is a short recipe to get sys­tem uptime in Python. Tested so far on Ubuntu linux and Solaris. Obvi­ously won't work on Windows.

gist on Github for sys_uptime.py

import subprocess

def uptime():
    raw = subprocess.check_output('uptime').replace(',','')
    days = int(raw.split()[2])
    if 'min' in raw:
    	hours = 0
    	minutes = int(raw[4])
    else:
    	hours, minutes = map(int,raw.split()[4].split(':'))
    totalsecs = days*24*60*60 + hours*60*60 + minutes*60
    return totalsecs

print 'System uptime of %d seconds' % (uptime())

How to Configure <span class="caps">NTP</span> in Solaris 10

0

This is a sim­ple work­ing con­fig­u­ra­tion method posted in the com­ments of this page. The page is offline but I found it in Google Cache and ver­i­fied that it works. Repost­ing it here for posterity.

(more…)

Fixing sendmail error "[<span class="caps">ID</span> 702911 mail.crit] My unqualified host name unknown; sleeping for retry"

0

This prob­lem annoys the heck out of me, and appar­ently thou­sands of other Solaris admins. I can't imag­ine the rea­son some­one thought send­mail should log this error every few min­utes about the stu­pid host­name, but must have been a good one because the app sure is adamant about it.

(more…)

How to Download Oracle 11gR2 from command line

Ora­cle doesn't give direct down­loads to the Ora­cle soft­ware. You gen­er­ally forced to go through a few web pages to login to your Ora­cle account, then accept a license agree­ment, then finally get the files. With remote servers you would be forced to down­load the file locally then push it to the server. Ora­cle 11 is upwards of 1 GB, so this isn't fea­si­ble. Bet­ter yet is to down­load directly to your server. That said, it is really quite sim­ple — just use wget with authen­ti­ca­tion credentials.

(more…)

On turning excellence in Python into epic mediocrity in <span class="caps">SQL</span>. Very successful mediocre <span class="caps">SQL</span>.

Today is a brute-force day. I needed to col­lect second-by-second data from a data­base over a 4-hour period. There were 2 queries that needed to be run, each just gen­er­at­ing a sin­gle num­ber for each sec­ond (count­ing events/sec). If I knew any­thing about SQL these could prob­a­bly be done in exactly 2 queries. I don't know any use­ful SQL so I ran indi­vid­ual SQL queries for every sin­gle sec­ond. That's 28,800 total queries.

I didn't hand-write them, of course. I first wrote a python script to gen­er­ate the queries and craft a sim­ple SQL script. After gen­er­at­ing my two SQL scripts (each 3 MB) and run­ning them, I had 2 data files each con­tain­ing 14,400 data points. Then I used my text edi­tor, Edit­Pad­Pro, to trim the white­space and con­dense to a sin­gle col­umn of num­bers. Then I pasted into Excel.

Then I made a line chart from the two num­ber sets which almost brought Excel to its knees, but it worked! It was cool but there was no way to zoom in on the smaller more inter­est­ing sec­tions, plus the thing took sev­eral sec­onds to redraw after any scrolling. I ended up cre­at­ing sep­a­rate charts for each hour so the graphs ren­der much faster. Now I am cal­cu­lat­ing some inter­est­ing max, mean, and mode num­bers to reduce it all to use­ful sum­mary numbers.

The last few hours were there­fore a major tri­umph of brute force effort: writ­ing a pro­gram to gen­er­ate two other pro­grams (the SQL queries) to gen­er­ate the 28,800 data points. All because I only know very basic SQL queries.

It was a blast!

BONUS — my gen­er­a­tor pro­gram under­stands nat­ural lan­guage, so when I ran it I did 'elog_count.py today 01:00:00 to today 05:00:00 by sec­ond for "Inform­Pe­ri­odic" '. Then once again for 'Infor­m­Val­ueChanged' for the other query.

Go to Top