Docker on Centos でzabbix serverを作ってみる
1年半振りの更新とか('A`)しかもazure関係ねぇし…。
CentOSにDockerをインストール
sudo yum install docker -y
お手軽お気軽。
ここでインストールしたdockerは一般ユーザーで
docker ps
とかすると
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
と、怒られる。
こいつはdocker.sockのパーミッションが無いから。
ls -la /var/run/docker.sock srw-rw----. 1 root root 0 6月 3 15:29 /var/run/docker.sock
使うユーザーを
sudo usermod -g root hogehoge
すればいいんだけどセキュリティ的にアレなのでsudo で使おう。
zabbixをdockerで動かす。
公式のzabbix/zabbix**が妙に不親切にできてるのが大変に遺憾。
zabbix - Docker Hub
https://hub.docker.com/u/zabbix/
なので割りと親切なmonitoringartist版を使う。
monitoringartist/zabbix-3.0-xxl - Docker Hub
https://hub.docker.com/r/monitoringartist/zabbix-3.0-xxl/
古いプロジェクトをAzureにデプロイするとCould not load file or assembly System.Web.Http.WebHost
I met the same problem and I resolved it by setting CopyLocal to true for the following libs:
System.Web.Http.dll
System.Web.Http.WebHost.dll
System.Net.Http.Formatting.dllI must to add that I use MVC4 and NET 4
answered Dec 17 '14 at 14:30 Bronek
asp.net - Could not load file or assembly System.Web.Http.WebHost after published to Azure web site - Stack Overflow
これだった。
INotifyPropertyChangedを自動実装してくれるPropertyChanged.fodyが超便利
ViewModel的なものを作るときに必ず出てくるのがINotifyPropertyChanged インターフェイス (System.ComponentModel)
これを実装するのが定跡ではあるんだけど案外面倒くさい。
C# - INotifyPropertyChangedを実装する - Qiita
public sealed class Sample { public string FamilyName { get; set} }
これを
public sealed class Sample : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public string FamilyName { get { return this._FamilyName; } set { if( this._FamilyName == value ) return; this._FamilyName = value; this.PropertyChanged?.Invoke( this , new PropertyChangedEventArgs( nameof( FamilyName ) ) ); } } private string _FamilyName; }
こんな感じで各プロパティについて、実際に値が変更されたかをチェックし変更された時はイベントをinvokeしなきゃならないとかかなりめんどい。
続きを読むストアドプロシージャがアプリケーションから実行すると遅いのにSSMSからだと高速なアレ
ローカルのSSMS*1から直接クエリを実行すると普段通りのパフォーマンスが出てる。クエリキャッシュを考えてランダムのパラメータでロードしても速度は普通。
これどういった話なんだろうと調べた結果そのものずばりな記事があった。
When I read various forums about SQL Server, I frequently see questions from deeply mystified posters. They have identified a slow query or stored procedure in their application. They cull the SQL batch from the application and run it in SQL Server Management Studio (SSMS) to analyse it, only to find that the response is instantaneous. At this point they are inclined to think that SQL Server is all about magic. A similar mystery is when a developer has extracted a query in his stored procedure to run it stand-alone only to find that it runs much faster – or much slower – than inside the procedure.
Slow in the Application, Fast in SSMS?
(;´д`) しかしなんちゅう読みにくい英語だ…
(そのうち訳すつもり)
SQLAzureでSQL Server Profiler的なデータを取得する
早くProfilerに対応してください(´;ω;`)
クエリで出力
パフォーマンスを監視するクエリ SQL Azureに限らず SQL Server でも使えるスクリプトですが、プロファイラを現在使うことのできない SQL Azureでは下記のスクリプトが便利です。このスクリプトを使うと、頻繁に実行されるクエリをその頻度の順番で最大10個まで出力させることができます。(ただし、データベースごとの出力内容となります。)
create table #t ( query_hash varbinary(64), query_plan_hash varbinary(64), num_cache_entries bigint, execution_count bigint, min_creation_time datetime, max_last_execution_time datetime, total_worker_time bigint, min_worker_time bigint, max_worker_time bigint, avg_worker_time float ) go insert into #t select top 10 query_hash, query_plan_hash, count(*) as num_cache_entries, sum(execution_count) as execution_count, min(creation_time) as min_creation_time, max(last_execution_time) as max_last_execution_time, sum(total_worker_time) as total_worker_time, min(min_worker_time) as min_worker_time, max(max_worker_time) as max_worker_time, sum(total_worker_time) / sum(execution_count) as avg_worker_time from sys.dm_exec_query_stats group by query_hash, query_plan_hash order by total_worker_time desc; declare @query_hash varbinary(64), @query_plan_hash varbinary(64) declare @query_num int = 1 declare c1 cursor for select query_hash, query_plan_hash from #t open c1 fetch next from c1 into @query_hash, @query_plan_hash; while @@fetch_status = 0 begin select top 1 @query_num as query_rank, s.*, p.*, replace (replace (substring (st.[text], s.statement_start_offset/2 + 1, case when s.statement_end_offset = -1 then len (convert(nvarchar(max), st.[text])) else s.statement_end_offset/2 - s.statement_start_offset/2 + 1 end), char(13), ' '), char(10), ' ') as sample_statement_text from sys.dm_exec_query_stats s cross apply sys.dm_exec_query_plan(s.plan_handle) as p cross apply sys.dm_exec_sql_text(s.sql_handle) as st where s.query_hash = @query_hash and s.query_plan_hash = @query_plan_hash; fetch next from c1 into @query_hash, @query_plan_hash; select @query_num = @query_num + 1; end deallocate c1 go drop table #t go[http://blogs.msdn.com/b/dsazurejp/archive/2011/06/27/sql-azure-performance-script.aspx:title=[SQL Azure] 頻繁に実行されるクエリのパフォーマンスを監視する便利なスクリプト - Microsoft Azure サポート チーム サイト - Site Home - MSDN Blogs]
でてきた。
ShowPlanXMLをもうちょっと見やすく
query_plan列にはShowPlanXML形式のXMLが有るんだがこれが実に見にくい。
もうちょっと何とかならんのかと思ったら何とかなった。
I've just rolled out the awesome HTML+CSS+JS view of the showplan XML using the XSLT from this project : http://code.google.com/p/html-query-plan/ (you can see it now if you visit the original link, above).
Interpreting SQL Server's Showplan XML - Database Administrators Stack Exchange
JustinPealing/html-query-plan · GitHub
これをダウンロード、展開して展開したフォルダにmsxsl.exeをコピーする。
Download Command Line Transformation Utility (msxsl.exe) from Official Microsoft Download Center
んで、qp.batにXMLを流し込めばOK
マウスホバーで詳細も見れる。
やるじゃん╭( ・ㅂ・)و