RemoteDB

1. Create a table that record the start and end time of a project. The format:

projectID  startTime  endTime

Now we can get these 2 times by desc and asc, we can do this after apparently define project_id.

2. Define the format of logs, create a final-log-table in remoteDB, which contains the results of select of kinds of monitor tables. This is becausec command mysqldump cannot only export dedicated columns, the parameter where can only filter lines, resulting we can only get final-log from a result table and filter it with time range.

We can do this after define the format of final-log of terminal.

 

Frontends

1. When import into exclusiveDB, add a column called ifchecked, true means this log is searched once and has displayed in the webpage, it cannot be search out again. So we must set the ifchecked column corresponding to search results to true.

Error: Using command cur.execute("update filesysteminfo set ifchecked = %s" % initialval), but the value of ifchecked is null not 0, although print the command is "update filesysteminfo set ifchecked = 0"

Solution: After the above cur.execute, you have to run "conn.commit()", conn is the the object got from MySQLdb.connct(..). This commit all changes that you load into MySQL server. You could also use this approach to enable the auto commit setting, just after the MySQL connection initialization: dbb.autocommit(True)

 

2. Verify the order of columns when search exclusiveDB.

3. Modify usage of datatime.replace. When using replace(day=day+1), if day is 23 initially, it'll be 24 and out of hour range 0~23, resulting in an error.

The order of parameter is: timedelta([days[, seconds[, microseconds[, milliseconds[, minutes[, hours[, weeks]]]]]]]), and return an datetime object.

 

from datetime import timedelta

timespan=timedelta(days=1)

curdatetime=nowdatetime+timespan

4. Scroll

<div id="scrollText" style="width: 60%; margin: 0px auto;font-size:13px;color:#fff;position: absolute;z-index:1000;">
  <div style="height:26px; line-height:26px; border-bottom:#CCC dashed 1px; padding-bottom:4px; margin-bottom:4px;">实时信息</div>
  <div id="scrollDiv" style="width: 100%; overflow-y: auto;">
    <ul id="scrollUl" style="width: 100%;">
      {# <li>开始检测实时信息</li>#}
    </ul>
  </div>
</div>

5. flush in order with 1s interval,

I write this in setTimeout and different record has different delay time.

 

var sttr="<li style='color:#9aff02;float:left;width:100%;'>";
for ( var subcolum in result.content[i])
  sttr=sttr + " " + result.content[i][subcolum];
$(sttr + "</li>").prependTo(ul);

But the console.log output of "console.log(sttr+"</li>")" is "<li style='color:#9aff02;float:left;width:100%;'></li>", and "console.log(i)" is 19, which is out of range (the true tag is 0~18). So we must set i as an parameter of setTimeout function.

Finally we use methods of array in JavaScript push() and shift(), putting the value of each log record into the array.

push() will add one or more kinds of objects into the end of an array, and return the length of the array. The opposite method pop() will pop object from end of an array, those two can realize function as stack.

arrayObject.push(newelement1,newelement2,....,newelementX)

shift() will delete and return the value of first object in the array.

arrayObject.shift()

 6. Change the offlineproc time to now(), and push to apache.

push project to git repository:

fetch project from git repository:

 restart apache2

 the dashboard pc can connect to storage cluster and git server but cannot connect to db of yan.

sudo a2ensite 000-default  // but the code is not the latest fetch from repository.

汉化:

./manage.py makemessages

./manage.py compilemessages

server启动:

git pull origin master

rm -rf static/

source dashboardenv/bin/activate

./manage.py collectstatic

deactivate

sudo service apache2 restart

grant all on *.* to 'helen'@'192.168.101.72' identified by '123321';

helen'@'192.168.228.9

mysql -h192.168.101.71 -P3306 -uhelen -p123321 importdb < latest.sql

mysql -unsr -pnsr1234 HostMonitorData  < ./latest.sql

安装python-rados成功,开始不行,报错“Unable to locate package”,比较ubuntu16.04 (成功用apt安装python-rados)和ubuntu14.04的/etc/apt/sources.list,发现16.04的源的url几乎都以cn打头,14.04是en打头,所以

16.04:

14.04:

用16.04的/etc/apt/sources.list替换14.04,"sudo apt update"更新软件源,再次“sudo apt install python-rados”即可安装成功,既可以执行python2编写的操作存储集群的脚本,至此只有周期性执行download这一条没有测试通过:

 display server上无法操作存储集群,能够正确拼接python2脚本路径,此时python2脚本中写的绝对路径

通过tail -f /var/log/apache2/error.log看到错误为访问权限:

这几个文件的权限与虚拟机上权限相同:

如果python2脚本中写相对路径

报错没找到相应log文件,路径错误,用os.getcwd()取得路径是/var/www;

这是apache执行的根目录,存放静态文件:

不能使用django的BASE_DIR

会有一连串的问题:

所以最简单方法使用绝对路径,添加root的写权限:

 

 修改权限后还是有错误:

 从ceph_error.log可以看到对import目录没有写权限:

下面添加写权限:

 

 

在git中如果想忽略掉某个文件,不让这个文件提交到版本库中,可以使用修改根目录中 .gitignore 文件的方法(如无,则需自己手工建立此文件)。这个文件每一行保存了一个匹配的规则例如:

1
2
3
4
5
6
7
# 此为注释 – 将被 Git 忽略
 
*.a       # 忽略所有 .a 结尾的文件
!lib.a    # 但 lib.a 除外
/TODO     # 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO
build/    # 忽略 build/ 目录下的所有文件
doc/*.txt # 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt

规则很简单,不做过多解释,但是有时候在项目开发过程中,突然心血来潮想把某些目录或文件加入忽略规则,按照上述方法定义后发现并未生效,原因是.gitignore只能忽略那些原来没有被track的文件,如果某些文件已经被纳入了版本管理中,则修改.gitignore是无效的。那么解决方法就是先把本地缓存删除(改变成未track状态),然后再提交:

1
2
3
git rm -r --cached .
git add .
git commit -m 'update .gitignore'

 Today‘s Tasks:

 apache django

deamon service

ht

posted on 2017-08-29 15:42  Helenbj  阅读(258)  评论(0编辑  收藏  举报