5. Define the length of intervals $(c, d)$, $[c, d)$, $(c, d]$, and $[c, d]$ to be $d-c$ ($d>c$). Given that the real number $a>b$. Then the length sum of the intervals formed by $x$ satisfying $\frac{1}{x-a}+\frac{1}{x-b} \geqslant 1$ is $(\quad$.
(A) 1
(B) $a-b$
(C) $a+b$
(D) 2
5.D.

The original inequality is equivalent to $\frac{2 x-(a+b)}{(x-a)(x-b)} \geqslant 1$.
When $x>a$ or $x>0$.
Let the two roots of $f(x)=0$ be $x_{1}$ and $x_{2}$ $\left(x_{1}<x_{2}\right)$, then the interval of $x$ that satisfies $f(x) \leqslant 0$ is $\left(a, x_{2}\right]$, and the length of the interval is $x_{2}-a$.

When $b<x<a$, similarly, the interval of $x$ that satisfies $f(x) \geqslant 0$ is $\left(b, x_{1}\right]$, and the length of the interval is $x_{1}-b$.

By Vieta's formulas, $x_{1}+x_{2}=a+b+2$, then the sum of the lengths of the intervals of $x$ that satisfy the condition is
$$
x_{2}-a+x_{1}-b=(a+b+2)-a-b=2 .
$$