w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How can I monitor the memory usage of a shell script at runtime?
you can use the ps command: ps aux | grep <scriptName> ps aux | grep "curl -s example" ps aux | grep "egrap -s 'sth'" ps aux | grep "sleep 60" the 3rd and 4th columns are cpu and mem (you can get them using awk)

Categories : Shell

android-how to monitor the orientation of the device in Realtime?
You should use the SensorEventListener private final SensorEventListener mSensorListener = new SensorEventListener() { public void onSensorChanged(SensorEvent se) { float x = se.values[0]; float y = se.values[1]; float z = se.values[2]; mAccelLast = mAccelCurrent; mAccelCurrent = (float) Math.sqrt((double) (x*x + y*y + z*z)); float delta = mAccelCurrent - mAccelLast; mAccel = mAccel * 0.9f + delta; // perform low-cut filter } public void onAccuracyChanged(Sensor sensor, int accuracy) { } }; On your Activity you have to import: private SensorManager mSensorManager; private float mAccel; // acceleration apart from gravity private float mAccelCurrent; // current acceleration including gravity private float mAccelLast; // last acc

Categories : Java

How to monitor the number of users online in a site realtime
You can use WebSockets, which maintains a persistent connection from the browser to the server. You can determine when someone leaves the page using one of a couple of methods, such as: Code sent through the socket connection just before the page unloads. The socket connection is unexpectedly dropped. While the connection is open, you can send other information over the connection to gather analytic information, such as if someone clicks on a particular element, or if they've clicked anywhere on the page and where. WebSockets is relatively new, and so requires a modern browser to function correctly. According to this site, WebSockets is fully supported in IE10, Firefox 6, Chrome 14, Safari 6, and Opera 12.1. If you need to support earlier browsers, you'd want to use an AJAX fallbac

Categories : PHP

Live preview aptana on different monitor
I actually found a chrome extension to do the job, it's called LivePage The good thing is that it isn't even related to aptana or another IDE, it simply checks for file changes and refreshes the page. :)

Categories : Google Chrome

Substituting a dll, to monitor dll usage
yes, entirely possible you can already figure out what the function signatures are and re-implement them (heh, Google already did this with Java JRE :) ) The problem you have is loading a different dll with the same name, though its entirely possible you can do this explicitly with a fixed directory. you can load the dll and then hook up all its functions. At least that's what I think will happen - having 2 dlls of the same name in the same process might be troublesome (but I think, different path, all's ok). Security generally isn't done when loading dlls, however MS does this with some .NET assemblies, but the cost is that it takes a long time to load them as there's a significant delay caused by the decryption required to secure the dll. this is why a lot of .NET applications (espec

Categories : Windows

How to monitor the EC2 compute usage of a directory on AWS
No, it is not possible to allocate Amazon EC2 usage costs to a fine-grained level, such as individual directory, application or user. Amazon EC2 is charged on an hourly basis, with the cost varying by: Instance Type (CPU, RAM, chipset) Operating System (eg Windows instances include an hourly charge for Windows) Billing type (On-Demand, Reserved Instance, Spot) While the AWS billing system can allocate EC2 costs based on tags (eg Department), this is only done for a whole instance on an hourly basis. Some ideas for fine-grained allocation of costs: Record usage in CloudWatch via a Custom Metric, then extract data for billing purposes Store usage information in log files and send them to CloudWatch Logs, then extra data for billing purposes Track usage in a file, send it to Amazon S3

Categories : Amazon

TC Bandwidth throttle script error
It looks like the code might not be formatted correctly. Try putting exit 0 on a new line like so: pwd=$(pwd) echo "Usage: tc.bash {start|stop|restart|show}" ;; esac exit 0 esac is used to close out case statements in bash. Hope that helps!

Categories : Linux

How to monitor the computer's cpu, memory, and disk usage in ASP.NET?
Perfomance counters is my advice. Check out Setting up performance counters for ASP.NET Beyond performance counters, if you really want to get an 'inside' look at your code, then you can try a memory profiler, such as the following: CLR Profiler - free Red Gate's ANTS Memory Profiler - NOT free Visual Studio 2012 Memory Profiler - may be free depending upon which version of VS2012 you have

Categories : Asp Net

how do android monitor usage applications work
The only way to monitor other apps is by monitoring foreground activity. This will drain your battery but there is no broadcast when other apps are launched and hence no other way to do it. You would like to start a timer task that checks the current foreground activity. I would highly recommend not to do it. To get current foreground activity use the following code: ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); List< ActivityManager.RunningTaskInfo > taskInfo = am.getRunningTasks(1); Log.d("topActivity", "CURRENT Activity ::" + taskInfo.get(0).topActivity.getClassName()); ComponentName componentInfo = taskInfo.get(0).topActivity; componentInfo.getPackageName(); You will need the following permission: <uses-permission android:name

Categories : Android

Can I monitor the usage of individual directories with AWS CloudWatch?
You should be able to use cloudwatch to do this, however, it might not be the most efficient place to put this information if you are going to bill or report on it. I think you are better off computing the data and then storing it in a database of your own. This way you have easy access to the data and you can do things with data that may not work well in the context of cloudwatch.

Categories : Amazon

System.Management resources monitor for statistics info such as I/O, CPU, Memory usage... etc'
public class MyPerfoamnceCounter { public string pc() { Dictionary<string, List<PerformanceCounter>> counters = new Dictionary<string, List<PerformanceCounter>>(); List<PerformanceCounter> cpuList = new List<PerformanceCounter>(); List<PerformanceCounter> procList = new List<PerformanceCounter>(); List<PerformanceCounter> memList = new List<PerformanceCounter>(); PerformanceCounterCategory perfCat = new PerformanceCounterCategory(); foreach (Process process in Process.GetProcesses()) { PerformanceCounter procProcesTimeCounter = new PerformanceCounter( "Process", "% Processor Time", process.ProcessName); var proc = procProc

Categories : C#

Ruby shell script realtime output
You can always execute this in Ruby: system("sh", "script.sh") Note it's important to specify how to execute this unless you have a proper #!/bin/sh header as well as the execute bit enabled.

Categories : Ruby

How to use perl script to monitor whether a process is finished?
You could open a named pipe and wait for it to close: open(PROC, "-|", "/path/to/process") or die "can't open process: $!"; # do something close(PROC) or die "can't close process: $!"; The close statement will make the perl script wait for the process to finish.

Categories : Perl

monitor a directory and pull new files as they appear - bash script
Two products come to mind depending on how you plan to approach the solution. I personally use Splunk on a variety of platforms (Windows & Linux servers/local Linux & OSX dev environments). It is a real-time log aggregator that features an API and the ability to query. Even if this doesn't solve your problem, the free version has some very robust features that you should consider: http://www.splunk.com The second approach would be synchronization of your web directories using something like RSync. I've used RSync on Linux boxes and always appreciated what it can do. I even see it now has a Windows port: https://www.itefix.no/i2/cwrsync

Categories : Bash

GAS script to monitor email inbox only responds intermittently
@patt0 - I had tried the .getPlainBody() option but it didnt help. It turned out that the problem wasnt in how the script parsed the data, it was in the initial 'if' statement. I changed the first four lines to this and it fixed it: var NewPhy = GmailApp.getUserLabelByName("New Physician Request") var TransPhy = GmailApp.getUserLabelByName("Transferred Physician Request") var Threads = NewPhy.getThreads() if (Threads[0]) { var messages = Threads[0].getMessages() var body = messages[0].getBody().split("<br />") After this, I left the rest of the code as it appears in the initial question and it works. For anyone that might need an example like this in the future, this code triggers every 5 minutes and monitors a google inbox for an email that contains a form lette

Categories : Email

monitor for creation and then read a file via windows .bat script
Here's a PowerShell script that will do what you asked. $content variable will store contents of the file (it will actually be an array of lines so you can throw it into foreach loop). $file = 'C:flag.xml' $timeout = New-TimeSpan -Minutes 1 $sw = [diagnostics.stopwatch]::StartNew() while ($sw.elapsed -lt $timeout) { if (Test-Path $file) { "$(Get-Date -f 'HH:mm:ss') Found a file: $file" $content = gc $file if ($content -contains 'something interesting') { "$(Get-Date -f 'HH:mm:ss') File has something interesting in it!" } break } else { "$(Get-Date -f 'HH:mm:ss') Still no file: $file" } Start-Sleep -Seconds 5 }

Categories : Windows

Send email alert from Performance Monitor using PowerShell script
There are basically two things to address that should make this work for you. Get the alert parameters correctly passed to your script. Actually call the function defined in your script. We'll start with the parameters. On the Alert Task tab of your alert (pictured above), edit the Task Arguments field and replace: {name}{date}{counter}{threshold}{value} with: "{name}" "{date}" "{counter}" "{threshold}" "{value}" Your parameters are basically being parsed as a space-separated string value, so we add double-quotes around each individual parameter token to handle values that include spaces, and we add a space between each individual parameter token so that we'll be able to tell one parameter from the next. Then, for the action of your scheduled task (named "Processor Monitori

Categories : Email

Add data in Sequelize migration script?
I figured it out. Sequelize is available from migration.migrator.sequelize. It is possible to do something like this: up: function (migration, DataTypes, done) { migration.createTable( 'Person', { name: DataTypes.STRING, age: DataTypes.INTEGER, } ).success(function () { migration.migrator.sequelize.query("insert into person (name, age) values ('Donald Duck', 60)"); done(); }); }, down: function (migration, DataTypes, done) { migration.dropTable( 'Person' ).then(function() { done(); }) }

Categories : Node Js

Renaming a column in a migration script in Doctrine2
The 'diff' that the exception is talking about is the diff between your original Schema and your updated Schema. This is how Doctrine generates the SQL statements -- by comparing the current Schema to the modified Schema. There is no way for Doctrine to reliably figure out that someColumn in $originalTable is now someRenamedColumn in $modifiedTable (pardon the bad psuedocode) and so the functionality was removed .

Categories : PHP

Trouble with loading a csv from a migration script in rails
I had this problem when using activerecord-fast-import (which is based on the same type of import query), and found out that, for security reasons, both the server and the client need to have this enabled. The setting on (my.cnf) is indeed needed for the server. To enable it on the client, just add this to database.yml: local_infile: true

Categories : Mysql

perl script to monitor & restart listener hangs on nohup waiting for carriage return
You're looking for the system() function, not exec() From the doc for exec(): The exec function executes a system command and never returns; use system instead of exec if you want it to return. Try doing system( $start_comtrol ) instead.

Categories : Perl

Running a script in a google live form
Short answer: In Google Forms? No Long Answer: You can if you use Google Apps Scripting and the UiApp to custom create a form that can interact if you utilize the ChangeListener for the listbox. Cheers.

Categories : Google Apps Script

How do i write a shell script for checking website live or not
Change it do this: if [ $(curl -s --head --request GET http://opx.opera.com/opx/version | grep "200 OK" > /dev/null) ] && [ $(curl -s --head --request GET http://oss.opera.com/version | grep "200 OK" > /dev/null) ] To check the status of a command inside an if, you have to do it like if [ $(command) ] while you were using if [ command] note also the need of spaces around [ ]: if [_space_ command _space_ ] Update Based on Ansgar Wiechers's comment, you can also use the following: if curl -s --head --request GET http://opx.com/opx/version | grep "200 OK" > /dev/null && curl -s --head --request GET http://oss.com/version | grep "200 OK" > /dev/null; That is, if command && command

Categories : Bash

Close connection in PHP but keep executing script in live iis server
finally i found answer ...... 1>On the server main page, under "Management", select "Configuration Editor"; 2>under "Section", enter 'system.webServer/handlers'; 3>next to "(Collection)" click "..." OR mark the element "(Collection)" and, under "Actions" und '(Collection)' Element, click "Edit Items"; 4>scroll down until you find your PHP version under "Name"; 5>at the bottom, the Properties are shown an can be edited manually, including responseBufferLimit, which should be set to 0 for flush() to work. just follwing this steps flush is working on iis..my problem is resolve

Categories : PHP

Using Performance Monitor to monitor pooled connections
You can run this from a SQL query windows to get a count and the details of current connections and session running on your SQL server. select * FROM sys.dm_exec_sessions AS es INNER JOIN sys.dm_exec_connections AS ec ON es.session_id = ec.session_id I've had trouble with pooled connections. They're hard to control. Explicitly closing them never seemed to work since they're under the control of .NET. The biggest reason we've run out of connections is uncommitted transactions. If a transaction is left uncommitted or rolled back for some reason, the connection, instead of being re-used, get's stuck in limbo, forcing .NET to open yet another connection to continue processing.

Categories : Sql Server

Winform SaveFileDialog usage through a php script
This functionality is not available in the SaveFileDialog so a custom control would need to be created to facilitate the behavior you're after. You'll find solutions that sound possible like this CodeProject article but these are largely UI enhancements and do no offer the extensible FileSystem-like layer you would need to achieve what you're after.

Categories : C#

Reduce RAM usage in Python script
What do you want the booklist for, in the end? You should export each book at the end of the "for url in range" block (inside it), and do without the allbooks dict. If you really need a list, define exactly what infos you will need, not keeping full Book objects.

Categories : Python

I can't find live count of elements after running script multiple times
You'll have to count the elements after the animation has completed. When the elements are animating they are still visible, or you could just keep the elements in a collection and count that : $('.filterEventsLinks a').click(function(){ var evCount = $('.singleEvent').length, cats = $(this).data('category').split(','), elems = $([]); $.each(cats, function(_, cat) { var _cat = $('.CAT-' + cat); $('.singleEvent').not(_cat).slideUp(200); _cat.slideDown(200); elems = elems.add(_cat); } // you're sliding all .singleEvent elements except "elems" up, so just count // the elements in "elems" instead, as that should be the visible ones var evCount = elems.length; });

Categories : Javascript

Running One Massive Migration in Rails. Deleted Migration File by Mistake
You don't need to drop all your tables in prod. Instead, create the big migration file you described, but then manually record it as applied in prod. After all, the point of a migration is to apply changes to the DB. In your case that's only needed outside of your production environment. Manually recording the migration is as simple as inserting the migration timestamp into the schema_migrations table: mysql> select * from schema_migrations; +----------------+ | version | +----------------+ | 20120504193548 | | 20120508160150 | | 20120518135330 | | 20120523163509 | ... So just execute the appropriate INSERT and rails will ignore the migration. PS - In the future, use source control so you can just simply restore the file from a prior version!

Categories : Ruby On Rails

Update-Database fails due to Pending Changes, but Add-Migration Creates a Duplicate Migration
I see this all the time also. I don't know why, wish i did, but my solution is to do a add-migration which will make a duplicate. Now this duplicate opens in the editor and then i edit it, so that the Up and Down methods are empty. So the result is a migration file that does nothing! VS is happy and you can do the update-database without errors (until next time). I hope this helps :)

Categories : C#

JQuery selector in handmade lightbox issue + live demo. Simple script need help :)
Add this to your scripts: $('.blackover form').click(function(e){e.stopPropagation();}); It will prevent the click-event of the form from bubbling upwards to the parent section-element

Categories : Javascript

Generating a rails migration, how can I get the migration filename into my clipboard automatically?
I figured out a way to do this in each, (Windows requires you are using rails command line from cygwin for this) For OSX to clipboard rails g migration add_something_to_table | grep -oP 'db/.*.rb' | pbcopy For any linux + X rails g migration add_something_to_table | grep -oP 'db/.*.rb' | xclip For Windows (with cygwin) rails g migration add_something_to_table | grep -oP 'db/.*.rb' > /dev/clipboard

Categories : Ruby On Rails

Monitor.Enter vs Monitor.Wait
According to MSDN: Monitor.Wait Method(Object) SynchronizationLockException: The calling thread does not own the lock for the specified object. In other words: You can only call Monitor.Wait(Object), when you already own the lock, whereas you call Monitor.Enter(Object) in order to acquire the lock. As for why Monitor.Wait is needed: If your thread realizes, that it is lacking information to continue execution (e.g. it's waiting for a signal), you might want to let other threads enter the critical section, because not all threads have the same prerequisites. For the waiting thread to continue execution, you will need to call Monitor.Pulse(Object) or Monitor.PulseAll(Object) before releasing the lock (otherwise, you're going to get the same kind of exception as with Monitor.Wait(Ob

Categories : C#

Dynamically edit multiple choice options in live Google Form using Apps Script
I believe we can achieve your second objective without too much difficulty and modify the form, based on the current state of response. The approach is to Create the form and associate it with a response spreadsheet In that response spreadsheet, create a script with a function (updateForm for instance) Bind that function with the onFormSubmit event, see Using Container-Specific Installable Triggers. Analyse the response in the updateForm function and modify your form using the Form Service For instance function updateForm(e) { if (e.values[1] == 'Yes') { Logger.log('Yes'); var existingForm = FormApp.openById('1jYHXD0TBYoKoRUI1mhY4j....yLWGE2vAm_Ux7Twk61c'); Logger.log(existingForm); var item = existingForm.addMultipleChoiceItem(); item.setTitle('Do you prefer c

Categories : Google Apps Script

What slows down Java if CPU usage low, hdd usage low, memory usage low?
You can test what is the bottle neck by taking different parts out of the equation. To take out the CPU, just read the files and don't do anything else. To take out the disk, keep reading the same file again and again, assuming it fits in your file cache. Compare this to the time for everything.

Categories : Java

Script to send alert mail if disk usage exceeds a percentage
You can use the df command to check the file system usage. As a starting point, you can use the below command: df -h | awk -v val=90 '$1=="/pqr"{x=int($5)>val?1:0;print x}' The above command will print 1 if more than threshold, else print 0. The threshold is set in val. Note: Please ensure the 5th column of your df output is the use percentage, else use appropriate column.

Categories : Shell

remove a migration from south migration history
delete from south_migrationhistory where app_name='robots'; south_migrationhistory table just keeps track of what migrations have been applied and what are yet to be applied. Since 0.8 of robots doesn't have any migration files any entries for it from table south_migrationhistory can be removed and it won't affect anything else.

Categories : Django

Possible EF6 beta 1 Migration bug. Codefirst migration deadlock
Try explicitly specifying the migrations with Update-Database one at a time. If that doesn't work, try applying the InitialCreate by itself, then re-creating/Adding the ChangePegawaiToTPT. Be sure to have a backup copy first... There are some cases where many-to-many relationships are being named differently in rc1 than in the beta, which causes some headaches.

Categories : C#

Error "Task can be only monitored with a single monitor" when setting my monitor to a task in dll
OnMessage function creates implicit monitor which receives the task message and calls your anonymous function. Same goes for OnTerminated. If you wish to use MonitorWith, you should implement message processing and termination handling as a monitor events, not with OnMessage/OnTerminated functions.

Categories : Delphi

Provide password to ssh command inside bash script, Without the usage of public keys and Expect
AFAIK there is no possibility beside from using keys or expect if you are using the command line version ssh. But there are library bindings for the most programming languages like C, python, php, ... . You could write a program in such a language. This way it would be possible to pass the password automatically. But note this is of course a security problem as the password will be stored in plain text in that program

Categories : Linux



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.