Hello, World!
Yeah, I know, that's lame, but hey! I'm a lamer!
Anywho, I've been maintaining radio silence for several years, but I need to
break out of my old habits. Figured I may as well go back online and
start blogging again. Maybe, just maybe, I can help someone with oddball
stuff that I constantly seem to find interesting and fun.
I'm an over 17-year Linux/BSD/Mac veteran. Been in IT since 2005. Before that, I drove 18 wheelers over the road, forklifts, and did various petroleum, odd job, and landscaping work. Hosted a late night radio show at a college radio station at which I wasn't a student, worked as a waiter, customer service agent, night audit clerk at a hotel, and even worked in the nuclear industry for a little bit.
Then my ex-wife happened -- the reason for the radio silence. Then the new wife, whom I lovingly refer to as "Wyfe", nudged me along into the IT field. I started with desktop support, moved to server administration, went into minor penetration testing (mostly manual tools), website design & build, then to analog telephony and voice over IP. Also tried out network configuration & troubleshooting. Now, scarily enough, I'm about to the "management" stage of the career path. Still get to handle the Linux/UNIX servers, though, which is a huge plus!
Wow, I'm sharing way too much!
Finally going to college. About dang time, right? Well, I'm in the BS IT Sec program with Western Governors University (online). I'm almost 3/4 done! Woot! Hopefully, by August 2017 or January 2018 I'll be a graduate and working toward my masters in IT Security... We'll see, right? Still have a long way to go, but trying to stay optimistic about it!
And, I'm proud to say that, no, I don't do Pokemon Go!
Cheers!
--0Net
0NetEnv Code & Crap
Saturday, August 6, 2016
conky config for fluxbox on slackware 14.2
I've used Slackware since 1999 and one thing I've always struggled with is a decent battery monitor...
Decided a few weeks ago to use conky.
Added this line to ~/.fluxbox/startup:
conky -d --config ~/.fluxbox/conky.config &
Added the following menu entry to ~/.fluxbox/menu
[exec] (restart conky) {pkill conky && sleep 1 && conky -d --config ~/.fluxbox/conky.config}
Here's a screenshot:
~/.fluxbox/conky.config:
background no
use_xft yes
xftfont Bitstream Vera Sans Mono:size=8
xftalpha 0.8
update_interval 5
total_run_times 0
own_window yes
own_window_type override
own_window_transparent yes
own_window_colour hotpink
own_window_hints undecorated,below,skip_taskbar,sticky,skip_pager
double_buffer yes
minimum_size 280 5
draw_shades yes
draw_outline no
draw_graph_borders yes
stippled_borders 8
border_margin 4
border_width 1
maximum_width 290
default_color darkgrey
default_shade_color black
default_outline_color black
alignment bottom_right
gap_x 4
gap_y 4
no_buffers yes
uppercase yes
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale no
use_spacer no
TEXT
${font TimesNewRoman:mono:bold:size=12}${color yellow}${alignc}${nodename}
${font TimesNewRoman:mono:italic:size=12}${color yellow}${alignc}SLACKWARE 14.2
${font TimesNewRoman:mono:italic:size=10}${color yellow}${alignc}${exec date +%Y/%m/%d:%H%M}${font}
${color yellow}$hr
${color yellow}UPTIME: $alignr $color ${uptime_short}
${color yellow}BATTERY: $alignr $color ${battery BAT0}
${color yellow}Temp: ${color}${alignr}${exec sensors | grep CPU: | sed 's/^.*+//g'}
${color yellow}Fan Speed: ${color}${alignr}${exec cat /sys/devices/virtual/hwmon/hwmon*/fan*_input} RPM
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc CPU:${font}
${color red}CPU1: ${cpu cpu1}% $alignr $color ${exec awk '/cpu MHz/{i++}i==1{printf "%.f",$4; exit}' /proc/cpuinfo} MHz
${color red}CPU2: ${cpu cpu2}% $alignr $color ${exec awk '/cpu MHz/{i++}i==2{printf "%.f",$4; exit}' /proc/cpuinfo} MHz
${color red}CPU3: ${cpu cpu3}% $alignr $color ${exec awk '/cpu MHz/{i++}i==3{printf "%.f",$4; exit}' /proc/cpuinfo} MHz
${color red}CPU4: ${cpu cpu4}% $alignr $color ${exec awk '/cpu MHz/{i++}i==4{printf "%.f",$4; exit}' /proc/cpuinfo} MHz
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc MEMORY:${font}
${color red}RAM: $alignr $color$mem/$memmax
${color red}Swap: $alignr $color$swap/$swapmax
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc WLAN0:${font}
${color red}WLAN0 Down: $color${downspeed wlan0}${alignr} k/s
${color red}wLAN0 Up: $color${upspeed wlan0}${alignr} k/s
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc ETH0:${font}
${color red}ETH0 Down: $color${downspeed eth0}${alignr} k/s
${color red}ETH0 Up: $color${upspeed eth0}${alignr} k/s
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc Connections: ${font}
$color In: ${tcp_portmon 1 32767 count} $alignr Out: ${tcp_portmon 32768 61000 count}${alignr}
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc File systems:${font}
${color red}/ $alignr $color${fs_free /}
${color red}/boot $alignr $color${fs_free /boot}
${color red}storage $alignr $color${fs_free /home}
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc Top Processes: ${font}${color}
01: ${color red}${top name 1} ${alignr}${color}${top cpu 1} ${top mem 1}
02: ${color red}${top name 2} ${alignr}${color}${top cpu 2} ${top mem 2}
03: ${color red}${top name 3} ${alignr}${color}${top cpu 3} ${top mem 3}
04: ${color red}${top name 4} ${alignr}${color}${top cpu 4} ${top mem 4}
05: ${color red}${top name 5} ${alignr}${color}${top cpu 5} ${top mem 5}
06: ${color red}${top name 6} ${alignr}${color}${top cpu 6} ${top mem 6}
07: ${color red}${top name 7} ${alignr}${color}${top cpu 7} ${top mem 7}
08: ${color red}${top name 8} ${alignr}${color}${top cpu 8} ${top mem 8}
09: ${color red}${top name 9} ${alignr}${color}${top cpu 9} ${top mem 9}
10: ${color red}${top name 10} ${alignr}${color}${top cpu 10} ${top mem 10}
${color yellow}$hr
${font TimesNewRoman:mono:italic:size=6}${color yellow}${alignc}Refreshed every 5 seconds
Hopefully this will help someone!
--Cheers!
-0Net
Decided a few weeks ago to use conky.
Added this line to ~/.fluxbox/startup:
conky -d --config ~/.fluxbox/conky.config &
Added the following menu entry to ~/.fluxbox/menu
[exec] (restart conky) {pkill conky && sleep 1 && conky -d --config ~/.fluxbox/conky.config}
Here's a screenshot:
Conky Screenshot |
~/.fluxbox/conky.config:
background no
use_xft yes
xftfont Bitstream Vera Sans Mono:size=8
xftalpha 0.8
update_interval 5
total_run_times 0
own_window yes
own_window_type override
own_window_transparent yes
own_window_colour hotpink
own_window_hints undecorated,below,skip_taskbar,sticky,skip_pager
double_buffer yes
minimum_size 280 5
draw_shades yes
draw_outline no
draw_graph_borders yes
stippled_borders 8
border_margin 4
border_width 1
maximum_width 290
default_color darkgrey
default_shade_color black
default_outline_color black
alignment bottom_right
gap_x 4
gap_y 4
no_buffers yes
uppercase yes
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale no
use_spacer no
TEXT
${font TimesNewRoman:mono:bold:size=12}${color yellow}${alignc}${nodename}
${font TimesNewRoman:mono:italic:size=12}${color yellow}${alignc}SLACKWARE 14.2
${font TimesNewRoman:mono:italic:size=10}${color yellow}${alignc}${exec date +%Y/%m/%d:%H%M}${font}
${color yellow}$hr
${color yellow}UPTIME: $alignr $color ${uptime_short}
${color yellow}BATTERY: $alignr $color ${battery BAT0}
${color yellow}Temp: ${color}${alignr}${exec sensors | grep CPU: | sed 's/^.*+//g'}
${color yellow}Fan Speed: ${color}${alignr}${exec cat /sys/devices/virtual/hwmon/hwmon*/fan*_input} RPM
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc CPU:${font}
${color red}CPU1: ${cpu cpu1}% $alignr $color ${exec awk '/cpu MHz/{i++}i==1{printf "%.f",$4; exit}' /proc/cpuinfo} MHz
${color red}CPU2: ${cpu cpu2}% $alignr $color ${exec awk '/cpu MHz/{i++}i==2{printf "%.f",$4; exit}' /proc/cpuinfo} MHz
${color red}CPU3: ${cpu cpu3}% $alignr $color ${exec awk '/cpu MHz/{i++}i==3{printf "%.f",$4; exit}' /proc/cpuinfo} MHz
${color red}CPU4: ${cpu cpu4}% $alignr $color ${exec awk '/cpu MHz/{i++}i==4{printf "%.f",$4; exit}' /proc/cpuinfo} MHz
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc MEMORY:${font}
${color red}RAM: $alignr $color$mem/$memmax
${color red}Swap: $alignr $color$swap/$swapmax
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc WLAN0:${font}
${color red}WLAN0 Down: $color${downspeed wlan0}${alignr} k/s
${color red}wLAN0 Up: $color${upspeed wlan0}${alignr} k/s
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc ETH0:${font}
${color red}ETH0 Down: $color${downspeed eth0}${alignr} k/s
${color red}ETH0 Up: $color${upspeed eth0}${alignr} k/s
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc Connections: ${font}
$color In: ${tcp_portmon 1 32767 count} $alignr Out: ${tcp_portmon 32768 61000 count}${alignr}
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc File systems:${font}
${color red}/ $alignr $color${fs_free /}
${color red}/boot $alignr $color${fs_free /boot}
${color red}storage $alignr $color${fs_free /home}
${color yellow}$hr
${font AvantGardeLTMedium:bold:italic:size=9}${color yellow} $alignc Top Processes: ${font}${color}
01: ${color red}${top name 1} ${alignr}${color}${top cpu 1} ${top mem 1}
02: ${color red}${top name 2} ${alignr}${color}${top cpu 2} ${top mem 2}
03: ${color red}${top name 3} ${alignr}${color}${top cpu 3} ${top mem 3}
04: ${color red}${top name 4} ${alignr}${color}${top cpu 4} ${top mem 4}
05: ${color red}${top name 5} ${alignr}${color}${top cpu 5} ${top mem 5}
06: ${color red}${top name 6} ${alignr}${color}${top cpu 6} ${top mem 6}
07: ${color red}${top name 7} ${alignr}${color}${top cpu 7} ${top mem 7}
08: ${color red}${top name 8} ${alignr}${color}${top cpu 8} ${top mem 8}
09: ${color red}${top name 9} ${alignr}${color}${top cpu 9} ${top mem 9}
10: ${color red}${top name 10} ${alignr}${color}${top cpu 10} ${top mem 10}
${color yellow}$hr
${font TimesNewRoman:mono:italic:size=6}${color yellow}${alignc}Refreshed every 5 seconds
Hopefully this will help someone!
--Cheers!
-0Net
password generator with argparse
Hello, World!
The following code works with either Python 2 or 3. Uses the "argparse" library (included with most versions of Python).
Most of the arguments I've written in Python (any version) have been done with if statements. We have a good number of those here, but this is the first time I've used argparse.
I'm not a professional developer, but if you have any questions, please let me know.
On with the code:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
license = """
# pwgen -- the pseudo-random password generator
#
# This software is distributed under the MIT license.
#
# The MIT License (MIT)
#
# Copyright (c) 2016 0NetEnv 0netenv@gmail.com
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the
# Software without restriction, including without
# limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice
# shall be included in all copies or substantial portions
# of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
# TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# NOTE:
# This software was tested on Slackware 14.2, Raspbian, &
# Mac OS X 10.11
#
"""
import string
import random
import sys
# first time using argparse library
import argparse
# wanted to change the formatting of the help menu a little bit, so used RawTextHelpFormatter directly
from argparse import RawTextHelpFormatter
typo = ''
c = 16
counter = 0
line = '-' * 40
# CREATE FUNCTION for PWGEN
def pwgen(z, t):
# EMPTY SET OF CHARACTERS
charsset = ''
# UPPERCASE -"O"
U = 'ABCDEFGHIJKLMNPQRSTUVWXYZ'
# lowercase -"l"
L = 'abcdefghijkmnopqrstuvwxyz'
N = '0123456789'
S = '!@#$%^&*?<>'
# make sure we're using an integer, not a char/string
z = int(z)
for type in t:
if 'u' in t:
charsset = charsset + U
if 'l' in t:
charsset = charsset + L
if 'n' in t:
charsset = charsset + N
if 's' in t:
charsset = charsset + S
if 'a' == t:
charsset = charsset + U + L + N + S
return ''.join(random.choice(charsset) for _ in range(0, int(z)))
# GET ARGUMENTS using ARGPARSE
parser = argparse.ArgumentParser(description='\n Create a random password\n\
Special characters, numbers, UPPERCASE -"Oscar",\n\
and lowercase -"lima" to avoid confusion.\n\
Default options (no arguments): -c 16 -a\n\
\t\tEnjoy! --0NetEnv@gmail.com', formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("-c", "--count", dest="count", action="store", help="password length")
parser.add_argument("-a", "--all", help="same as -l -n -s -u", action="store_true")
parser.add_argument("-l", "--lower", help="include lowercase characters", action="store_true")
parser.add_argument("-n", "--number", help="include 0-9", action="store_true")
parser.add_argument("-s", "--special", help="include special characters", action="store_true")
parser.add_argument("-u", "--upper", help="include uppercase characters", action="store_true")
parser.add_argument("-p", "--license", help="print license and exit", action="store_true")
# COLLECT ARGPARSE RESULTS
results = args = parser.parse_args()
# CHECK RESULTS
# Check that a length was given.
# If not, gripe and exit.
if args.count == '0':
print ("Input error:\nCannot create a zero length password.\nExiting")
exit (0)
# check character results and add to counter if
# selection is made.
if args.lower:
typo = typo + 'l'
counter = counter + 1
#print "lower"
if args.number:
typo = typo + 'n'
counter = counter + 1
#print "number"
if args.special:
typo = typo + 's'
counter = counter + 1
#print "special"
if args.upper:
typo = typo + 'u'
counter = counter + 1
#print "upper"
if args.all:
typo = 'a'
counter = counter + 1
#print "all"
if args.license:
print (license)
exit (1)
# CHECK COUNTER
# Check our counter and see if we used any command line
# options. We don't want to error out.
# try it gracefully. If no arguments are given,
# use defaults and tell the user.
# args.count comes from argparse and by default requires
# an input to '-c'. We want to get around that for the
# sake of convenience.
# Without further adieu, here's our if statement:
if args.count:
if counter == 0:
typo = 'a'
print ("defaulting to '--all'")
print (line)
print (pwgen(results.count,typo))
else:
if counter == 0:
typo = 'a'
print ("defaulting to '--count 16 --all'")
print (line)
print (pwgen(c,typo))
print (line)
#print typo
Cheers!
-0net
The following code works with either Python 2 or 3. Uses the "argparse" library (included with most versions of Python).
Most of the arguments I've written in Python (any version) have been done with if statements. We have a good number of those here, but this is the first time I've used argparse.
I'm not a professional developer, but if you have any questions, please let me know.
On with the code:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
license = """
# pwgen -- the pseudo-random password generator
#
# This software is distributed under the MIT license.
#
# The MIT License (MIT)
#
# Copyright (c) 2016 0NetEnv 0netenv@gmail.com
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the
# Software without restriction, including without
# limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice
# shall be included in all copies or substantial portions
# of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
# TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# NOTE:
# This software was tested on Slackware 14.2, Raspbian, &
# Mac OS X 10.11
#
"""
import string
import random
import sys
# first time using argparse library
import argparse
# wanted to change the formatting of the help menu a little bit, so used RawTextHelpFormatter directly
from argparse import RawTextHelpFormatter
typo = ''
c = 16
counter = 0
line = '-' * 40
# CREATE FUNCTION for PWGEN
def pwgen(z, t):
# EMPTY SET OF CHARACTERS
charsset = ''
# UPPERCASE -"O"
U = 'ABCDEFGHIJKLMNPQRSTUVWXYZ'
# lowercase -"l"
L = 'abcdefghijkmnopqrstuvwxyz'
N = '0123456789'
S = '!@#$%^&*?<>'
# make sure we're using an integer, not a char/string
z = int(z)
for type in t:
if 'u' in t:
charsset = charsset + U
if 'l' in t:
charsset = charsset + L
if 'n' in t:
charsset = charsset + N
if 's' in t:
charsset = charsset + S
if 'a' == t:
charsset = charsset + U + L + N + S
return ''.join(random.choice(charsset) for _ in range(0, int(z)))
# GET ARGUMENTS using ARGPARSE
parser = argparse.ArgumentParser(description='\n Create a random password\n\
Special characters, numbers, UPPERCASE -"Oscar",\n\
and lowercase -"lima" to avoid confusion.\n\
Default options (no arguments): -c 16 -a\n\
\t\tEnjoy! --0NetEnv@gmail.com', formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("-c", "--count", dest="count", action="store", help="password length")
parser.add_argument("-a", "--all", help="same as -l -n -s -u", action="store_true")
parser.add_argument("-l", "--lower", help="include lowercase characters", action="store_true")
parser.add_argument("-n", "--number", help="include 0-9", action="store_true")
parser.add_argument("-s", "--special", help="include special characters", action="store_true")
parser.add_argument("-u", "--upper", help="include uppercase characters", action="store_true")
parser.add_argument("-p", "--license", help="print license and exit", action="store_true")
# COLLECT ARGPARSE RESULTS
results = args = parser.parse_args()
# CHECK RESULTS
# Check that a length was given.
# If not, gripe and exit.
if args.count == '0':
print ("Input error:\nCannot create a zero length password.\nExiting")
exit (0)
# check character results and add to counter if
# selection is made.
if args.lower:
typo = typo + 'l'
counter = counter + 1
#print "lower"
if args.number:
typo = typo + 'n'
counter = counter + 1
#print "number"
if args.special:
typo = typo + 's'
counter = counter + 1
#print "special"
if args.upper:
typo = typo + 'u'
counter = counter + 1
#print "upper"
if args.all:
typo = 'a'
counter = counter + 1
#print "all"
if args.license:
print (license)
exit (1)
# CHECK COUNTER
# Check our counter and see if we used any command line
# options. We don't want to error out.
# try it gracefully. If no arguments are given,
# use defaults and tell the user.
# args.count comes from argparse and by default requires
# an input to '-c'. We want to get around that for the
# sake of convenience.
# Without further adieu, here's our if statement:
if args.count:
if counter == 0:
typo = 'a'
print ("defaulting to '--all'")
print (line)
print (pwgen(results.count,typo))
else:
if counter == 0:
typo = 'a'
print ("defaulting to '--count 16 --all'")
print (line)
print (pwgen(c,typo))
print (line)
#print typo
Cheers!
-0net
Subscribe to:
Posts (Atom)