Dave Heavy Industries » Uncategorized http://www.daveheavyindustries.com Dave Heavy Industries - blog Mon, 12 Aug 2013 00:24:10 +0000 en-US hourly 1 http://wordpress.org/?v=3.6 NGINX snmp monitoring http://www.daveheavyindustries.com/2013/08/12/nginx-snmp-monitoring/ http://www.daveheavyindustries.com/2013/08/12/nginx-snmp-monitoring/#comments Sun, 11 Aug 2013 22:09:40 +0000 admin http://wp.daveheavyindustries.com/?p=397 So far as I could tell, nginx doesn't provide any stats out to snmp. This is something we like to watch closely so I put together the following based on a script I found here - http://www.kutukupret.com/2011/05/31/how-to-graph-nginx-statistics/

The script above took a few metrics out of the nginx_status stub page that you can include into your nginx config.

you can do this by including

location /nginx_status {
stub_status on;
access_log off;
}

under your server binding. you might (should) want to restrict access to this to only your internal subnets or localhost.

nginx_stats.pl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl
# $Revision: 2 $
# $Date: 2008-09-12 15:11:40 +0300 (Fri, 12 Sep 2008) $
 
my %opt = (
# http link to nginx stub_status, be sure turn on stub_status in nginx conf
    nginx_status   => 'http://localhost:80/nginx_status',
# path for program what may dump web page, normaly lynx -dump
#    lynx            => 'curl ',
    lynx            => 'wget -q -Y off -O -',
);
 
$opt{var} = $ARGV[0] if $ARGV[0];
$opt{nginx_status} = $ARGV[1] if $ARGV[1] and $ARGV[1]=~/^http:\/\/\w+/;
$opt{var} ||= '';
 
my $do = `$opt{lynx} $opt{nginx_status}`;
 
    $do=~/^Active connections:\s*(\d+)\s*$/ms or warn "Error! Can't find data!\nIN :\n$do";
    $opt{d1} = $1;
    $do=~/^\s*(\d+)\s+(\d+)\s+(\d+)\s*$/ms or warn "Error! Can't find data!\nIN :\n$do";
    $opt{d2} = $1;
    $opt{d3} = $2; 
    $opt{d4} = $3;
#elsif { $do=~/^Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/; }
 
print "$opt{d1}\n";
print "$opt{d2}\n";
print "$opt{d3}\n";
print "$opt{d4}\n";
#print "$opt{up}\n" if $opt{up};
print "Nginx $opt{var}\n";

Once this has been created somewhere (I like /bin for this), you then need to link it into snmp.

you can do this with something along the lines of  the following in your /etc/snmp/snmpd.conf

extend .1.3.6.1.4.1.3031.67 "exim-stats"        /usr/bin/perl   /bin/nginx_stats.pl

output will look something like


iso.3.6.1.4.1.3031.67.1.0 = INTEGER: 1
iso.3.6.1.4.1.3031.67.2.1.2.10.101.120.105.109.45.115.116.97.116.115 = STRING: "/usr/bin/perl"
iso.3.6.1.4.1.3031.67.2.1.3.10.101.120.105.109.45.115.116.97.116.115 = STRING: "/bin/nginx_stats.pl"
iso.3.6.1.4.1.3031.67.2.1.4.10.101.120.105.109.45.115.116.97.116.115 = ""
iso.3.6.1.4.1.3031.67.2.1.5.10.101.120.105.109.45.115.116.97.116.115 = INTEGER:5
iso.3.6.1.4.1.3031.67.2.1.6.10.101.120.105.109.45.115.116.97.116.115 = INTEGER:1
iso.3.6.1.4.1.3031.67.2.1.7.10.101.120.105.109.45.115.116.97.116.115 = INTEGER:1
iso.3.6.1.4.1.3031.67.2.1.20.10.101.120.105.109.45.115.116.97.116.115 = INTEGER: 4
iso.3.6.1.4.1.3031.67.2.1.21.10.101.120.105.109.45.115.116.97.116.115 = INTEGER: 1
iso.3.6.1.4.1.3031.67.3.1.1.10.101.120.105.109.45.115.116.97.116.115 = STRING: "1"
iso.3.6.1.4.1.3031.67.3.1.2.10.101.120.105.109.45.115.116.97.116.115 = STRING: "1
360890
360890
338689
Nginx "
iso.3.6.1.4.1.3031.67.3.1.3.10.101.120.105.109.45.115.116.97.116.115 = INTEGER:5
iso.3.6.1.4.1.3031.67.3.1.4.10.101.120.105.109.45.115.116.97.116.115 = INTEGER:0
iso.3.6.1.4.1.3031.67.4.1.2.10.101.120.105.109.45.115.116.97.116.115.1 = STRING: "1"
iso.3.6.1.4.1.3031.67.4.1.2.10.101.120.105.109.45.115.116.97.116.115.2 = STRING: "360890"
iso.3.6.1.4.1.3031.67.4.1.2.10.101.120.105.109.45.115.116.97.116.115.3 = STRING: "360890"
iso.3.6.1.4.1.3031.67.4.1.2.10.101.120.105.109.45.115.116.97.116.115.4 = STRING: "338689"
iso.3.6.1.4.1.3031.67.4.1.2.10.101.120.105.109.45.115.116.97.116.115.5 = STRING: "Nginx "

]]>
http://www.daveheavyindustries.com/2013/08/12/nginx-snmp-monitoring/feed/ 0
#junipered. http://www.daveheavyindustries.com/2011/09/15/junipered/ http://www.daveheavyindustries.com/2011/09/15/junipered/#comments Thu, 15 Sep 2011 03:35:42 +0000 admin http://wp.daveheavyindustries.com/?p=213 #junipered - to be promised a service or a product that was not delivered
#ciscoed - When you deliver the products and solutions that the customer wants, when the customer wants it.
... apparently.


Currently trending on twitter, #junipered means a few different things to a few different people. For anyone with marketing experience, it represents the blatent disregard for the cardinal rule of advertising. For Cisco fans, it's a reference to http://www.overpromisesunderdelivers.net , saying Juniper over promises and is a vendor of vaporware that is only hurting its customers. For Juniper fans, its a sign that Cisco is launching a childish advertising campaign as they're loosing market share to Juniper.

For me, it's sad. As a cisco fan, I'm a little worried that they're stooping this low, and certainly taken away from their image they I had of them. This is the first time I've seen them actually acknowledging the competition in any other way besides performance comparisons (and always retaliated against with TCO comparisons).

I'm sure everyone can see many sides to this, but what will be most interesting, is Junipers response, if any.

 

]]>
http://www.daveheavyindustries.com/2011/09/15/junipered/feed/ 2
HTC Desire S Flashing problems… M4G2DE http://www.daveheavyindustries.com/2011/09/13/htc-desire-s-flashing-problems-m4g2de/ http://www.daveheavyindustries.com/2011/09/13/htc-desire-s-flashing-problems-m4g2de/#comments Mon, 12 Sep 2011 23:01:19 +0000 admin http://wp.daveheavyindustries.com/?p=207 After a huge amount of effort, lots of "status 1" lots of "can't open /cache/recovery/log " ... I stumbled across this site - http://forum.xda-developers.com/showthread.php?t=1150917

My heart sank. I feared for the worst. I had infact ejected and re-inserted the battery in close succession when it had frozen earlier that day.

I installed the HTC adb and fastboot drivers, android SDK and platform tools, booted the clockworkmod bootloader (yes, was already s-off and gingerbroken), and started throwing some adb commands at it from here - http://forum.xda-developers.com/showpost.php?p=16135893&postcount=27

adb shell cat /sys/devices/platform/msm_sdcc.2/mmc_host/mmc0/mmc0:0001/name
M4G2DE

... bugger, he thought.

adb shell  dmesg | grep mmc0

lots of i/o errors, but most importantly...  mmc0: Deferred resume failed

... bugger, bugger, he thought. the phone gods were angry with me.

Just as the xda-developer prophecy fortold, your mmc will stop working if its a M4G2DE and you don't treat the battery nicely.

My next thought was, restore the original boot and recovery and try and plead my case for a warranty... I doubted they'll be kind to me if they saw clockworkmod on boot.

so, I pulled apart the HTC telstra RUU and got the boot.img and recovery.img ready for a fastboot (more drivers required.. agh.) and was presented with

C:\android\tools>fastboot.exe flash boot ..\boot_signed.img
      sending 'boot' (2836 KB)... OKAY [  0.495s]
                writing 'boot'... FAILED (remote: not allowed)

... That's a bit rude, same thing for recovery.img.

As a last stich attempt, I booted back into fastboot, and ran the telstra RUU again. as i couldn't use adb to see the kmsg, I assumed it was going poorly... until... it booted!

failing to believe what I was seeing.... I ran the same command given to me to check the mmc... and..

<3>[    8.589385] mmc0: No card detect facilities available
<6>[    8.590026] mmc0: Qualcomm MSM SDCC at 0x00000000a0500000 irq 98,0 dma 7
<6>[    8.590148] mmc0: Platform slot type: MMC
<6>[    8.590393] mmc0: 4 bit data mode disabled
<6>[    8.590515] mmc0: 8 bit data mode enabled
<6>[    8.590637] mmc0: MMC clock 144000 -> 50000000 Hz, PCLK 96000000 Hz
<6>[    8.590881] mmc0: Slot eject status = 0
<6>[    8.591003] mmc0: Power save feature enable = 1
<6>[    8.591247] mmc0: DM non-cached buffer at ffa0f000, dma_addr 0x0bb01000
<6>[    8.591369] mmc0: DM cmd busaddr 0x0bb01000, cmdptr busaddr 0x0bb01300
<6>[    8.745025] mmc0: new high speed MMC card at address 0001
<6>[    8.746337] mmcblk0: mmc0:0001 M4G2DE 2.10 GiB

SUCCESS! Potentially good news for anyone mid-heart-attack, your phone might not (but still could be) screwed.

I have since re gingerbroken, installed Cyanogen, and am back up and running with a working phone.

------

Update 20/9 - phone has been operational for about a week now, all is good.

To follow up a few questions - logs did indicate "failed to get card ready" , "deferred resume failed", several DMA errors, several (thousands of lines) of i/o errors. I guess something I've taken from all of this is that its possible that the current tests accepted on XDA to determine a hardware fault are not conclusive. I was ready to prepare my phone for a warranty (if I was lucky) repair, and installing the stock RUU fixed the issue. I have no doubt that there are people with a physically damaged emmc out there, but I was not one of them, and I think that means I'm not alone - so don't give up yet, try and flash the RUU from fastboot.

I was asked on XDA to prepare a filesystem and format it, and confirm there were no errors - there were not.

~ # mke2fs -j /dev/block/mmcblk0p27
mke2fs -j /dev/block/mmcblk0p27
mke2fs 1.40.8 (13-Mar-2008)
/dev/block/mmcblk0p27 is apparently in use by the system; will not make a filesy
stem here!
~ # umount /cache
umount /cache
~ # mke2fs -j /dev/block/mmcblk0p27
mke2fs -j /dev/block/mmcblk0p27
mke2fs 1.40.8 (13-Mar-2008)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
76912 inodes, 307196 blocks
15359 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
38 block groups
8192 blocks per group, 8192 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

~ # e2fsck /dev/block/mmcblk0p27
e2fsck /dev/block/mmcblk0p27
e2fsck 1.41.6 (30-May-2009)
/dev/block/mmcblk0p27: clean, 11/76912 files, 20003/307196 blocks
~ # e2fsck /dev/block/mmcblk0p27 -f
e2fsck /dev/block/mmcblk0p27 -f
e2fsck 1.41.6 (30-May-2009)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/block/mmcblk0p27: 11/76912 files (0.0% non-contiguous), 20003/307196 blocks

]]>
http://www.daveheavyindustries.com/2011/09/13/htc-desire-s-flashing-problems-m4g2de/feed/ 11
iinet cisco 877 config http://www.daveheavyindustries.com/2011/09/03/iinet-cisco-877-config/ http://www.daveheavyindustries.com/2011/09/03/iinet-cisco-877-config/#comments Sat, 03 Sep 2011 06:59:25 +0000 admin http://wp.daveheavyindustries.com/?p=193 This is the config I'm recommending for people running cisco 877's on iinet. feel free to post back with any amendments.
config working on IOS 12.4(24)T3

replace [username] with your iinet username and [password] with your iinet password.

hostname router
ip dhcp pool general
network 10.10.10.0 255.255.255.0
dns-server 10.10.10.1
default-router 10.10.10.1
domain-name router.local
!
ip dns server
ip domain name router.local
ip name-server 203.0.178.191
interface ATM0
no ip address
no ip redirects
no ip unreachables
no ip proxy-arp
no ip mroute-cache
no atm ilmi-keepalive
!
interface ATM0.1 point-to-point
description $ES_WAN$$FW_OUTSIDE$
pvc 8/35
encapsulation aal5mux ppp dialer
dialer pool-member 1
!
!
interface FastEthernet0
switchport access vlan 1
!
interface FastEthernet1
switchport access vlan 1
!
interface FastEthernet2
switchport access vlan 1
!
interface FastEthernet3
switchport access vlan 1
!
interface Vlan1
description --- INSIDE INTERFACE ---
ip address 10.10.10.1 255.255.255.0
ip nat inside
ip virtual-reassembly
ip tcp adjust-mss 1412
!
interface Dialer1
description --- OUTSIDE INTERFACE ---
ip address negotiated
ip mtu 1452
ip nat outside
ip virtual-reassembly
encapsulation ppp
dialer pool 1
dialer-group 1
no cdp enable
ppp authentication chap pap callin
ppp chap hostname [USERNAME]@iinet.net.au
ppp chap password password 0 [PASSWORD]
ppp pap sent-username [USERNAME]@iinet.net.au  password [PASSWORD]
!
ip access-list extended nat
permit ip 10.10.10.0 0.0.0.255 any
ip route 0.0.0.0 0.0.0.0 Dialer1
no ip http server
no ip http secure-server
ip dns server
ip nat inside source list nat interface Dialer1 overload

[facebook_ilike]
]]>
http://www.daveheavyindustries.com/2011/09/03/iinet-cisco-877-config/feed/ 0
TPG Username http://www.daveheavyindustries.com/2011/08/30/tpg-username/ http://www.daveheavyindustries.com/2011/08/30/tpg-username/#comments Mon, 29 Aug 2011 22:37:14 +0000 admin http://wp.daveheavyindustries.com/?p=190 last one - TPG Usernames for use on dialing up from your router..
should be in the format username@tpg.com.au

]]>
http://www.daveheavyindustries.com/2011/08/30/tpg-username/feed/ 0
TPG MTU & MSS for ADSL2+ http://www.daveheavyindustries.com/2011/08/30/tpg-mtu-mss-for-adsl2/ http://www.daveheavyindustries.com/2011/08/30/tpg-mtu-mss-for-adsl2/#comments Mon, 29 Aug 2011 22:36:14 +0000 admin http://wp.daveheavyindustries.com/?p=188 Again, keep getting asked this one, TPG uses PPPoE which works a little differently in terms of MTU and MSS.

I found the best settings for me were
MTU 1492
MSS 1452

on a cisco router this is achieved by

interface Vlan1
ip tcp adjust-mss 1452
!
interface Dialer1
ip mtu 1492
!

]]>
http://www.daveheavyindustries.com/2011/08/30/tpg-mtu-mss-for-adsl2/feed/ 0
TPG DNS Servers http://www.daveheavyindustries.com/2011/08/30/tpg-dns-servers/ http://www.daveheavyindustries.com/2011/08/30/tpg-dns-servers/#comments Mon, 29 Aug 2011 22:33:47 +0000 admin http://wp.daveheavyindustries.com/?p=181 Keep getting asked this one, for some reason.
here they are, the TPG DNS (Domain Name Servers)
203.12.160.35
203.12.160.36
203.12.160.37

]]>
http://www.daveheavyindustries.com/2011/08/30/tpg-dns-servers/feed/ 0
Ableton Live 8.2.5 now officially supported on OS X 10.7 Lion http://www.daveheavyindustries.com/2011/08/29/ableton-live-8-2-5-now-officially-supported-on-os-x-10-7-lion/ http://www.daveheavyindustries.com/2011/08/29/ableton-live-8-2-5-now-officially-supported-on-os-x-10-7-lion/#comments Mon, 29 Aug 2011 07:16:53 +0000 admin http://wp.daveheavyindustries.com/?p=179 Been asked about this a bit over the last few weeks. It's official.. go forth and update to 10.7

http://www.ableton.com/news/osx-10-7-lion-compatibility-live-update-coming-soon

 

Tips, Tricks & Secrets For OS X Lion - 

 

]]>
http://www.daveheavyindustries.com/2011/08/29/ableton-live-8-2-5-now-officially-supported-on-os-x-10-7-lion/feed/ 0
Unable to post link to facebook http://www.daveheavyindustries.com/2011/04/29/unable-to-post-link-to-facebook/ http://www.daveheavyindustries.com/2011/04/29/unable-to-post-link-to-facebook/#comments Fri, 29 Apr 2011 05:29:27 +0000 admin http://wp.daveheavyindustries.com/?p=153 Strange one this morning. Our e-comm guys reported they were unable to post any links to their page, their own wall, other peoples walls... anywhere on facebook really. only "The message could not be posted to this Wall." was presented to them as an error.. useful??!?? I think not. After a bit of investigation, I found that it was some pages but not others. The home page for example worked, but a product would not. A content page would, but a category page would not. Ugh.

They all use the same template so I thought surely the html would be very similar... and it was. I ran the pages through the w3c validator, and made a bunch of unecessary changes to do with short-tags and pulled my hair out some more.

A few more coffees and some tweeting and googling brought to my attention that the error "The message could not be posted to this Wall." could be due to facebook blocking that url due to abuse... maybe one of our competitors complained to upset our social strategy? no - then all of the urls would be broken (only lost an hour here :| )

I went back to the HTML, removed anything fancy and it still didn't work. I decided not to let this get the better of me, and I went through the html line by line looking for anything out of the ordinary... and there it was.

Canonical link was missing a slash. <link rel="canonical" href="https:/somedomain.com" />. Now this was set by our e-commerce system, not by the template or development, and none of that has changed for a really long time, meaning that something at facebooks end has tightened up the validation. Anyway, not pointing fingers, commented it out and Posts are now sharing as expected. ugh.

 

 

]]>
http://www.daveheavyindustries.com/2011/04/29/unable-to-post-link-to-facebook/feed/ 0
MS SQL Server – index fragmentation – amended http://www.daveheavyindustries.com/2011/04/29/ms-sql-server-index-fragmentation-amended/ http://www.daveheavyindustries.com/2011/04/29/ms-sql-server-index-fragmentation-amended/#comments Thu, 28 Apr 2011 23:39:00 +0000 admin http://wp.daveheavyindustries.com/?p=148 From http://wp.daveheavyindustries.com/2011/02/07/ms-sql-server-index-fragmentation/

Having had to use this on a very large database, I've made some small changes to the index fragmentation statistics script. this time to include table names (object_name) as well as database_name.

SELECT
ps.database_id,
ps.OBJECT_ID,
OBJECT_NAME(ps.OBJECT_ID,db_id()) as [object_name],
DB_NAME(ps.database_id) as [database_name],
ps.index_id,
b.name,
ps.avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS ps
INNER JOIN sys.indexes AS b on ps.OBJECT_ID = b.object_id and b.index_id = ps.index_id
WHERE ps.database_id = DB_ID()
ORDER BY ps.avg_fragmentation_in_percent
GO
]]>
http://www.daveheavyindustries.com/2011/04/29/ms-sql-server-index-fragmentation-amended/feed/ 0