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 "]]>
First things first, you'll need to get a copy of chan-sccp-b (http://chan-sccp-b.sourceforge.net/) and compile it. If you don't know how to do that, follow the steps on the chan-sccp-b site.
Grab a copy of my freepbx module -
http://wp.daveheavyindustries.com/?attachment_id=357
http://wp.daveheavyindustries.com/?attachment_id=372
http://wp.daveheavyindustries.com/?attachment_id=378
http://wp.daveheavyindustries.com/?attachment_id=382
I used this sccp.conf, pay attention to the bold lines, this is what tells chan-sccp-b to talk to the mysql database for it's config (which the freepbx module updates).
[general]
servername = Asterisk keepalive = 60 debug = core,event,device,channel context = from-internal dateFormat = D.M.Y bindaddr = 0.0.0.0 port = 2000 disallow=all allow=g722 allow=g729 allow=alaw allow=ulaw firstdigittimeout = 16 digittimeout = 8 autoanswer_ring_time = 1 autoanswer_tone = 0x32 remotehangup_tone = 0x32 transfer_tone = 0 callwaiting_tone = 0x2d musicclass=default language=en deny=0.0.0.0/0.0.0.0 permit=10.0.0.0/255.0.0.0 dnd = off sccp_tos = 0x68 sccp_cos = 4 audio_tos = 0xB8 audio_cos = 6 video_tos = 0x88 video_cos = 5 echocancel = on silencesuppression = off private = off callanswerorder=oldestfirst meetme = on meetme = qxd hotline_enabled=yes ; can devices without configuration register hotline_context=default ; context for hotline hotline_extension=111 ; extension will be dialed on offHook devicetable=sccpdevice linetable=sccpline
append this to your res_config_mysql.conf (your username, password and database name added obviously)
[asterisk] dbhost = 127.0.0.1 dbname = asterisk dbuser = username dbpass = password
execute mysql-v5.sql from chan-sccp_trunk/conf of your downloaded chan-sccp-b source on your mysql database
mysql --user=user --password=password asterisk < mysql-v5.sql
install the module to freepbx (http://yourpbxip/admin )
Admin -> Module Admin ->Upload Module ->Chose File -> browse to sccp_module.tar.gz (downloaded from above) -> Upload
Admin -> Module Admin -> SCCP Manager -> Install -> Process (bottom right hand corner) -> Confirm
Two new menus will be added under "Basic"
SCCP Device Manager
SCCP Line Manager
SCCP Button Manager <-- SCCP Button manager cannot be accessed directly, this is called via the SCCP Device Manager
Self explanatory really.
now the last step is to add sccp to the extension list so you can map extensions to SCCP.
edit /var/www/html/admin/modules/core/functions.inc.php around line 6041.
Add this above "$currentcomponent->setoptlistopts('devicelist', 'sort', false);" :-
$currentcomponent->addoptlistitem('devicelist', 'sccp', _("SCCP MAP"));
Now, for elastix, to get the module visible from the elastix gui, I ahd to add two lines to modules/pbxadmin/themes/default/main.tpl, just below extensions
<li><a href="/?menu=pbxconfig&type=setup&display=sccpline" >SCCP Line</a></li>
<li><a href="/?menu=pbxconfig&type=setup&display=sccpdevice" >SCCP Device</a></li>
Install JSON module for PHP
yum info php-pecl-json-1.2.1-4.el5.x86_64
and add to php.ini under Dynamic Extensions
extension=json.so
and you're done!
]]>Usually it'll be something along the lines of DEV -> UAT -> PRE_PRODUCTION -> PRODUCTION
So, how do you get updates that have been developed against in DEV to UAT, or from UAT to PREPROD, or PREPROD into production?
well, I wrote a script.. two really, but we'll get to that.
update approval copier.
This copies all update approvals from a source target into a destination target where it has been approved, installed, and where it hasn't failed (on any computer) on the source computer target.
Approve already installed updates
Now... the second is very simpler, it's for when you first deploy WSUS, and you want to copy a baseline for approvals from already updated servers within that target. Note the source and the target are the same (although you could change if it you wanted to copy installed updates as approvals to another target)
Function js_escape(ByRef input_string)
If NOT IsNull(input_string) AND input_string <> "" Then Dim working_string working_string = input_string working_string = Replace(working_string, vbNewLine, "\n") working_string = Replace(working_string, vbTab, "\t") working_string = Replace(working_string, "'", "\'") ' .. other escape values/strings you may wish to add js_escape = working_string End If End Function]]>
The UPS has a metric for each Phase, so for a total output, we have to aggregate the figure. I chose to use Watts in my graphs. The other thing to note is that it requires version 1 of SNMP.
Config below....
$Path is the working directory, needs to exist. $Name is the mrtg name of the instance. $Community is the snmp community (usually public), $host is the hostname/ip of the device. $Title is the friendly name of the instance. Easy as that.
WorkDir:$Path Target[$Name]: enterprises.534.1.4.4.1.4.1&enterprises.534.1.4.4.1.4.1:$Community@$Host:::::1 + enterprises.534.1.4.4.1.4.2&enterprises.534.1.4.4.1.4.2:$Community@$Host:::::1 + enterprises.534.1.4.4.1.4.3&enterprises.534.1.4.4.1.4.3:$Community@$Host:::::1 MaxBytes[$Name]: 36000 Title[$Name]: $Title PageTop[$Name]: <H1>$Title</H1> Options[$Name]: gauge, nopercent, absolute, unknaszero, growright YLegend[$Name]: Watts ShortLegend[$Name]: Watts Legend1[$Name]: Watts Legend2[$Name]: . Legend3[$Name]: Max value per interval on graph Legend4[$Name]: . LegendI[$Name]: True Power LegendO[$Name]: . Colours[$Name]: GREEN#00eb0c,BLUE#0000ff,GRAY#AAAAAA,VIOLET#ff00ff WithPeak[$Name]: ymw
]]>
Well, the SNMP oid for this device is enterprises.318.1.1.12.2.3.1.1.2.1 .The current is returned as AMPSx10 .
I.E... will return 100 for 10 amps. The reason for this is that all things snmp expect whole numbers (bits, bytes etc..), the rail measures to 1/10th AMP, so this is the only way they could really do it.
Because of this, you need to let MRTG know that the scale is 0.1
other than that... its very straight foward.
$Path is the Working directory, you need to create it before running it. $Community is the snmp community (usually public), $Host is the hostname/ip of the power rail, $name is the MRTG name of the instance. $Title is the friendly name. Easy?
WorkDir: $PATH Target[$NAME]: enterprises.318.1.1.12.2.3.1.1.2.1&enterprises.318.1.1.12.2.3.1.1.2.1:$COMMUNITY@$HOST MaxBytes[$NAME]: 200 Title[$NAME]: $Title PageTop[$NAME]: <H1>$Title</H1> Options[$NAME]: gauge, nopercent, absolute, unknaszero, growright YLegend[$NAME]: Current ShortLegend[$NAME]: Amps Legend1[$NAME]: Current, Amps Legend2[$NAME]: . Legend3[$NAME]: Max value per interval on graph Legend4[$NAME]: . LegendI[$NAME]: Current LegendO[$NAME]: . Colours[$NAME]: GREEN#00eb0c,BLUE#0000ff,GRAY#AAAAAA,VIOLET#ff00ff WithPeak[$NAME]: ymw YTicsFactor[$NAME]: 0.1]]>
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.
]]>
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
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]]]>