示例#1
0
文件: task.py 项目: feifeigood/watch
def check_session_stats(t):
    """Please see "Activity -> Session monitor -> Session -> Session stats" to find all available statistic names."""
    r = execute(
        t.target,
        "select s.sid, n.name, s.value from v$sesstat s join v$statname n on s.statistic# = n.statistic#"
        " where n.name = :statistic_name and s.value >= :value order by s.value desc",
        {**t.parameters}, 'many', False)
    return t.get_message(
        r, lambda o, i: 'Session {} on {} has {} = {}.'.format(
            t_link(f'{o.target}/S/{str(i[0])}', str(i[0])), o.target, i[1],
            get_num_str(i[2])), None, 0)
示例#2
0
文件: task.py 项目: feifeigood/watch
def check_frequent_sql(t):
    """This task based on v$sqlarea which accumulate statistics since SQL statement had been cached."""
    r = execute(
        t.target, "select sql_id, parsing_schema_name, executions,"
        " to_char(to_date(first_load_time, 'yyyy-mm-dd/hh24:mi:ss'), 'dd.mm hh24:mi')"
        " from v$sqlarea where parsing_schema_name not like '%SYS%'"
        " and executions > :executions order by executions desc",
        {**t.parameters}, 'many', False)
    return t.get_message(
        r, lambda o, i: '{} ({}) executed {} times since {}.'.format(
            t_link(f'{o.target}/Q/{i[0]}', i[0]), i[1], get_num_str(i[2]), i[3]
        ), lambda o: f'Frequent executions on {o.target}', 0)