/*
 * Shows number of processes. Returns output 2x -> made for MRTG.
 *
 * This program is in the public domain.
 */

#include <sys/param.h>
#include <sys/sysctl.h>

#include <fcntl.h>
#include <kvm.h>
#include <paths.h>
#include <stdio.h>

int 
main(void)
{
	char *execf, *coref, error[2048];
	struct kinfo_proc *procs;
	kvm_t *kd;
	int count;

	coref = execf = _PATH_DEVNULL;

	kd = kvm_openfiles(execf, coref, NULL, O_RDONLY, error);
	if (kd == 0)
		return (0);

	if ((procs = kvm_getprocs(kd, KERN_PROC_ALL, 0, &count)) == 0)
		return (0);

	printf("%d\n%d\n", count, count);

	return (0);
}
