#] root@web:~ 21:47:16 0 [# cat /usr/sbin/apacheAccessLog.sh #!/bin/bash filename="/var/log/apache2/access.log.1" hostname="localhost" username="apache" password="******" database="apache" sqltable="accessLog" mysql -h${hostname} -u${username} -p${password} ${database} << EOQ LOAD DATA LOCAL INFILE "${filename}" INTO TABLE $sqltable FIELDS TERMINATED BY '\t' EOQ
mysql> select * from accessLog where datetime > date_sub( now( ), interval 1 day) and status = 404; mysql> select count(*), substring( request, 1, 64 ), filename from accessLog where datetime > date_sub( now( ), interval 1 day) and status = 404 group by request, filename order by count(*) desc; mysql> select * from accessLog where datetime > date_sub( now( ), interval 1 day) and status not in( 401, 404 ); mysql> select count(*), substring( request, 1, 64 ), filename from accessLog where datetime > date_sub( now( ), interval 1 day) and status not in( 401, 404 ) group by request, filename order by count(*) desc; mysql> select filename, count(*) from accessLog where datetime > date_sub( now( ), interval 1 day ) and status <> 404 group by filename order by count(*) desc; mysql> select filename, count(*) from accessLog where datetime > date_sub( now( ), interval 1 day ) and status not in( 401, 404) group by filename order by count(*) desc; mysql> select substr( filename, 1, 29 ), count(*) from accessLog where datetime > date_sub( now( ), interval 1 day ) and status not in( 401, 404 ) and filename regexp '/var/www/html/us/kohlmeyer/[cekp]' group by substr( filename, 1, 29 ) order by count(*);
#] kemiko@box:/usr/local/bin 20:30:25 0 [# cat lines.sh #!/bin/bash #set -x # 2024-06-15; lines.sh; Kent M Kohlmeyer (kemiko) # display range of lines from a file if [ ${#} -lt 1 ] then printf "\e[1mUsage: $(basename ${0}) <file> <start line> <stop line>\e[0m\n" exit 1 fi if [ ! -s ${1} ] then printf "\e[1m\"${0}\" is not a regular file with size!\e[0m\n" exit 1 fi if [ "${2}" -eq "${2}" ] && [ "${3}" -eq "${3}" ] 2>/dev/null then : else printf "\e[1m\"${2}\" (start) and/or \"${3}\" (stop) is not an integer\e[0m\n" exit 1 fi if [ ${2} -le 0 ] || [ ${3} -le 0 ] then printf "\e[1m\"${2}\" (start) and/or \"${3}\" (stop) can't be negative\e[0m\n" exit 1 fi if [ ${3} -gt $(wc -l ${1} | cut -d' ' -f1) ] then printf "\e[1m\"${3}\" (stop) shouldn't be greater than the file line count of \"$(wc -l ${1} | cut -d' ' -f1)\"\e[0m\n" exit 1 fi if [ "${2}" -gt "${3}" ] 2>/dev/null then printf "\e[1m\"${2}\" (start) can't be greater than \"${3}\" (stop)\e[0m\n" exit 1 fi head -n ${3} ${1} | tail -n $(expr ${3} - ${2} + 1) #] kemiko@box:/usr/local/bin 20:30:25 0 [#
#] kemiko@box:/usr/local/bin 08:57:18 0 [# cat free.sh #!/bin/bash #set -x # 2024-07-26; free.sh; Kent M Kohlmeyer (kemiko) # This script shows memory usage in... # bytes, kibibytes, mebibytes, or gibibytes # Add seconds argument to pause until... # <enter> is pressed # don't echo key presses to screen stty -echo # don't show cursor tput civis trap 'tput cnorm; stty echo; exit 1' 0 1 2 15 # set defaults size=m seconds=86400 if [ ${#} -eq 0 ] then printf "\e[1mUsage: %s <b|k|m|g> [seconds]\e[0m\n" "${0}" exit 1 fi if [ ${1} != b ] && [ ${1} != k ] && [ ${1} != m ] && [ ${1} != g ] then printf "\e[1mArgument one, \"${1}\", is not \"b|k|m|g\"\e[0m\n" exit 1 else size=${1} fi # test if argument two is set if [ -z ${2+x} ] then : else # test if argument two is an integer if [ "${2}" -eq "${2}" ] 2>/dev/null then seconds=${2} else printf "\e[1mArgument two, \"${2}\", is not an integer\e[0m\n" exit 1 fi fi clear while [ 1 ] do printf "\e[1m%s\e[0m\n" "$(date '+%Y-%m-%d @ %H:%M:%S (%A)')" free -w${size} read -t ${seconds} done #] kemiko@box:/usr/local/bin 08:57:18 0 [#
#] kemiko@box:/tmp 23:47:18 0 [# cat glibc.c #include <stdio.h> #include <gnu/libc-version.h> int main( void ) { puts( gnu_get_libc_version ( ) ); return 0; } #] kemiko@box:/tmp 23:47:19 0 [#
#] kemiko@box:~/bin 09:13:01 1 [# cat highlight.sh #!/bin/bash #set -x # 2025-01-06; highlight.sh; Kent M Kohlmeyer (kemiko) # This script highlights pattern(s) in file(s) if [ ${#} -eq 0 ] then printf "\e[1mUsage: %s <regexp> <file(s)>\e[0m\n" "${0}" exit 1 fi init=0 filesValid="" filesError="" errors=0 for file in ${@} do if [ ${init} -eq 0 ] then init=1 else if [ -f ${file} ] then filesValid=$(printf "%s %s" "${filesValid}" "${file}") else errors=$(expr ${errors} + 1) filesError=$(printf "%s \"%s\"" "${filesError}" "${file}") fi fi done if [ ${errors} -gt 0 ] then printf "\e[1mError: %s file(s) are not valid...%s\e[0m\n" "${errors}" "${filesError}" exit ${errors} fi #for file in ${filesValid} #do # egrep -iIn --color=auto "${1}|$" ${file} /dev/null #done egrep -iIn --color=auto "${1}|$" ${filesValid} /dev/null exit 0 #] kemiko@box:~/bin 09:13:02 0 [#
Alpha and Omega Semiconductor Limited, or AOS, is a designer, developer and global supplier of a broad range of power semiconductors, including a wide portfolio of Power MOSFET, IGBT and Power IC products. AOS has developed extensive intellectual property and technical knowledge that encompasses the latest advancements in the power semiconductor industry, which enables it to introduce innovative products to address the increasingly complex power requirements of advanced electronics. AOS differentiates itself by integrating its Discrete and IC semiconductor process technology, product design, and advanced packaging know-how to develop high performance power management solutions. AOS's portfolio of products targets high-volume applications, including portable computers, flat panel TVs, LED lighting, smart phones, battery packs, consumer and industrial motor controls and power supplies for TVs, computers, servers and telecommunications equipment. For more information, please visit http://www.aosmd.com. For investor relations, please contact So-Yeon Jeong at investors@aosmd.com.
CONTACT: Alpha and Omega Semiconductor Limited Investor Relations So-Yeon Jeong 408-789-3172 investors@aosmd.com
1. Filter for interactive SSH logins bash> grep sshd.\*Failed /var/log/auth.log | less 2. Filter for failed connections (i.e. no login attempted, could be a port scanner, etc) bash> grep sshd.\*Did /var/log/auth.log | less
![]() |
;)u | winky tongue |
![]() |
^^)u | silly tongue |
![]() |
;3* | kissy |
![]() |
(bb) | bear (brown) ... pairs well with "huggy" |
![]() |
(bp) | bear (panda) ... pairs well with "huggy" |
![]() |
(^^8)) | huggy |
![]() |
**^o^ | heart eyes |
![]() |
:(? | thought |
![]() |
:'( | sad |
![]() |
:8^v^ | embarrassed |
![]() |
^^8) | blush |
![]() |
:8| | rolling eyes |
![]() |
'><8 | very upset |
![]() |
^^)*** | three hearts (kisses) on face |
--shows base table information SELECT * FROM pg_catalog.pg_tables --WHERE -- tableowner = current_user --WHERE -- schemaname NOT IN ('public','pg_catalog','information_schema') --WHERE -- schemaname IN ('public','pg_catalog','information_schema') --ORDER BY -- schemaname DESC, tablename ; ┌────────────────────┬─────────────────────────┬────────────┬────────────┬────────────┬──────────┬─────────────┬─────────────┐ │ schemaname │ tablename │ tableowner │ tablespace │ hasindexes │ hasrules │ hastriggers │ rowsecurity │ ├────────────────────┼─────────────────────────┼────────────┼────────────┼────────────┼──────────┼─────────────┼─────────────┤ │ ... │ ... │ ... │ (NULL) │ t │ f │ f │ f │ │ public │ exampleTable │ dba │ (NULL) │ t │ f │ f │ f │ │ pg_catalog │ pg_aggregate │ postgres │ (NULL) │ t │ f │ f │ f │ │ ... │ ... │ ... │ (NULL) │ t │ f │ f │ f │ │ information_schema │ sql_features │ postgres │ (NULL) │ f │ f │ f │ f │ │ ... │ ... │ ... │ (NULL) │ t │ f │ f │ f │ └────────────────────┴─────────────────────────┴────────────┴────────────┴────────────┴──────────┴─────────────┴─────────────┘ (999 rows)
--shows "table catalog" and "table type", but not "table owner" compared to previous query SELECT * FROM information_schema.tables --WHERE -- table_schema = 'public' --WHERE -- table_schema NOT IN ('public','pg_catalog','information_schema') --WHERE -- table_schema IN ('public','pg_catalog','information_schema') ORDER BY table_schema DESC, table_name ; ┌────────────────┬────────────────────┬───────────────────────────────────────┬────────────┬──────────────────────────────┬──────────────────────┬───────────────────────────┬──────────────────────────┬────────────────────────┬────────────────────┬──────────┬───────────────┐ │ table_catalog │ table_schema │ table_name │ table_type │ self_referencing_column_name │ reference_generation │ user_defined_type_catalog │ user_defined_type_schema │ user_defined_type_name │ is_insertable_into │ is_typed │ commit_action │ ├────────────────┼────────────────────┼───────────────────────────────────────┼────────────┼──────────────────────────────┼──────────────────────┼───────────────────────────┼──────────────────────────┼────────────────────────┼────────────────────┼──────────┼───────────────┤ │ exampleCatalog │ public │ exampleTable │ BASE TABLE │ (NULL) │ (NULL) │ (NULL) │ (NULL) │ (NULL) │ YES │ NO │ (NULL) │ │ ... │ ... │ ... │ BASE TABLE │ (NULL) │ (NULL) │ (NULL) │ (NULL) │ (NULL) │ YES │ NO │ (NULL) │ │ ... │ pg_catalog │ pg_aggregate │ BASE TABLE │ (NULL) │ (NULL) │ (NULL) │ (NULL) │ (NULL) │ YES │ NO │ (NULL) │ │ ... │ information_schema │ administrable_role_authorizations │ VIEW │ (NULL) │ (NULL) │ (NULL) │ (NULL) │ (NULL) │ NO │ NO │ (NULL) │ │ ... │ ... │ ... │ BASE TABLE │ (NULL) │ (NULL) │ (NULL) │ (NULL) │ (NULL) │ YES │ NO │ (NULL) │ └────────────────┴────────────────────┴───────────────────────────────────────┴────────────┴──────────────────────────────┴──────────────────────┴───────────────────────────┴──────────────────────────┴────────────────────────┴────────────────────┴──────────┴───────────────┘ (999 rows)
CREATE VIEW tables AS SELECT table_catalog, table_schema, table_name, table_type FROM information_schema.tables WHERE table_schema NOT IN ('pg_catalog', 'information_schema') ;
SELECT * FROM tables ; ─ ┌────────────────┬───────────────┬──────────────────┬─────────────┐ │ table_catalog │ table_schema │ table_name │ table_type │ ├────────────────┼───────────────┼──────────────────┼─────────────┤ │ exampleCatalog │ exampleSchema │ exampletable │ exampleType │ │ ... │ ... │ ... │ ... │ │ postgres │ public │ tables │ VIEW │ └────────────────┴───────────────┴──────────────────┴─────────────┘ (999 rows)
--shows non system objects owned by current user SELECT nsp.nspname AS object_schema, cls.relname AS object_name, CASE cls.relkind WHEN 'r' THEN 'table' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 'v' THEN 'view' WHEN 'c' THEN 'type' ELSE cls.relkind::text END AS object_type, rol.rolname AS object_owner FROM pg_class cls JOIN pg_roles rol ON rol.oid = cls.relowner JOIN pg_namespace nsp ON nsp.oid = cls.relnamespace WHERE nsp.nspname NOT IN ('information_schema', 'pg_catalog') AND nsp.nspname NOT LIKE 'pg_toast%' AND rol.rolname = current_user ORDER BY nsp.nspname, cls.relname ; ┌───────────────┬─────────────────────┬─────────────┬──────────────┐ │ object_schema │ object_name │ object_type │ object_owner │ ├───────────────┼─────────────────────┼─────────────┼──────────────┤ │ public │ tables │ view │ postgres │ │ ... │ ... │ ... │ ... │ │ exampleSchema │ example │ table │ dba │ │ exampleSchema │ example_id_seq │ sequence │ dba │ │ exampleSchema │ example_pkey │ index │ dba │ └───────────────┴─────────────────────┴─────────────┴──────────────┘ (XXX rows)
SELECT r.usename AS grantor, e.usename AS grantee, nspname, privilege_type, is_grantable FROM pg_namespace JOIN LATERAL (SELECT * FROM aclexplode(nspacl) AS x) a ON true JOIN pg_user e ON a.grantee = e.usesysid JOIN pg_user r ON a.grantor = r.usesysid WHERE e.usename = current_user ; ┌──────────┬──────────┬────────────────────┬────────────────┬──────────────┐ │ grantor │ grantee │ nspname │ privilege_type │ is_grantable │ ├──────────┼──────────┼────────────────────┼────────────────┼──────────────┤ │ postgres │ postgres │ pg_catalog │ USAGE │ f │ │ postgres │ postgres │ pg_catalog │ CREATE │ f │ │ postgres │ postgres │ public │ USAGE │ f │ │ postgres │ postgres │ public │ CREATE │ f │ │ postgres │ postgres │ information_schema │ USAGE │ f │ │ postgres │ postgres │ information_schema │ CREATE │ f │ └──────────┴──────────┴────────────────────┴────────────────┴──────────────┘ (6 rows)
SELECT * FROM pg_stat_activity ; ┌───────┬───────────┬───────┬──────────┬──────────┬──────────────────┬─────────────┬─────────────────┬─────────────┬───────────────────────────────┬───────────────────────────────┬───────────────────────────────┬───────────────────────────────┬─────────┬────────┬─────────────┬──────────────┬─────────────────────────────────────────────────────────────────────────────┐ │ datid │ datname │ pid │ usesysid │ usename │ application_name │ client_addr │ client_hostname │ client_port │ backend_start │ xact_start │ query_start │ state_change │ waiting │ state │ backend_xid │ backend_xmin │ query │ ├───────┼───────────┼───────┼──────────┼──────────┼──────────────────┼─────────────┼─────────────────┼─────────────┼───────────────────────────────┼───────────────────────────────┼───────────────────────────────┼───────────────────────────────┼─────────┼────────┼─────────────┼──────────────┼─────────────────────────────────────────────────────────────────────────────┤ │ 12411 │ postgres │ 16459 │ 24655 │ dba │ psql │ 127.0.0.1 │ (NULL) │ 49568 │ 2024-11-28 13:39:41.091595-08 │ 2024-12-01 20:09:47.198842-08 │ 2024-12-01 20:09:47.198842-08 │ 2024-12-01 20:09:47.198847-08 │ f │ active │ (NULL) │ 4838 │ SELECT * FROM pg_stat_activity; │ │ 12411 │ postgres │ 23698 │ 10 │ postgres │ psql │ (NULL) │ (NULL) │ -1 │ 2024-11-30 11:51:07.192089-08 │ (NULL) │ 2024-11-30 11:51:58.141689-08 │ 2024-11-30 11:51:58.156049-08 │ f │ idle │ (NULL) │ (NULL) │ select table_name, ↵│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ table_schema as schema_name, ↵│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ pg_database_size(current_database()) as total_database_size, ↵│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ pg_total_relation_size(table_name) as total_table_size, ↵│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ pg_relation_size(table_name) as table_size, ↵│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ pg_indexes_size(table_name) as index_size ↵│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ from information_schema.tables ↵│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ where table_schema=current_schema() and table_name like 'table_%'↵│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ order by total_table_size; │ │ ... │ ... │ ..... │ ..... │ ........ │ .... │ ......... │ ......... │ ..... │ ............................. │ ............................. │ ............................. │ ............................. │ . │ ...... │ ...... │ ...... │ ...... │ │ 24732 │ xxxxxxx │ 1015 │ 10 │ postgres │ psql │ (NULL) │ (NULL) │ -1 │ 2024-11-27 20:21:49.750157-08 │ (NULL) │ 2024-11-27 20:21:58.891633-08 │ 2024-11-27 20:21:58.900124-08 │ f │ idle │ (NULL) │ (NULL) │ select * from xxx.ledger; │ └───────┴───────────┴───────┴──────────┴──────────┴──────────────────┴─────────────┴─────────────────┴─────────────┴───────────────────────────────┴───────────────────────────────┴───────────────────────────────┴───────────────────────────────┴─────────┴────────┴─────────────┴──────────────┴─────────────────────────────────────────────────────────────────────────────┘ (XXX rows)
SELECT pg_terminate_backend( pid );