Category Archives: code snippets

arduino and PHP snippets

Dell Ubuntu rfkill

Apparently the Fn-F7 option on the Lattitude 13 and other models causes breakage with Ubuntu 11.04 putting blocks on wireless. So if you’re getting: tail -f /var/log/syslog Jun 28 11:58:43 latitude13 kernel: [42125.406612] iwlagn 0000:0c:00.0: RF_KILL bit toggled to enable radio. Jun 28 11:58:45 latitude13 kernel: [42127.020863] iwlagn 0000:0c:00.0: RF_KILL bit toggled to disable radio. [...]

Also posted in geek, servers & tech | Leave a comment

Zabbix for XenServer (work in progress)

Using “xe host-data-source-list” and “xe host-data-source-query” I made some basic UserParameter for xenserver below. UserParameter=xe.vmcountup,sudo /opt/xensource/bin/xe vm-list | grep running | wc -l UserParameter=xe.vmcountdown,sudo /opt/xensource/bin/xe vm-list | grep halted | wc -l UserParameter=xe.memory_total_kib,sudo /opt/xensource/bin/xe host-data-source-query data-source=memory_total_kib UserParameter=xe.memory_free_kib,sudo /opt/xensource/bin/xe host-data-source-query data-source=memory_free_kib UserParameter=xe.xapi_memory_usage_kib,sudo /opt/xensource/bin/xe host-data-source-query data-source=xapi_memory_usage_kib UserParameter=xe.xapi_free_memory_kib,sudo /opt/xensource/bin/xe host-data-source-query data-source=xapi_free_memory_kib UserParameter=xe.xapi_live_memory_kib,sudo /opt/xensource/bin/xe host-data-source-query data-source=xapi_live_memory_kib UserParameter=xe.xapi_allocation_kib,sudo /opt/xensource/bin/xe host-data-source-query [...]

Also posted in geek, servers & tech | 4 Comments

Zabbix Agent RPM on XenServer 5.6 Dom0

Grab Zabbix RPM for CentOS 5 from http://download.opensuse.org/repositories/home:/ericgearhart:/zabbix/CentOS_CentOS-5/ for your architecture. wget http://download.opensuse.org/repositories/home:/ericgearhart:/zabbix/CentOS_CentOS-5/i386/zabbix-1.8.3-12.1.i386.rpm wget http://download.opensuse.org/repositories/home:/ericgearhart:/zabbix/CentOS_CentOS-5/i386/zabbix-agent-1.8.3-12.1.i386.rpm #installs fine rpm -Uv zabbix-1.8.3-12.1.i386.rpm #openssl-devel needed for zabbix_agentd rpm -Uv zabbix-agent-1.8.3-12.1.i386.rpm warning: zabbix-agent-1.8.3-12.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID a8022b27 error: Failed dependencies: openssl-devel >= 0.9.7d is needed by zabbix-agent-1.8.3-12.1.i386 #try and install openssl-devel yum –enablerepo=base install openssl-devel [...]

Also posted in geek, servers & tech | Leave a comment

find and awk for httpd owned files (with count and average)

These are not very efficient (two sorts in one line for example) but for my needs work fine (improvements welcomed). Create a list of “filenames|size in bytes” of all httpd owned files sorted by reverse size: find “/path/to/examine/” -user httpd -type f -printf ‘%p|%s\n’ | sort -t \| +1 -2 > httpd.usage.txt results: /path/to/examine/some/user/files/file0.jpg|99995 /path/to/examine/some/user/files/file7.jpg|99994 [...]

Also posted in geek, servers & tech | Leave a comment

Configure sendmail with saslauthd for SMTP AUTH

Install: wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm rpm -Uv rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm yum install sendmail sendmail-cf cyrus-sasl-plain cd /etc/mail vi sendmail.mc change from: DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl change to: DAEMON_OPTIONS(`Port=smtp, Name=MTA’)dnl add: define(`confAUTH_MECHANISMS’, `LOGIN PLAIN’)dnl add: TRUST_AUTH_MECH(`LOGIN PLAIN’)dnl make sendmail.cf -C /etc/mail chkconfig sendmail on chkconfig saslauthd on /etc/init.d/sendmail start /etc/init.d/saslauthd start adduser someusername (the username to allow relay) passwd someusername (the username [...]

Also posted in geek, servers & tech | Leave a comment

roundcube add subject to smtp_log

vi program/steps/mail/func.inc change: if ($CONFIG['smtp_log']) { write_log(‘sendmail’, sprintf(“User %s [%s]; Message for %s; %s”, $RCMAIL->user->get_username(), $_SERVER['REMOTE_ADDR'], $mailto, !empty($smtp_response) ? join(‘; ‘, $smtp_response) : ”)); } to: if ($CONFIG['smtp_log']) { write_log(‘sendmail’, sprintf(“User %s [%s]; Message for %s; Subject: %s %s”, $RCMAIL->user->get_username(), $_SERVER['REMOTE_ADDR'], $mailto, $headers['Subject'], !empty($smtp_response) ? join(‘; ‘, $smtp_response) : ”)); }

Posted in code snippets | Leave a comment

Converting 32bit RRD to 64bit RRD (moving cacti between architectures)

While migrating cacti over to a new virtual machine I got “ERROR: This RRD was created on another architecture” in /var/log/httpd/error_log when the crontab ran resulting in blank graphs.

Also posted in geek, servers & tech | 5 Comments

CentOS 5.3 Smokeping 2.4.2 Install (quick)

Install the latest smokeping (without distributed polling) on a virgin Centos 5.3 minimal box… It’s probably the best (free) tool for monitoring network latency at a glance. Examples: Pipe Ten Derby and Pipe Ten Sheffield.

Also posted in geek, servers & tech | Tagged , , , , | 11 Comments

CentOS 5.3 Zabbix 1.6.5 Install (quick)

A quick reference for a from-scratch Zabbix install on CentOS 5.3. We’ve used Zabbix for the past 3 or 4 years and just implementing 1.6.5 across multiple Xen nodes for funky distributed monitoring.

Also posted in geek, servers & tech | 4 Comments

Ardunio Visible Distance Detector v1.0 snippet

/* This code receives input from the SRF02 ultrasonic and maps the values to RGB outputs to a tri-colour LED. */

Also posted in projects | Tagged , , , | Leave a comment