Tag Archives: linux

zshell: rsync hostname completion with zsh

If you use ssh a lot with zsh and have a lot of entries in your hostsfile (/etc/hosts) you might find it convenient to disable completion from these hosts by using: zstyle ‘:completion:*’ hosts off However, this may give you adverse affects, and your hostnames may stop auto-completing with rsync – in order to fix this try also adding this in to your .zshrc zstyle -s ‘:completion:*:hosts’ hosts _ssh_config [[ -r ~/.ssh/config ]] && _ssh_config+=($(cat ~/.ssh/config | sed -ne ‘s/Host[=\t ]//p’)) zstyle ‘:completion:*:hosts’ hosts $_ssh_config If you also use oh-my-zsh and are still having trouble, trying adding those lines after this line: source $ZSH/oh-my-zsh.sh

Posted in Tech Tips | Tagged , | 1 Comment

brew install gnu-stat

The stat command on Ubuntu and OS X behave differently and I’d like to have the functionality of the GNU / Ubuntu version of stat available on OS X – if there is such a thing. I have already used homebrew to install gnu-sed and I see similarly that a lot of the GNU utilities are available from: brew install coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt I know stat on OS X might be very specialized because of the OS X file systems that may be present, but I’d ALSO like to have the linuxy version if it is available. As it turns out, it is. The GNU version of stat can be accessed on OS X by installing a package / keg called coreutils which includes the following utilities: base64 env mknod runcon touch basename expand mktemp seq tr cat expr mv sha1sum true chcon factor nice sha224sum truncate chgrp false nl sha256sum tsort chmod fmt nohup sha384sum tty chown fold nproc sha512sum uname chroot groups numfmt shred unexpand cksum head od shuf uniq comm hostid paste sleep unlink cp id pathchk sort uptime csplit install pinky split users cut join pr stat vdir date kill printenv stty wc dd link printf sum who df ln ptx sync whoami dir logname pwd tac yes dircolors ls readlink tail dirname md5sum realpath tee du mkdir rm test echo mkfifo rmdir timeout These GNU utilities are available on Mac OS X but the one caveat is that they are … Continue reading

Posted in Mac, Server Admin, Tech Tips | Tagged , , , | Leave a comment

linux: What does hash -r do?

The hash utility shall affect the way the current shell environment remembers the locations of utilities found as described in Command Search and Execution. Depending on the arguments specified, it shall add utility locations to its list of remembered locations or it shall purge the contents of the list. When no arguments are specified, it shall report on the contents of the list. The following option shall be supported: -r: Forget all previously remembered utility locations.

Posted in Server Admin | Tagged , | Leave a comment

rtorrent autoload directory

When using rtorrent, you can set a folder to be watched for torrent files that will be auto-loaded. To do this, you’ll edit your ~/.rtorrent.rc file and add one of the following lines. See the comment below for more information: # Watch a directory for new torrents, and stop those that have been deleted. schedule = watch_directory,5,5,load_start=/home/user/torrent_files/*.torrent schedule = untied_directory,5,5,stop_untied=

Posted in Software, Tech Tips | Tagged , , | Leave a comment

nmap scans ips and ports

A useful linux/unix tool, nmap scans ips and ports of given hosts: Nmap 5.21 ( http://nmap.org ) Usage: nmap [Scan Type(s)] [Options] {target specification} TARGET SPECIFICATION: Can pass hostnames, IP addresses, networks, etc. Ex: scanme.nmap.org,; 10.0.0-255.1-254 -iL <inputfilename>: Input from list of hosts/networks -iR <num hosts>: Choose random targets –exclude <host1 [,host2][,host3],…>: Exclude hosts/networks –excludefile <exclude_file>: Exclude list from file HOST DISCOVERY: -sL: List Scan – simply list targets to scan -sP: Ping Scan – go no further than determining if host is online -PN: Treat all hosts as online — skip host discovery -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes -PO[protocol list]: IP Protocol Ping -n/-R: Never do DNS resolution/Always resolve [default: sometimes] –dns-servers <serv1 [,serv2],…>: Specify custom DNS servers –system-dns: Use OS’s DNS resolver –traceroute: Trace hop path to each host SCAN TECHNIQUES: -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans -sU: UDP Scan -sN/sF/sX: TCP Null, FIN, and Xmas scans –scanflags <flags>: Customize TCP scan flags -sI <zombie host[:probeport]>: Idle scan -sY/sZ: SCTP INIT/COOKIE-ECHO scans -sO: IP protocol scan -b <ftp relay host>: FTP bounce scan PORT SPECIFICATION AND SCAN ORDER: -p <port ranges>: Only scan specified ports Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080 -F: Fast mode – Scan fewer ports than the default scan -r: Scan ports consecutively – don’t randomize –top-ports <number>: Scan </number><number> most common ports –port-ratio <ratio>: Scan ports more common than </ratio><ratio> SERVICE/VERSION DETECTION: -sV: Probe open ports to determine service/version info –version-intensity <level>: … Continue reading

Posted in Security, Server Admin, Tech Tips | Tagged , , , | Leave a comment

mod_auth_openid v0.6 on Ubuntu 12.04 for AuthOpenIDAXRequire

I believe the standard version of mod_auth_openid that comes with Ubuntun 12.04 precise pangolin is v0.5 This library is also known by the name libapache2-mod-auth-openid Make sure you have apxs2 installed: Apache Extension Tools (apxs / apxs2) apache extension tools apt-get install sudo apt-get install apache2-threaded-dev I didn’t have the time to finish editing this post to my liking, so I’m just adding my notes as-are: mod_auth_openid v0.6 on Ubuntu 12.04 with AuthOpenIDAXRequire sudo apt-get install apache2-threaded-dev AuthOpenIDAXRequire schema email http://openid.net/schema/namePerson/prefix http://openid.net/schema/namePerson/first http://openid.net/schema/namePerson/last http://openid.net/schema/namePerson/middle http://openid.net/schema/namePerson/suffix http://openid.net/schema/namePerson/friendly http://openid.net/schema/person/guid http://openid.net/schema/birthDate/birthYear http://openid.net/schema/birthDate/birthMonth http://openid.net/schema/birthDate/birthday http://openid.net/schema/gender http://openid.net/schema/language/pref http://openid.net/schema/contact/phone/default http://openid.net/schema/contact/phone/home http://openid.net/schema/contact/phone/business http://openid.net/schema/contact/phone/cell http://openid.net/schema/contact/phone/fax http://openid.net/schema/contact/postaladdress/home http://openid.net/schema/contact/postaladdressadditional/home http://openid.net/schema/contact/city/home http://openid.net/schema/contact/state/home http://openid.net/schema/contact/country/home http://openid.net/schema/contact/postalcode/home http://openid.net/schema/contact/postaladdress/business http://openid.net/schema/contact/postaladdressadditional/business http://openid.net/schema/contact/city/business http://openid.net/schema/contact/state/business http://openid.net/schema/contact/country/business http://openid.net/schema/contact/postalcode/business http://openid.net/schema/contact/IM/default http://openid.net/schema/contact/IM/AIM http://openid.net/schema/contact/IM/ICQ http://openid.net/schema/contact/IM/MSN http://openid.net/schema/contact/IM/Yahoo http://openid.net/schema/contact/IM/Jabber http://openid.net/schema/contact/IM/Skype http://openid.net/schema/contact/internet/email http://openid.net/schema/contact/web/default http://openid.net/schema/contact/web/blog http://openid.net/schema/contact/web/Linkedin http://openid.net/schema/contact/web/Amazon http://openid.net/schema/contact/web/Flickr http://openid.net/schema/contact/web/Delicious http://openid.net/schema/company/name http://openid.net/schema/company/title http://openid.net/schema/media/spokenname http://openid.net/schema/media/greeting/audio http://openid.net/schema/media/greeting/video http://openid.net/schema/media/biography http://openid.net/schema/media/image http://openid.net/schema/media/image/16×16 http://openid.net/schema/media/image/32×32 http://openid.net/schema/media/image/48×48 http://openid.net/schema/media/image/64×64 http://openid.net/schema/media/image/80×80 http://openid.net/schema/media/image/128×128 http://openid.net/schema/media/image/160×120 http://openid.net/schema/media/image/320×240 http://openid.net/schema/media/image/640×480 http://openid.net/schema/media/image/120×160 http://openid.net/schema/media/image/240×320 http://openid.net/schema/media/image/480×640 http://openid.net/schema/media/image/favicon http://openid.net/schema/timezone via http://stackoverflow.com/questions/7403536/list-of-available-attributes-for-http-axschema-org-and-http-schemas-openid-n changeset on openid auth schemas http://sourceforge.net/apps/trac/simpleid/changeset/459 openid auth properties http://openid.net/specs/openid-attribute-properties-list-1_0-01.html Introduction : The Apache OpenID Module http://findingscience.com/mod_auth_openid/ AuthType OpenID require valid-user AuthOpenIDTrusted ^https://www.google.com/accounts/o8/ud AuthOpenIDSingleIdP https://www.google.com/accounts/o8/id AuthOpenIDAXRequire email http://openid.net/schema/contact/email [email protected] AuthOpenIDAXUsername email via http://mmornati.tumblr.com/post/23559005172/apache-and-mod-auth-openid-on-f16-centos openid explained http://openidexplained.com/use myopenid https://www.myopenid.com Using Mod_auth_openid With Ubuntu SSO http://rtg.in.ua/blog/2011/11/modauthopenid-and-ubuntu-sso/ sudo apt-add-repository ppa:rye/ppa sudo apt-get update sudo apt-get install libapache2-mod-auth-openid apt-cache policy libapache2-mod-auth-openid libapache2-mod-auth-openid: Installed: 0.6-0ubuntu1 Candidate: 0.6-0ubuntu1 Using Apache2’s mod_auth_openid… http://hustoknow.blogspot.com/2012/05/setting-up-google-apps-single-sign-on.html sudo apt-get install automake sudo apt-get install autotools-dev sudo apt-get install libtool sudo apt-get install libtidy-dev sudo apt-get install libcurl4-openssl-dev sudo apt-get install libopkele-dev ./autogen.sh ./configure make <location “/”> LoadModule authopenid_module /usr/lib/apache2/modules/mod_auth_openid.so AuthType OpenID require valid-user AuthOpenIDTrusted ^https://www.google.com/accounts/o8/ud … Continue reading

Posted in Server Admin | Tagged , , , , , , | Leave a comment

nagios check_dns / check_ip example

Need to monitor an IP address / DNS entry with Nagios? Nagios has a plugin called check_dns just for that. The check commands are defined in this file: /etc/nagios-plugins/config/dns.cfg # ‘check_dns’ command definition define command{ command_name check_dns command_line /usr/lib/nagios/plugins/check_dns -H www.google.com -s ‘$HOSTADDRESS$’ } # ‘check_dig’ command definition define command{ command_name check_dig command_line /usr/lib/nagios/plugins/check_dig -H ‘$HOSTADDRESS$’ -l ‘$ARG1$’ } here is an alternate version I wrote to check the IP of a host, I could have used check_ip because I don’t think that command is taken, but instead I used my_check_dns: #my_check_dns command, checks to make sure a hostname resolved to a specified IP address: define command { command_name my_check_dns command_line /usr/lib/nagios/plugins/check_dns -H $ARG1$ -a $ARG2$ } this is how it would be implemented in a service: define service{ use generic-service ; Name of service template to use host_name mysite.com service_description check dns check_command my_check_dns!www.mysite.com!123.456.78.90 } Man Page: check_dns v1.4.14 (nagios-plugins 1.4.14) Copyright (c) 1999 Ethan Galstad <nagios @nagios.org> Copyright (c) 2000-2008 Nagios Plugin Development Team <nagiosplug [email protected]> This plugin uses the nslookup program to obtain the IP address for the given host/domain query. An optional DNS server to use may be specified. If no DNS server is specified, the default server(s) specified in /etc/resolv.conf will be used. Usage:check_dns -H host [-s server] [-a expected-address] [-A] [-t timeout] [-w warn] [-c crit] Options: -h, –help Print detailed help screen -V, –version Print version information -H, –hostname=HOST The name or address you want to query -s, –server=HOST Optional DNS server you … Continue reading

Posted in Security, Server Admin | Tagged , , , , | Leave a comment

wget: no retries

Wget – is the non-interactive network downloader, and you can set it up to download without retrying / making any retries with the following option: -t number / –tries=number: Set number of retries to number. Specify 0 or ‘inf’ for infinite retrying. The default is to retry 20 times, with the exception of fatal errors like “connection refused” or “not found” (404), which are not retried. It is usually also helpful to set up a timeout for requests which may take a long time: -T seconds / –timeout=seconds: Set the network timeout to seconds seconds. This is equivalent to specifying ‘–dns-timeout’, ‘–connect-timeout’, and ‘–read-timeout’, all at the same time. When interacting with the network, Wget can check for timeout and abort the operation if it takes too long. This prevents anomalies like hanging reads and infinite connects. The only timeout enabled by default is a 900-second read timeout. Setting a timeout to 0 disables it altogether. Unless you know what you are doing, it is best not to change the default timeout settings. All timeout-related options accept decimal values, as well as subsecond values. For example, ‘0.1’ seconds is a legal (though unwise) choice of timeout. Subsecond timeouts are useful for checking server response times or for testing network latency.

Posted in Web Development | Tagged , , | 1 Comment

How to Monitor Canon Printers with SNMP

I’m working to set up monitoring of Canon printers with SNMP, and I’m having a hard time finding resources around the internet on how to go about doing this, so this article will be collecting the resources I’ve found and putting them in once place. Commands for Monitoring Canon Printers with SNMP One of the problems that I had to look into was monitoring of CANON printers, and properly modifying Nagios config files for that: Once you understand a little how NAGIOS works you will understand what I am trying to show you here in example: in /usr/local/nagios/etc/objects/commands.cfg I added a command: define command{ command_name check_snmp_canon command_line $USER1$/check_snmp -H $HOSTADDRESS$ -l STATUS -C public $ARG1$ $ARG2$ } then in: /usr/local/nagios/etc/objects/printer.cfg you define host and service like this: define host{ use generic-printer host_name SOMECANONPRINTER alias SOMECANONPRINTER Alias address “IP of the printer goes here” hostgroups network-printers } define service{ use generic-service host_name SOMECANONPRINTER service_description Printer Status check_command check_snmp_canon!-o hrDeviceStatus.1 -r “2|3” normal_check_interval 10 retry_check_interval 1 } via http://mariuszgal.com/blog/?p=93 Some of the commands I’ve tried to execute directly from the command line use something like this: /usr/lib/nagios/plugins/check_snmp -H -C public -o hrDeviceStatus.1 snmpwalk -v <snmp version, typically ‘2c’> -c <community string> <agent address, e.g. ‘’> snmpwalk -v 2c -c public What is SNMP Simple Network Management Protocol (SNMP) is a set of standards for managing network devices, network devices are monitored by a SNMP manager which connects to an SNMP agent on network devices. Data which the SNMP agent … Continue reading

Posted in Linux, Server Administration, Tech Tips | Tagged , , , , , , , , , | 8 Comments

Setting Nagios host check frequency and Nagios default check interval

With nagios (nagios3), the normal check interval is set to 5 minutes, and the retry is set to 1 minute. If your services are not that critical, you can increase the default check interval, perhaps from five minutes (or 600 seconds) to something like 10 minutes or 15 minutes. Look for a file like generic-service_nagios.cfg in your configuration directory, possibly: /etc/nagios3/conf.d/generic-service_nagios2.cfg Then you can find the corresponding lines to make the edits you need: define service{ name generic-service active_checks_enabled 1 passive_checks_enabled 1 parallelize_check 1 obsess_over_service 1 check_freshness 0 notifications_enabled 1 event_handler_enabled 1 flap_detection_enabled 1 failure_prediction_enabled 1 process_perf_data 1 retain_status_information 1 retain_nonstatus_information 1 notification_interval 0 is_volatile 0 check_period 24×7 normal_check_interval 5 retry_check_interval 1 max_check_attempts 4 notification_period 24×7 notification_options w,u,c,r contact_groups admins register 0 }

Posted in Software, Web Development | Tagged , , , , , | Leave a comment